From 08b06acc4cf9a9bacd31ea230772e84ad5808581 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 15 Jan 2025 16:18:21 +0000 Subject: [PATCH] =?UTF-8?q?timeLimitsManager:=20Only=20stop=20the=20state?= =?UTF-8?q?=20machine=20if=20it=E2=80=99s=20already=20running?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a bug which happens if screen time limits are *disabled* and the history file (`~/.local/share/gnome-shell/session-active-history.json`) is missing when gnome-shell is started. If so, the code would previously have incorrectly called `this._stopStateMachine()` on startup, even though the state machine wasn’t running. This adds a fake transition from ACTIVE to INACTIVE to the history file. If the user later (that day) enables time limits, the code assumes that they were active from the start of the day through to that fake transition, which is possibly sufficient time to reach the user’s limit already. This results in the screen immediately being made greyscale as the limit has apparently been reached. Signed-off-by: Philip Withnall Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8155 Part-of: --- js/misc/timeLimitsManager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/misc/timeLimitsManager.js b/js/misc/timeLimitsManager.js index c72dc0b88..f605fb11b 100644 --- a/js/misc/timeLimitsManager.js +++ b/js/misc/timeLimitsManager.js @@ -169,8 +169,10 @@ export const TimeLimitsManager = GObject.registerClass({ _updateSettings() { if (!this._screenTimeLimitSettings.get_boolean('enabled')) { - this._stopStateMachine().catch( - e => console.warn(`Failed to stop state machine: ${e.message}`)); + if (this._state !== TimeLimitsState.DISABLED) { + this._stopStateMachine().catch( + e => console.warn(`Failed to stop state machine: ${e.message}`)); + } return false; }