xafter
xafter – wait until a specified X11 window has closed
xafter [ window-id ]
xafter lets you specify an X11 window by its numeric ID, or alternatively allows you to select one interactively with the mouse pointer, and then it waits until that window has closed.
You might use xafter, for example, if you were running a CPU-intensive process group (such as a long software compilation) while also having a video call, and found that the CPU-heavy job was interfering with your video call quality. In that situation, you might suspend the job with Ctrl-Z, intending to resume it with ‘fg’ once the call is finished. But this risks forgetting, and finding out three hours later that the job is still waiting to be resumed (ask me how I know). So instead, you could immediately run
xafter; fg
and click to select the video call window. Then the job will automatically resume as soon as that window closes.
Sometimes the owning application gives you a way to find this out; for example, some terminal emulators define $WINDOWID in the environment of the shell running inside them. Programmable window managers (such as Sawfish) can also tell you window ids.
The id can be specified in decimal, or in hex with a ‘0x’ prefix. For example, ‘xafter 79691945’ and ‘xafter 0x04c000a9’ are both valid, and mean the same thing.
If you do not specify the window id, then xafter will run a preliminary interactive selection process: your mouse pointer will become a crosshair, and you can select a window to wait for by placing the crosshair over it and clicking the left mouse button. If you click the right button instead, it aborts the selection and xafter will terminate immediately without waiting for anything.