xdotool desktop features
Posted Sat, 31 May 2008
Tonight I added 7 new commands to xdotool (not yet in a release):
- get and set the number of desktops
- get and set the currently active desktop
- get and set the desktop for a specific window (set == move it to a new desktop)
- activate a window
The last is window activation. It will jump you to the window and give it focus. If the window is on a different desktop, it jumps to that desktop and then activates the window. I've tested exactly that behavior (firefox lives on a separate desktop or workspace) in Gnome2 and ion-3, and it works.
Example: Jump to firefox:
./xdotool windowactivate $(./xdotool search -title "Mozilla Firefox")Example: Trying to do bad things in Gnome2
% ./xdotool set_num_desktops 5000 % ./xdotool get_num_desktops 36Example: Move firefox to another desktop
# Find firefox's X Window ID % MOZWIN=$(./xdotool search --title "Mozilla Firefox") # Find the desktop containing firefox. % ./xdotool get_desktop_for_window $MOZWIN 0 # How many desktops do we have? % ./xdotool get_num_desktops 5 # Move firefox to desktop 3 (index starts at 0) % ./xdotool set_desktop_for_window $MOZWIN 3 # Show me that firefox has moved to desktop 3 % ./xdotool get_desktop_for_window $MOZWIN 3 # Show me the current desktop % ./xdotool get_desktop 0 # Activate firefox's window (taking us to Firefox's desktop) % ./xdotool windowactivate $MOZWIN # Show that we're now on the same desktop as firefox % ./xdotool get_desktop 3I'll put out a new release after I have a chance to tidy up the code a bit.