Skip to content

Instantly share code, notes, and snippets.

@wojtha
Created November 12, 2014 15:03
Show Gist options
  • Save wojtha/e9ed6f355e2222875a50 to your computer and use it in GitHub Desktop.
Save wojtha/e9ed6f355e2222875a50 to your computer and use it in GitHub Desktop.
xdotool - scripting X11 from command line
# Absolute switching
xdotool set_desktop 0
xdotool set_desktop 1
xdotool set_desktop 2
xdotool set_desktop 3
# Relative switching
xdotool set_desktop $(echo $(($(xdotool get_desktop) + 1)))
xdotool set_desktop $(echo $(($(xdotool get_desktop) - 1)))
# What about the max num of desktops?
echo $(( ( $(xdotool get_desktop) + 1 ) % $(xdotool get_num_desktops)))
echo $(( ( $(xdotool get_desktop) - 1 ) % $(xdotool get_num_desktops)))
# Hmm, but we can get -1 and bash has no abs() function
# Bit hey there is a undocumented --relative argument!
xdotool set_desktop --relative -- 1
xdotool set_desktop --relative -- -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment