Xfce Forum

Sub domains
 

You are not logged in.

#1 2013-09-08 21:12:56

epsilon0
Member
Registered: 2013-09-08
Posts: 2

[Solved] Switch workspaces in two dimensions

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.

Offline

#2 2013-09-08 22:20:22

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,494

Re: [Solved] Switch workspaces in two dimensions

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.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2013-09-08 23:09:57

epsilon0
Member
Registered: 2013-09-08
Posts: 2

Re: [Solved] Switch workspaces in two dimensions

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.

Offline

#4 2013-09-09 00:24:12

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,494

Re: [Solved] Switch workspaces in two dimensions

Very nice. Thanks for sharing.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2014-02-23 05:51:16

blackbird
Member
Registered: 2014-02-23
Posts: 1

Re: [Solved] Switch workspaces in two dimensions

Sorry for the necropost... I'm having a similar issue, and didn't want to start a new thread. My issue isn't persistent though - it only occurs on reboot. I generally name my workspaces, and move between them using ctrl+alt+arrow keys. In XFCE 4.8 on Debian 7.4, I set everything up just the way I like it, including the naming of workspaces and giving the switcher 2 rows instead of 1, with a total of 4 workspaces. The shortcut keys work just fine. Reboot, and... suddenly, this no longer works. The switcher LOOKS as if it has 2 rows, but behaves as if all 4 workspaces are in a single row, i.e. ctrl+alt+left or right works, but up or down doesn't, and using left or right moves amongst the workspaces as if they were on one row, workspace 1 thru 4 in order. I have found a temporary workaround - I open the workspace switcher properties dialogue, select and then deselect the "show miniature view" checkbox, and things are back to "normal". But if I reboot (or log out/back in - I'm not sure, I'll try that in a few minutes) the issue returns. So I know the functionality is there, without having to write or use an extra script. Any ideas?

Offline

#6 2014-12-02 23:44:22

gregory.0xf0
Member
Registered: 2013-06-12
Posts: 1

Re: [Solved] Switch workspaces in two dimensions

blackbird wrote:

Sorry for the necropost... I'm having a similar issue, and didn't want to start a new thread. My issue isn't persistent though - it only occurs on reboot. I generally name my workspaces, and move between them using ctrl+alt+arrow keys. In XFCE 4.8 on Debian 7.4, I set everything up just the way I like it, including the naming of workspaces and giving the switcher 2 rows instead of 1, with a total of 4 workspaces. The shortcut keys work just fine. Reboot, and... suddenly, this no longer works. The switcher LOOKS as if it has 2 rows, but behaves as if all 4 workspaces are in a single row, i.e. ctrl+alt+left or right works, but up or down doesn't, and using left or right moves amongst the workspaces as if they were on one row, workspace 1 thru 4 in order. I have found a temporary workaround - I open the workspace switcher properties dialogue, select and then deselect the "show miniature view" checkbox, and things are back to "normal". But if I reboot (or log out/back in - I'm not sure, I'll try that in a few minutes) the issue returns. So I know the functionality is there, without having to write or use an extra script. Any ideas?

That looks like https://bugzilla.xfce.org/show_bug.cgi?id=10229

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.010 seconds, 7 queries executed - Memory usage: 547.67 KiB (Peak: 548.52 KiB) ]