From 0069a85f31b62ddd515132a47d6569cdefcaae27 Mon Sep 17 00:00:00 2001 From: Brendan Weibrecht Date: Wed, 18 Jan 2023 10:30:17 +1100 Subject: [PATCH 1/2] Specify sessions modes to allow the extention to keep running on the lockscreen in an officially-supported manner See https://gjs.guide/extensions/topics/session-modes.html --- system-monitor@paradoxxx.zero.gmail.com/metadata.json | 1 + 1 file changed, 1 insertion(+) diff --git a/system-monitor@paradoxxx.zero.gmail.com/metadata.json b/system-monitor@paradoxxx.zero.gmail.com/metadata.json index 1851c46d..b59143ae 100644 --- a/system-monitor@paradoxxx.zero.gmail.com/metadata.json +++ b/system-monitor@paradoxxx.zero.gmail.com/metadata.json @@ -6,5 +6,6 @@ "description": "Display system information in GNOME Shell status bar, such as memory, CPU, disk and battery usages, network rates…", "settings-schema": "org.gnome.shell.extensions.system-monitor", "gettext-domain": "system-monitor", + "session-modes": ["user", "unlock-dialog"], "version": -1 } From f251e720a52fe0a30b19fabfc81e4add3cd49279 Mon Sep 17 00:00:00 2001 From: Brendan Weibrecht Date: Thu, 19 Jan 2023 01:05:12 +1100 Subject: [PATCH 2/2] Optionally hide on lockscreen while continuing to produce graphs in background Hidden by default. This makes use of the session modes feature introduced in GNOME Shell 42. https://gjs.guide/extensions/topics/session-modes.html Strangely, disconnecting the session mode updated callback, like in the example, resulted in the applet still being shown the first time the screen is locked. It seems to work fine with it left out, so I've just done that. --- system-monitor@paradoxxx.zero.gmail.com/extension.js | 12 ++++++++++++ system-monitor@paradoxxx.zero.gmail.com/prefs.js | 5 +++++ ...gnome.shell.extensions.system-monitor.gschema.xml | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/system-monitor@paradoxxx.zero.gmail.com/extension.js b/system-monitor@paradoxxx.zero.gmail.com/extension.js index 1c56f0d3..cf5e7383 100644 --- a/system-monitor@paradoxxx.zero.gmail.com/extension.js +++ b/system-monitor@paradoxxx.zero.gmail.com/extension.js @@ -2396,6 +2396,14 @@ function init() { IconSize = Math.round(Panel.PANEL_ICON_SIZE * 4 / 5); } +function _onSessionModeChanged(session) { + if (session.currentMode === 'user' || session.parentMode === 'user') { + Main.__sm.tray.show() + } else if (session.currentMode === 'unlock-dialog' && !Schema.get_boolean('show-on-lockscreen')) { + Main.__sm.tray.hide() + } +} + function enable() { log('[System monitor] applet enabling'); Schema = Convenience.getSettings(); @@ -2547,6 +2555,10 @@ function enable() { }); tray.menu.addMenuItem(item); Main.panel.menuManager.addMenu(tray.menu); + + if (shell_Version >= '42') { + Main.sessionMode.connect('updated', _onSessionModeChanged); + } } log('[System monitor] applet enabling done'); } diff --git a/system-monitor@paradoxxx.zero.gmail.com/prefs.js b/system-monitor@paradoxxx.zero.gmail.com/prefs.js index 388f512a..db8d3351 100644 --- a/system-monitor@paradoxxx.zero.gmail.com/prefs.js +++ b/system-monitor@paradoxxx.zero.gmail.com/prefs.js @@ -512,6 +512,11 @@ const App = class SystemMonitor_App { this.items.push(item) this.hbox1.add(item) Schema.bind(key, item, 'active', Gio.SettingsBindFlags.DEFAULT); + } else if (key === 'show-on-lockscreen') { + let item = new Gtk.CheckButton({label: _('Show on lockscreen')}) + this.items.push(item) + this.hbox1.add(item) + Schema.bind(key, item, 'active', Gio.SettingsBindFlags.DEFAULT); } else if (key === 'background') { let item = new ColorSelect(_('Background Color')) item.set_value(Schema.get_string(key)) diff --git a/system-monitor@paradoxxx.zero.gmail.com/schemas/org.gnome.shell.extensions.system-monitor.gschema.xml b/system-monitor@paradoxxx.zero.gmail.com/schemas/org.gnome.shell.extensions.system-monitor.gschema.xml index 62472636..dde78acf 100644 --- a/system-monitor@paradoxxx.zero.gmail.com/schemas/org.gnome.shell.extensions.system-monitor.gschema.xml +++ b/system-monitor@paradoxxx.zero.gmail.com/schemas/org.gnome.shell.extensions.system-monitor.gschema.xml @@ -328,6 +328,11 @@ Optimize view for small displays Optimize texts sizes to fit on a small display + + false + Show on lockscreen + Allow the extension to run while the screen is locked. Also avoids resetting graph history + '#00b35b' Color of program memory in the chart