5

I'm using Ubuntu 18.04. I can find the option to change the keyboard shortcuts to move to workspace 1, 2, etc. but there doesn't seem to be an option to go to the 'next workspace', cycle through existing workspaces, as I would do with alt+tab to switch across windows.

Clicking the '+' button in the 'keyboard shortcuts' window to create a custom shortcut would probably do the trick. But I do not know what would be the command I would have to use.

2
  • 1
    Cycle through assumes dynamic workspaces off, right (run gsettings get org.gnome.mutter dynamic-workspaces) Jun 10, 2019 at 20:48
  • 1
    That's right, dynamic workspaces are off. I set this off with a tool called Tweaks. Jun 10, 2019 at 20:50

2 Answers 2

4

The Workspace Switch Wraparound GNOME Shell extension enables cycling. It officially supports up to GNOME Shell v3.32, but in practice it works on even Ubuntu 20.04 LTS (Focal Fossa).

Update June 2022: it also works perfectly fine on Ubuntu 22.04 LTS.

2

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!

1
  • Works like a charm, thank you!! Now I can do super+tab to move vertically across workspaces and alt+tab to move across windows in a given workspace. Love it! Jun 11, 2019 at 8:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .