Calling functions in extension at startup via ~/.config/autostart

Hi,

I’m using ~/.config/autostart as a way to call functions in the extension via DBus at startup.

The question is that is the extension system finished to initialize before the execution of .desktops in ~/.config/autostart? I did several tests, looks it’s so. If this is true, I’m very happy to remove the sleep 10 part from the Exec.

And if you know other ways to call functions in extension at startup, please let me know. I don’t like to install a .desktop to ~/.config/autostart, it works but I just don’t like it personally.

Probably what you should be doing is calling these functions in enable() and then reversing whatever they do in disable(). Is there a reason you are running these commands at “startup” rather than when your extension is enabled?

Yes, I’m working on this extension GitHub - nlpsuge/gnome-shell-extension-another-window-session-manager: A Gnome shell extension to close open windows gracefully and save them as a session. The previous session can be restored at startup. Most importantly, it supports both X11 and Wayland!. It can save all running apps in disk and restore them only at startup.

Maybe just keep a boolean and toggle it after the first time the extension is loaded?

let startup = true;

function enable() {
    if (startup) {
        doStartup();
        startup = false;
    }
}

After startup becomes false, will it be reset to true again? For example, the extension is disabled; or it’s disabled and then enabled; and On X11, the gnome shell can be restarted.

It will be reset to true if you change it, or GNOME Shell restarts. I guess if you need to account for X11 you could store some persistent state.

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