Ubuntu – 18.04 (gnome) workspaces – How to manipulate (e.g. arbitrarily reorder) workspaces

gnomeworkspaces

Gnome workspaces are very convenient to use, but I find them very difficult to manage. For example:

  • Shutting the last window in a workspace causes that workspace to close (if not immediately, then soon)
  • New windows can only be inserted at the always present empty workspace at the bottom.
  • Moving workspaces around would require moving each window individually, and if a workspace becomes empty during that intended process the workspace will close.

Features I though exist but can't find are:

  • Ability to suppress auto-closing of workspaces, perhaps to replace with a close-(empty)-workspace command.
  • Ability to rotate workspaces (so the empty workspace could be placed anywhere)
  • Ability to swap any workspace with its lower neighbor

Maybe I am just ignorant about commonly known facts. Or, maybe Gnome offers an API for programming in this behavior. Or maybe it's impossible.

Please inform.


Addendum: A few days after selecting the answer for this question, I found a relatively easy API to achieve stated goals. That information is provided below as a new answer.

Best Answer

In GNOME Shell, one cannot, by default, move around entire workspaces with the applications they contain. While this would be a powerful feature, I do not know Linux desktop environments that feature this.

With respect to an API, GNOME Shell has the mechanism of extensions. This actually is not an API at all. It is essentially a "(potential security) hole" in the system where developers can inject their own javascript code to change the behaviour of the Shell. The many GNOME Shell extensions around exist illustrate what can be done, in many cases with great success.

With respect to the features you expect, the situation is as follows:

Ability to suppress auto-closing of workspaces, perhaps to replace with a close-(empty)-workspace command.
By default, GNOME Shell comes with dynamic work spaces. This, however, can be turned off, and you can set a number of fixed workspaces. To achieve this, install (GNOME) Tweaks, and select "Static workspaces" on the "Workspaces" tab as illustrated here.

Ability to rotate workspaces (so the empty workspace could be placed anywhere)
There is no possibility to change the order of workspaces (and their content), unfortunately. You only can move applications around. Of course, with static workspaces, an empty workspace remains empty.

Ability to swap any workspace with its lower neighbor
It depends what you mean with this. If you mean again changing the order of workspaces, then see the point above. If you mean quickly switching workspaces, then this is easily achieved with the shortcut keys Ctrl+Alt+Up/Down or Super+PgDn/PgUp.

Switching to static workspaces can give you more control on what is where, with the restriction that you cannot move entire workspaces around.

Some tips to enhance a workflow with static workspaces

  • You can install the Workspace Indicator GNOME Shell extension to provide an indicator of the current workspace you are on. The extension allows you to rename your workspaces if you wish (e.g. "1 - Browsing" rather than "1").

  • You can configure hotkeys to quickly switch to a specific workspace or move an application, for example:

    gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-4 "['<Super>4']"
    gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-4 "['<Super><Shift>4']"
    

These commands will set up a hotkey Super+4 that immediately brings you to WS 4, and a hotkey Super+Shift+4 that moves an application to WS 4 (much like it works in the tiling window manager i3).

Related Question