Open every app/window on a new worspace

Hello GNOME developers,

Does anybody know if there is a setting to open every app (or window) on a new workspace?
I would like to try something out. It would be very helpful!

Regards,

Scott Trakker

There is no such setting, but it’s fairly straight-forward to implement that behavior in an extension:

const { Meta } = imports.gi;

class Extension {
    constructor() {
        this._windowCreatedId = 0;
    }

    enable() {
        this._windowCreatedId = global.display.connect(
            'window-created', (dpy, window) => {
                if (window.window_type != Meta.WindowType.NORMAL)
                    return;
                let { workspaceManager } = global;
                let ws = workspaceManager.get_workspace_by_index(
                    workspaceManager.get_n_workspaces() - 1);
                window.change_workspace(ws);
                ws.activate_with_focus(window, global.get_current_time());
            });
    }

    disable() {
        global.display.disconnect(this._windowCreatedId);
        this._windowCreatedId = 0;
    }
}

function init() {
    return new Extension();
}

You can download the above code here.

2 Likes

You are a hero!!
This is perfect!!
Thanks a lot!

Now I can try out how this would work (as an usability experiment)!

One app can consist of multiple windows (for example when the option Single-Window mode in GIMP is not enabled). Do application know out of which windows they consist? Is it possible to keep those windows together on one workspace ? In other words: can you adjust the script in such away that every app is opened on a new workspace and not necessarily every window?

Sure, later tonight. Right now we have about two hours of daylight left here, so I’d rather head outside for a bit :wink:

Take your time!

I understand what you mean; I also went outside for a few hours!

Do you use your e-mail-address that is mentioned on the GNOME-website? In that case I will send you a personal e-mail and explain what I try to achieve.

And here we go! I ended up writing two versions:

  • the first extension is similar to the original one, but only acts on the initial window(s) of an app
  • the second one links an app to a particular workspace, that is all new app windows are opened on that workspace

Do you use your e-mail-address that is mentioned on the GNOME-website?

Yes.

1 Like

You are a magician :slight_smile: !
Thank you very much!

The second extension is one that a friend of mine would like a lot.

This week I will send you an e-mail in which I will explain what i tried to achieve.

Have a nice Sunday!

Thanks :blush:

Please note that those extensions are very much prototypes, I wouldn’t recommend using them in production (there’s at least one condition where the second extension will crash the session).

1 Like