How can I set a minimum of workspaces which should always stay available in Gnome 3?

1

I have been using Ubuntu Oneiric Ocelot (11.10) with gnome-shell (Gnome 3) for a little while and I'm trying to get accustomed to it.

Another question asked if the dynamic workspace creation in Gnome 3 can be disabled, which seems not to be perfectly possible currently.

What I would prefer instead is to set a fixed amount of workspaces which should be created on login and should stay alive even if no windows are in them, while still giving me the option to create more workspaces dynamically. Is such a thing currently possible in Gnome 3?

One dirty hack could be to force some micro-sized window to be created in each of the workspaces on startup. Using devilspie this may be possible, although I don't know if this still works for Gnome 3. The best case would be creating persistent invisible windows somehow. Does anyone know a way?

aef

Posted 2011-11-17T03:02:38.557

Reputation: 1 052

Answers

1

I know this is an old post, but i stumbled across it when searching for this myself. I'm using ubuntu 12.04 and I created a patch that allows exactly what your describing.

DISCLAIMER:

This patch may stop working if gnome-shell updates, and enough changes are made to make the patch get rejected. If you wish to try it out, make sure you backup everything before applying the patch. If something goes wrong, you can restore the file and have a working desktop again.

END DISCLAIMER

Just save the bellow code in a file (eg: gnome-shell.patch):

--- /usr/share/gnome-shell/js/ui/main.js        2012-03-29 21:15:44.899552355 +0300
+++ /usr/share/gnome-shell/js/ui/main.js        2012-03-29 21:38:17.603507004 +0300
@@ -273,9 +273,20 @@
  */
 const LAST_WINDOW_GRACE_TIME = 1000;

+function _getFixedWorkspaces(){
+    let settings = new Gio.Settings({ schema: 'org.gnome.fixedWorkspaces' }); 
+    let nr_workspaces = settings.get_int('minworkspace');
+    if (nr_workspaces == 0){
+        return 1;
+    }
+    return nr_workspaces;
+}
+
+
 function _checkWorkspaces() {
     let i;
     let emptyWorkspaces = [];
+    let min_wrk = _getFixedWorkspaces();

     if (!Meta.prefs_get_dynamic_workspaces()) {
         _checkWorkspacesId = 0;
@@ -284,6 +295,7 @@

     for (i = 0; i < _workspaces.length; i++) {
         let lastRemoved = _workspaces[i]._lastRemovedWindow;
+        if ( i < min_wrk-1){ _workspaces[i]._keepAliveId = true; }
         if ((lastRemoved &&
              (lastRemoved.get_window_type() == Meta.WindowType.SPLASHSCREEN ||
               lastRemoved.get_window_type() == Meta.WindowType.DIALOG ||

This patch looks for a dconf setting to determine the minimum number of workspaces you want. Create a file called org.gnome.fixedWorkspaces.gschema.xml and paste the following:

<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
  <schema path="/org/gnome/fixedWorkspaces/" id="org.gnome.fixedWorkspaces" gettext-domain="fixedWorkspaces">
    <key type="i" name="minworkspace">
      <default>4</default>
      <range min="1" max="32"/>
      <summary>Minimum workspaces</summary>
      <description>This option sets the minimum number of desktops that the shell should stat with.</description>
    </key>
  </schema>
</schemalist>

Now you must copy the schema file in a location where gnome knows where to look:

cp org.gnome.fixedWorkspaces.gschema.xml /usr/share/glib-2.0/schemas/

Compile the schemas:

glib-compile-schemas /usr/share/glib-2.0/schemas/

And finally, apply the gnome-shell patch:

patch /usr/share/gnome-shell/js/ui/main.js < gnome-shell.patch

Log out, and back in and you should have a minimum of 4 workspaces (default value). You may customize the number of workspaces using dconf-editor.

Gabriel Samfira

Posted 2011-11-17T03:02:38.557

Reputation: 126