Hide Top Bar in Workspaces

It would be nice to setup Gnome so applications opened in any additional workspace (any other than the main/first one) wouldn’t have a bar on top. So they behave pretty much like when you plug a secondary monitor in most OS.

Is there a way to do this? To disable the top bar in all workspaces instead of the first one.

I doubt that it’s behavior we’ll want out of the box, but an extension can implement it along those lines:

function _updateTopBar() {
    Main.panel.visible =
        global.workspace_manager.get_active_workspace_index() === 0;
}

global.workspace_manager.connect('active-workspace-changed', _updateTopBar);
_updateTopBar();

Thanks a lot for writing a script in reply @fmuellner !

I never designed an extension, but I suppose it is not trivial. Is there a simple way to introduce the modification only in my system? Adding the script somehow or editing any Gnome file?

i pressed alt+f2, typed lg, and pasted the code above there, and it worked!
now i only need to log out to get my top bar back on workspaces…

Modifying gnome-shell’s javascript code requires jumping through some hoops or rebuilding the package.

That is, an extension is probably the easiest option. (You can use gnome-extensions create --interactive to generate the boilerplate, so you only have to fill in the enable() and disable() methods)

@two you are right! using your method actually works :slight_smile:

I tried creating an extension with gnome-extensions create --interactive. The extension is created, then I paste @fmuellner script at the end of the extension.js file. It appears on the extensions’ GUI list, but after enabling it it shows the error “Main is not defined”.

Screenshot from 2022-11-14 11-10-53

You have to import Main. Also you shouldn’t just append a random script at the end, an extension should do its modifications on “enable” and undo them on “disable”.

The following should be a complete example (bar errors, as I didn’t test that it actually works):

const Main = imports.ui.main;

class Extension {
    _updateTopBar() {
        Main.panel.visible =
            global.workspace_manager.get_active_workspace_index () === 0;
    }
   
    enable() {
        global.workspace_manager.connectObject(
            'active-workspace-changed', () => this._updateTopBar(),
            this);
        this._updateTopBar();
    }

    disable() {
        global.workspace_manager.disconnectObject(this);
        Main.panel.show();
    }
}

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

you also need this: const Main = imports.ui.main;

It works wonderfully @fmuellner.

Many thanks for your time and this code belongs to you, so feel free to publish it as an extension on your name if it is on your interest.
Screenshot from 2022-11-14 21-03-32

Many thanks also @two, for pumping up this topic.

–There is a known extension around called Hide Top Bar, but it currently flickers with non-native fullscreen applications. This extension here serves me as a workaround to it. Combined with narrow titlebars it creates very neat workspaces to concentrate in one app, or a combination of windows you want to focus on (video editing, proofreading, etc.)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.