I'm trying to write a script that will start an X application if it's not already running, but will find it and pop it to the front if it is already running (maybe it's lost on a busy desktop).
Is there such a mechanism?
Here is part of the logic:
VRDP="$(ps ax|grep "rdesktop .* $SERVER[:]$PORT")"
if [ -z "$VRDP" ]; then
rdesktop $SERVER:$PORT &
else
PID="$(echo $VRDP | sed 's/ *\([0-9]*\) .*/\1/')"
# Pop $PID to the front here
fi
The X primitive you want, I believe, is "raise". Window managers (KDE, Gnome, Xface, etc) might have some customizable interface so that you can ask window with a certain title to be raise()d.
I found one command that might give you what you need... it's called wmctrl, and according to the man page you can do:
BTW, thank you otheus. That does just what I wanted.
I now have a shell script that starts my selected VirtualBox virtual machine if it's not running, opens an RDP window to it if it's not open, and takes me to it if it's already running and open.