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,402

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

#3 2024-10-04 18:17:57

k-3.14
Member
From: Rhineland
Registered: 2017-02-18
Posts: 156
LinuxFirefox 115.0

Re: Toggling between 2 workspaces using shortcut key

Was searching the internet for a solution.
Have 2 workspaces here and if I am in full screen mode in a program on one screen, I can not switch to the other workspace with scrolling the mouse wheel.
Again here I found the solution for that. Now I have your script on those obsolete WIN keys on the keyboard. Works like a charm!

br KH

Offline

#4 2024-10-08 06:18:14

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 861
UbuntuFirefox 131.0

Re: Toggling between 2 workspaces using shortcut key

FYI:

i have 20 workspaces on each user and around 23 users.  everything has shortcuts.  10 shortcuts go to 10 workspaces by pressing a keypad number from 0 to 9.  then there are 10 more by holding (pre-pressing with sticky keys on) CTRL.  so i can flip between 2 workspaces by just alternately pressing the keys.

i think i will extend this by having the key script record the last two workspaces, and create a new key script that switches to the previous workspace and exchange the last two recordings.

FYI, i switch users with ALT+letter where letter is that user's first or last letter.  I use the logo key in place of the alt key for a few users.  that overloads a few default shortcuts i never use.  you might want to use Ctrl+Alt+letter or something else.

yes, up to 23 logged in users X 20 workspaces (especially with fullscreen terminals on 180 of them) can eat a lot of memory.  my 16 GB runs out quickly.  i need to up the RAM but that is waiting on a new laptop that will be 32 GB or 64 GB.

Offline

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

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.007 seconds, 7 queries executed - Memory usage: 534.88 KiB (Peak: 535.72 KiB) ]