From 0e304100ab8c1381ee15e296b8e08576aa026201 Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Wed, 26 Mar 2025 11:28:30 +0100 Subject: [PATCH] loginManager: Use signal argument to detect preparing for sleep The DBus PreparingForSleep property on org.freedesktop.login1.Manager does not trigger PropertyChanged signals, leading to wrong values due to gdbus caching. In most cases it would have always been false. Additionally it was not included in the XML interface description file included in gnome-shell. So it was actually undefined. Since this property is used in _calculateUserStateFromLogind() to determine that a user is not active when closing the lid on a laptop, the user was considered still active. Fix this by storing the "start" argument from the PrepareForSleep signal instead of trying to read from the property. Fixes: 6a43b6f55 ("timeLimitsManager: Store screen time state on suspend/resume") Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8185 Part-of: --- js/misc/loginManager.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/misc/loginManager.js b/js/misc/loginManager.js index 191b5334f..9dd9fa251 100644 --- a/js/misc/loginManager.js +++ b/js/misc/loginManager.js @@ -93,6 +93,8 @@ class LoginManagerSystemd extends Signals.EventEmitter { constructor() { super(); + this._preparingForSleep = false; + this._proxy = new SystemdLoginManager(Gio.DBus.system, 'org.freedesktop.login1', '/org/freedesktop/login1'); @@ -224,6 +226,7 @@ class LoginManagerSystemd extends Signals.EventEmitter { } _prepareForSleep(proxy, sender, [aboutToSuspend]) { + this._preparingForSleep = aboutToSuspend; this.emit('prepare-for-sleep', aboutToSuspend); } @@ -235,7 +238,7 @@ class LoginManagerSystemd extends Signals.EventEmitter { * @type {boolean} */ get preparingForSleep() { - return this._proxy.PreparingForSleep; + return this._preparingForSleep; } _sessionRemoved(proxy, sender, [sessionId]) {