I know in the gnome-shell extension we can append workspaces by calling global.workspace_manager.append_new_workspace.
I have searched the source code of gnome-shell. I found that the variable global is from Shell.Global.get(). And the Shell is imported like this: const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi;.
The above code is in gnome-shell/js/ui/environment.js.
As you can see the Shell is from the js version of GI.
I tried to write this kind of code in Python like this: from gi.repository import Shell.
But it seems that there is no Shell in the python version of GI at all, is this true?
Recently Iāve learned Wnck which surprised me at first. Now I know that it does not provide APIs to append/insert workspaces.
So is it impossible to append or insert workspaces in other language bindings like Python except js?
Iām writing some sort of application in which it need to append workspaces in some cases.
I know I can add this feature in a gnome shell extension, add schema and key, then access them via GIO.Settings.
Iām still looking forward to implementing this feature just in Python.
Shell, St and Meta arenāt installed in the default path, because they are not meant for applications. In fact, I donāt expect much of its API to work at all when used outside the gnome-shell process (independent from the language used - C, JS or python).
There are ways to do workspace management from outside gnome-shell (forcing static workspaces and changing the num-workspaces setting, or talking D-Bus), but it is generally something that is considered under user control that applications arenāt meant to touch.
Unless you are writing something like a dock or taskbar (that will be limited to the legacy X11 session), I strongly recommend to reconsider whatever it is that you are trying to do
forcing static workspaces and changing the num-workspaces setting
This is a good idea. But I think it depends on some conditions.
1.Users prefer using Dynamic Workspaces
Then users may will be stuck with the Fixed Workspaces, they cannot add or move windows into new workspace due to any reason that they believe. I think itās not a good idea to change this option to Fixed Workspaces for user.
2.Users prefer using Fixed Workspaces
Then perhaps it will be OK for users.
I know a gnome-shell extension named āMinimum Workspacesā located at āMinimum Workspaces - GNOME Shell Extensionsā which works well on Fedora 32 and has a fixed numbers of workspaces but allow more workspaces to be added. Can you add this feature into gnome itself as an extra option along with the Dynamic Workspace and Fixed Workspaces? But I donāt expect this will happenā¦
or talking D-Bus
I donāt know D-Bus but will learn it later to see what it can doā¦
I agree. In fact, I donāt think it is a good idea to change any workspace-related option for the user ā including the number of workspaces ā unless it is in response to a user action that is clearly marked as such (like a click on a āAdd workspaceā button for example).
What exactly is the use case for that? Off-hand I canāt think of one that would be strong enough to justify a build-in option.