I want to retrieve the X id of GUI programs I launch in background, in order to work on their windows properties. I've been so far using this workaround:
myprogram &
sleep 1
winID=$(wmctrl -l | awk '/./{line=$0} END{print $1;}')
But this relies on three heavy assumptions:
- the program will take less than 1 second to get its window opened (not to mention than 1 second can be far too long)
- the window will be appened at the end of the
wmctrl
list - no other window will be opened meanwhile
Is there any signal myprogram
will send once it has opened a window? How can I intercept it?