From dac6658bae4f4ca35c63fb7b1bc2977164097ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9za=20B=C3=BAza?= Date: Sun, 4 Nov 2018 21:54:13 +0100 Subject: [PATCH] Send session lock/unlock events to systemd-logind To keep compatibility with systemd-logind, call the LockSession and UnlockSession methods of logind via D-Bus when Gnome sceensaver locks or unlocks the screen. See reference: https://www.freedesktop.org/wiki/Software/systemd/logind/ --- js/ui/shellDBus.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js index a200a1bdd3..5362658e62 100644 --- a/js/ui/shellDBus.js +++ b/js/ui/shellDBus.js @@ -13,6 +13,7 @@ const ExtensionUtils = imports.misc.extensionUtils; const Main = imports.ui.main; const Screenshot = imports.ui.screenshot; const ViewSelector = imports.ui.viewSelector; +const LoginManager = imports.misc.loginManager; const { loadInterfaceXML } = imports.misc.fileUtils; @@ -354,6 +355,27 @@ var ScreenSaverDBus = new Lang.Class({ screenShield.connect('wake-up-screen', shield => { this._dbusImpl.emit_signal('WakeUpScreen', null); }); + screenShield.connect('locked-changed', shield => { + let sessionId = GLib.getenv('XDG_SESSION_ID'); + let params = GLib.Variant.new('(i)', [sessionId]); + let busName = 'org.freedesktop.login1.Manager'; + this._dbusImpl.call( + busName, + '/org/freedesktop/login1', + 'org.freedesktop.login1.Manager', + shield.active ? 'LockSession' : 'UnlockSession', + params, + null, Gio.DBusCallFlags.NONE, -1, null, + (conn, result) => { + try { + conn.call_finish(result); + } catch (e) { + let action = shield.active ? 'lock' : 'unlock'; + log(`Cannot ${action} the session "${sessionId}" via "${busName}".`); + } + } + ); + }); this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this); this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver'); -- GitLab