Cycle through workspaces
There is no existing command to cycle through workspaces, but as alway, we can make it.
Run the script below from a convenient shortcut and it will do exactly as you describe: cycle through the existing workspaces. Once the last is reached, it jumps back to the first.
Note That dynamic workspaces needs to be set to false
The script
Using Wnck
, we can get information on both the (list of) workspaces, as well as the current one. Subsequently, we can move to any other of the listed workspaces in an organized way.
Please make sure Wnck
is installed:
sudo apt install python3-gi gir1.2-wnck-3.0
Then copy the script below into an empty file, save it as cycle_workspaces.py
, make it executable and run it from a shortcut of your choice. (running: /path/to/cycle_workspaces.py
)
#!/usr/bin/env python3
import gi
gi.require_version("Wnck", "3.0")
gi.require_version("Gtk", "3.0")
from gi.repository import Wnck, Gtk
scr = Wnck.Screen.get_default()
scr.force_update()
# list existing workspaces
workspaces = scr.get_workspaces()
# get the (index of) current one
currws = workspaces.index(scr.get_active_workspace())
# since first in list has index 0, subtract 1, if index is last,
# move to first index of the list (workspaces)
if currws == len(workspaces) - 1:
next_workspace = workspaces[0]
# else pick the next in list
else:
next_workspace = workspaces[currws + 1]
# and activate it...
next_workspace.activate(Gtk.get_current_event_time())
Enjoy!
gsettings get org.gnome.mutter dynamic-workspaces
)