Xfce Forum

Sub domains
 

You are not logged in.

#1 2024-03-19 07:45:37

yump
Member
Registered: 2024-01-02
Posts: 3

Toggling between 2 workspaces using shortcut key

Hi, I am looking to setup a keyboard shortcut to toggle between 2 workspaces. However, I can't find any option in "Window Manager >  Keyboard" section to assign this shortcut. This is the only thing missing from my perfect setup, Any help is appreciated smile

Offline

#2 2024-03-19 10:39:51

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

Re: Toggling between 2 workspaces using shortcut key

If by "toggle" you mean automatically switching between only two workspaces, then that does not exist. The keyboard shortcuts allows you to move to different workspaces using different shortcuts.

However, you can create a script that does this and assign your keyboard shortcut to the script. Here is a sample script that uses the wmctrl utility (you may need to install it):

#!/usr/bin/env bash 

# set these to the two workspaces you want to toggle. 
WS1=1
WS2=2

CURRENT=$(( $(wmctrl -d | grep " \* " | awk '{print $1}') + 1 ))

if [ $CURRENT -eq $WS1 ]; then
	wmctrl -s $(( $(echo $WS2) -1 ))
else
	wmctrl -s $(( $(echo $WS1) -1 ))
fi

exit 0

Edit the "WS1" and "WS2" variables to indicate the workspace numbers you want to toggle and make the file executable. Then create a keyboard shortcut for it in Settings Manager > Keyboard > Application Shortcuts.


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

Board footer

Powered by FluxBB