Skip to content

Commit

Permalink
Merge pull request #773 from ZimbiX/continue-running-when-screen-is-l…
Browse files Browse the repository at this point in the history
…ocked-and-optionally-show-on-lockscreen

Continue running when screen is locked and optionally show on lockscreen, using session modes
  • Loading branch information
chrisspen authored Jan 22, 2023
2 parents 8f74f07 + f251e72 commit 21d7b4e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -2402,6 +2402,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();
Expand Down Expand Up @@ -2568,6 +2576,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');
}
Expand Down
1 change: 1 addition & 0 deletions [email protected]/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions [email protected]/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@
<summary>Optimize view for small displays</summary>
<description>Optimize texts sizes to fit on a small display </description>
</key>
<key name="show-on-lockscreen" type="b">
<default>false</default>
<summary>Show on lockscreen</summary>
<description>Allow the extension to run while the screen is locked. Also avoids resetting graph history</description>
</key>
<key name="memory-program-color" type="s">
<default>'#00b35b'</default>
<summary>Color of program memory in the chart</summary>
Expand Down

0 comments on commit 21d7b4e

Please sign in to comment.