Remove unnecessary empty workspace

I would like to reduce the number of workspaces by 1. This would prevent there always being one empty workspace. Or, when there are no windows, there is would be only 1 empty workspace instead of 2.

Is there a way to do this (settings or extension). I haven’t been able to find anything unfortunately.

Yes: Disable dynamic workspaces and set the number of workspaces to 1.

In GNOME 41, you can use the “Multitasking” panel in settings. In older versions, you have to resort to the command line:

$ gsettings set org.gnome.mutter dynamic-workspaces false
$ gsettings set org.gnome.desktop.wm.preferences num-workspaces 1

Thanks for the reply.

Unfortunately not completely what I meant. I do want dynamic workspaces, but just not the second workspace when there is no windows open.

By the way the setting you mention is also available in Tweaks (at least on Ubuntu 21.10).

I do want dynamic workspaces, but just not the second workspace when there is no windows open.

Ah, so the pre-40 behavior?

There is no setting, but an extension can change imports.ui.windowManager.MIN_NUM_WORKSPACES to 1.

Yes that works!

I guess I’ll make it configurable and then post the extension.

Thanks a lot!

Here it is for references: Prevent double empty window - GNOME Shell Extensions

Since setting it to >2 has no effect, I didn’t implement any configuration.

Increasing the variable should work just as well as setting it to 1.

Of course it would only take effect the next time that the code that reads it runs (for example after opening or closing a window).