I have XFCE configured with nine workspaces, which are displayed in Workspace Switcher in three rows of three. I have disabled workspace switching with the scrool wheel, and the ability to move a window or the mouse pointer to an adjacent workshpace by crossing the workspace edge. I have Ctrl-up, Ctrl-down, Ctrl-left and Ctrl-right bound to commands to switch to a workspace in the corresponding direction (keys are bound to `(up|down|left|right)_workspace_key', under xfwm4->custom in kxfe4-keyboard-shortcuts).
With this arrangement XFWM treats the workspaces as a single row on nine workspaces. Ctrl-up and Ctrl-down have no effect, and Ctrl-left and Ctrl-right move between workspaces in order 1 <-> 2 <-> 3 <-> 4 <-> 5 <-> 6 <-> 7 <-> 8 <-> 9 <-> 1.
How can I configure XFWM to treat the workspaces as three rows of three, with horizontal and vertical navigation? I want Ctrl-left and Ctrl-right to switch between workspaces within a row, wrapping within the row at the ends (ie, switching within three groups, 1 <-> 2 <-> 3 <-> 1, 4 <-> 5 <-> 6 <-> 4, and 7 <-> 8 <-> 9 <-> 7), and for Ctrl-up and Ctrl-down to do the same for the columns (groups 1 <-> 4 <-> 7 <-> 1, 2 <-> 5 <-> 8 <-> 2, and 3 <-> 6 <-> 9 <-> 3).
I am using an up-to-date version on Arch Linux, which includes XFCE 4.10.
Here is a script you can use (requires wmctrl):
#!/bin/bash #get the current workspace CURRENT=$(($(wmctrl -d | grep "*" | cut -d' ' -f1)+1)) #the workspace movement logic case $CURRENT in 1) LEFT=3; RIGHT=2; UP=7; DOWN=4;; 2) LEFT=1; RIGHT=3; UP=8; DOWN=5;; 3) LEFT=2; RIGHT=1; UP=9; DOWN=6;; 4) LEFT=6; RIGHT=5; UP=1; DOWN=7;; 5) LEFT=4; RIGHT=6; UP=2; DOWN=8;; 6) LEFT=5; RIGHT=4; UP=3; DOWN=9;; 7) LEFT=9; RIGHT=8; UP=4; DOWN=1;; 8) LEFT=7; RIGHT=9; UP=5; DOWN=2;; 9) LEFT=8; RIGHT=7; UP=6; DOWN=3;; esac #move to new workspace case $1 in left) $(wmctrl -s $(($LEFT-1)));; right) $(wmctrl -s $(($RIGHT-1)));; up) $(wmctrl -s $(($UP-1)));; down) $(wmctrl -s $(($DOWN-1)));; esac
Create keyboard shortcuts to the script sending the parameters left, right, up, down as required.
Thanks for the quick response, and the idea of writing a script using `wmctrl'. I rewrote the script so that it can be configured to work for any number of rows or columns.
#!/bin/bash # # Switch to workspace left, right, up, or down from current for # workspaces arranged in `$num_rows' rows and `$num_cols' # columns. Wraps around within the current row for left and right and # within the current column for up and down. # # Usage: switch-workspace (left|right|up|down) # # Configuration num_rows=3 ; num_cols=3 ; # Workspaces are numbered 0 .. $num_rows*$num_cols-1. current=$( wmctrl -d | grep "*" | cut -d ' ' -f 1 ) ; row=$(( $current / $num_cols )) ; col=$(( $current % $num_cols )) ; case $1 in left) col=$(( ( $col + $num_cols - 1 ) % $num_cols )) ; ;; right) col=$(( ( $col + 1 ) % $num_cols )) ; ;; up) row=$(( ( $row + $num_rows - 1 ) % $num_rows )) ; ;; down) row=$(( ( $row + 1 ) % $num_rows )) ; ;; esac ; wmctrl -s $(( $row * $num_cols + $col )) ;
I set up keyboard shortcuts to call this script, and everything works fine.
Very nice. Thanks for sharing.