while xprop -display :0.1 -root | grep mythfrontend ; do #active window doesn't exist in 0.1 :(( if ! xprop -display :0.1 -id `xprop -display :0.1 -root _NET_ACTIVE_WINDOW | cut -c 41-` ; then echo "Selecting the right window!" if xprop -display :0.1 -root | grep xine ; then DISPLAY=:0.1 wmctrl -a xine elif xprop -display :0.1 -root | grep mplayer ; then DISPLAY=:0.1 wmctrl -a mplayer else DISPLAY=:0.1 wmctrl -a mythfrontend fi fi done