Search this site


Metadata

Articles

Projects

Presentations

xdotool desktop features

I spent a while tonight reading up on extended window manager hints. It's not a very well thought-through standard, but many window managers implement it nonetheless.

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 first 3 should be pretty straight forward. For fun, I told Gnome2 to create 50 workspaces, and it didn't barf. The taskbar pager looked a little funny as it was sprawling with little desktop views, but it works :)

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
36
Example: 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
3
I'll put out a new release after I have a chance to tidy up the code a bit.