dereenigne.org

reverse engineered

GNOME Workspace Wraparound

I found out yesterday that GNOME (or more correctly, the GNOME window manager, Metacity) only allows you to switch to a specific workspace. You cannot cycle through workspaces, wrapping around to the first when on the last. There is a long-standing upstream bug report, about this issue, but sadly it is marked as wontfix.

I have, however, found a workaround using wmctrl. These commands could obviously be much nicer if they were placed in a proper script, but I wanted a one line snippet that I could add to my xbindkeys config. This allows me to execute these commands using keyboard shortcuts.

# Workspace Increment
wmctrl -s $(( $(( $(wmctrl -d | sed -n 's/^\([0-9]\+\) *\*.*/\1/p') + 1 )) & 3 ))

# Workspace Decrement
wmctrl -s $(( $(( $(wmctrl -d | sed -n 's/^\([0-9]\+\) *\*.*/\1/p') - 1 )) & 3 ))

Note: In order to minimise the calls to wmctrl, I’ve hardcoded my number of workspaces (4 in my case) as a bitwise AND in the last portion of these commands.


comments powered by Disqus