Can a Gnome extension detect when it was re-enabled after screen lock?

Is there a way for a Gnome extension to tell if it has been re-enabled after the user unlocked the screen?

I am writing an extension that fetches incident reports from a server and displays them as a notification. However, when the extension is first launched after login, it starts a countdown to give the user time to stop the connection. I do not want this countdown to repeat after a screen-lock.

What works for me: In disable() function I test whether the extension is enabled in gsettings - if true, this call is probably triggered by the screen lock, if false, extension was disabled permanently. I’m sure this is not the best solution, but no Gnome developer said ‘it’s bad, don’t do that’ or offered something better, yet…

1 Like

That seems smart, I will do that check too. Thank you!

This isn’t necessarily bad, but note that extensions must still cleanup all the changes made in enable() when disable() is called, regardless of why disable() was called.

You also have to check whether the extension is disabled in gsettings. Extensions that appear in both enabled-extensions and disabled-extensions are disabled.

1 Like

Right, I forgot that one, thanks! And I guess disable-user-extensions too…

1 Like

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