XTOOLWAIT(1)

NAME
xtoolwait - start X client and wait for it to map a window

SYNOPSIS
xtoolwait [ -display display-name ] [ -timeout nseconds ] [ -mappings nwindows ] [ -pid ] [ -help ] [ -version ] command

DESCRIPTION
Xtoolwait notably decreases the startup time of an X session by reducing the load on the X server and the OS. Xtoolwait starts the X client command in the background. It then waits until a window is mapped on the root window and exits. Xtoolwait also exits if a time-out occurs (by default after 15 seconds), or if command exits.

OPTIONS

-display display-name
    Monitor the X display display-name for window mapping events. If this option is not used, the X display defaults to the value of the DISPLAY environment variable. See also section NOTES below.

-timeout nseconds
    Use a time-out period of nseconds seconds. If this option is not used, the time-out period defaults to 15 seconds.

-mappings nwindows
    Exit after nwindows windows have been mapped, instead of the default of one window. Use this option only if you are absolutely sure that command will map nwindows top-level windows, in which case it will slightly increase the performance.

-pid
    Print the process id (pid) of command to standard output. This option is useful for shell scripts that want to wait for (or send a signal to) command. To support shell command substitution (`command`), Xtoolwait redirects the standard output of command to standard error.

-help
    Print out the `Usage:' command syntax summary.

-version
    Print out the version number.

USAGE
This is the relevant part of my own .xinitrc file, showing the proper use of Xtoolwait:

    #
    # Startup the window manager first
    #
    olvwm & wmpid=$!
    #
    # Restore desktop settings
    # Do _not_ put xtoolwait in the background
    #
    xtoolwait -mappings 2 contool -Wp 30 30 -Ws 575 246 -WP 3 533 -Wi
    xtoolwait xeyes -geom 77x60+640+107
    xtoolwait ansi_xterm -geom 80x24+22+11
    xtoolwait clock -Wp 90 90 -Ws 150 150 -WP 733 110 -Wi
    #
    # Wait for the window manager
    #
    wait $wmpid

Note that the window manager must be started first. Xtoolwait depends on it to detect window mappings. The first instance of Xtoolwait will wait until both the window manager and the X client have finished their initialization.

Note also that the first Xtoolwait uses the -mappings option to detect the virtual desktop window, which is mapped by virtual window managers. Omit this option if you use a non-virtual window manager.

EXIT STATUS
Xtoolwait returns 0 if it detected the mapping of a window on the root window, and 1 otherwise. The one exception to this rule is when command exits normally before mapping a window, in which case its return value is returned.

ENVIRONMENT

DISPLAY
    The default display name to monitor

SEE ALSO
xtoolplaces(1)

NOTES
Xtoolwait does not propagate the -display option to command. If you use this option, you should feed it both to Xtoolwait and to command. This is intentional, so don't report this as a bug.

AUTHOR
Xtoolwait was written by Richard Huveneers <richard@hekkihek.hacom.nl>. Check out http://www.hacom.nl/~richard for more information about the author.

COPYRIGHT
Copyright (C) 1995-1999 Richard Huveneers <richard@hekkihek.hacom.nl>. Xtoolwait is released under the GNU General Public License. The full copyright notice is stated at the start of the source code.

BUGS
Xtoolwait tries to ignore windows that are mapped by other X clients. The method used will fail if two or more X clients are started almost simultaneously. This situation does not arise as long as all X clients are started by Xtoolwait during the X session startup.