phocean / TopIcons-plus

An gnome-shell extension to put the icons back to the tray.
674 stars 98 forks source link

[enhancement, patch] prevent disabling extension on screen lock #100

Open eugene-rom opened 6 years ago

eugene-rom commented 6 years ago

Idea taken from source code https://www.reddit.com/r/gnome/comments/2hj8bx/has_anyone_figured_out_a_way_to_keep_the_screen/cktqjqd/?st=j987r55w&sh=303792a6

Works well for me, can be disabled via gnome-tweak-tool but no recreation on screen lock.

patch:

diff --git a/extension.js b/extension.js
index 77be022..49ccdad 100644
--- a/extension.js
+++ b/extension.js
@@ -32,6 +32,7 @@ const ExtensionUtils = imports.misc.extensionUtils;
 const Me = ExtensionUtils.getCurrentExtension();
 const Convenience = Me.imports.convenience;

+let extensionActive = false;
 let settings = null;
 let tray = null;
 let trayIconImplementations = null;
@@ -46,6 +47,9 @@ let blacklist = [["skype","SkypeNotification@chrisss404.gmail.com"]]; // blackli
 function init() { Convenience.initTranslations(); }

 function enable() {
+    if (!extensionActive) {
+        extensionActive = true;
+
         tray = Main.legacyTray;

         if (tray)
@@ -64,9 +68,13 @@ function enable() {
         settings.connect('changed::tray-order', Lang.bind(this, placeTray));

         connectPanelChildSignals();
+    }
 }

 function disable() {
+    // Do not allow disabling the extension when in 'unlock-dialog' (lock-screen) mode.
+    if (extensionActive && Main.sessionMode.currentMode != 'unlock-dialog') {
+        extensionActive = false;

         if (Main.legacyTray)
             moveToTray();
@@ -75,6 +83,7 @@ function disable() {
         settings.run_dispose();

         disconnectPanelChildSignals();
+    }
 }

 function onTrayIconAdded(o, icon, role, delay=1000) {
jhasse commented 6 years ago

Will this pass review on e.g.o?

eugene-rom commented 6 years ago

@jhasse, ahh, you right, it may not pass. :(

Never think about this, as I very novice gnome-shell user (since ubuntu 17.10 release) and just started to settle a new desktop environment.

ghost commented 6 years ago

Yes, but patch the shell itself is also violate his check and it's more critical create a way to violate the shell itself than just one extension. This is in my opinion less critical that the @jhasse patch with it's the same but for all than want to avoid the gdm rules.

Really the problem is not here. This are just workarouds.

ghost commented 6 years ago

You can find here https://bugzilla.gnome.org/show_bug.cgi?id=787079 more information about his path: https://bugzilla.gnome.org/show_bug.cgi?id=781760

ghost commented 6 years ago

And some thing similar it's what i proposed here: https://github.com/ubuntu/gnome-shell-extension-appindicator/issues/75#issuecomment-331390300