From b60633f95cea567fd66ded6cf201ae3410fa9797 Mon Sep 17 00:00:00 2001 From: John Beatty Date: Thu, 3 Dec 2026 07:00:00 -0500 Subject: [PATCH 1/2] Lock: no shell reload while locked, and none that locks A reload, which a changed shell file starts (an update of the package), destroyed the session lock without unlocking it. The compositor takes that for a protocol error and disconnects the shell: under Labwc the screen stayed locked with nothing on it to unlock, and only a restart of the shell from outside brought the PIN back. Quickshell's file watching is now off while locked; after the unlock the shell reloads once if one of its files changed (by ctime: installed package files keep their build-time mtime). A reload also took the session's start lock again, so an update while the tablet was in use locked it. The start lock is now taken once per shell process; a shell started anew (a crash, a restart) still takes it. Tried on an iPhone 7 Plus: a file changed while locked held its reload until the unlock; reloads while unlocked left it unlocked. --- desktop/shell/shell/plugins/lock/Service.qml | 60 +++++++++++++++++++- tests/test_lock_holds_reloads.py | 48 ++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 tests/test_lock_holds_reloads.py diff --git a/desktop/shell/shell/plugins/lock/Service.qml b/desktop/shell/shell/plugins/lock/Service.qml index 5828d9f9..3ad4e78c 100644 --- a/desktop/shell/shell/plugins/lock/Service.qml +++ b/desktop/shell/shell/plugins/lock/Service.qml @@ -84,6 +84,44 @@ Item { readonly property bool locked: lockRequested || sessionLock.locked || sessionLock.secure + // A reload (a shell file changed: an update of the package) destroys the + // session lock without unlocking it, which the compositor takes for a + // protocol error: it disconnects the shell and the session stays locked with + // nothing to unlock it (Labwc; Hyprland shows its crashed-lock fallback). + // So the shell does not watch its files while locked, and reloads once + // after the unlock if any of them changed meanwhile. + readonly property string runtimeDir: Quickshell.env("XDG_RUNTIME_DIR") || "/tmp" + readonly property string reloadStampPath: runtimeDir + "/omarchy-shell-reload-stamp" + property bool reloadsHeld: false + onLockedChanged: holdReloads(locked) + + function holdReloads(hold) { + if (hold === reloadsHeld) return + reloadsHeld = hold + Quickshell.watchFiles = !hold + if (hold) reloadStamp.running = true + else changedWhileLocked.running = true + } + + Process { + id: reloadStamp + command: ["sh", "-c", ": > \"$1\"", "sh", root.reloadStampPath] + } + + Process { + id: changedWhileLocked + // ctime: a package's files keep their build-time mtime when installed. + command: ["sh", "-c", "[ -e \"$2\" ] && find \"$1\" -cnewer \"$2\" -print -quit 2>/dev/null", "sh", Quickshell.shellDir, root.reloadStampPath] + stdout: StdioCollector { + waitForEnd: true + onStreamFinished: { + if (String(text || "").trim() === "" || root.currentlyLocked()) return + root.logEvent("reload: shell files changed while locked") + Quickshell.reload(false) + } + } + } + // Decisions read the lock state afresh. A property binding that missed a change // notification once reported locked after an unlock, and a lock request before // suspend then took that for done and never locked the session. @@ -939,10 +977,30 @@ Item { checkStrandedLock() } + // The start lock is the session's, taken once by each shell process: a + // reload (an update while the tablet is in use) builds this service anew + // and must not lock the screen again. A shell started anew (a crash, a + // restart) does take it. + FileView { + id: startLockMark + path: root.runtimeDir + "/omarchy-start-lock-pid" + printErrors: false + blockLoading: true + } + function takeStartLock() { if (!startLocked || startLockTaken || !passwordPamConfigured) return + var taken = "" + try { taken = String(startLockMark.text() || "").trim() } catch (e) { taken = "" } + if (taken === String(Quickshell.processId)) { + startLockTaken = true + return + } startLockTaken = beginLock() - if (startLockTaken) logEvent("start-locked") + if (startLockTaken) { + startLockMark.setText(Quickshell.processId + "\n") + logEvent("start-locked") + } } // The lock is on screen: lift Labwc's startup cover, and record for the diff --git a/tests/test_lock_holds_reloads.py b/tests/test_lock_holds_reloads.py new file mode 100644 index 00000000..3107577a --- /dev/null +++ b/tests/test_lock_holds_reloads.py @@ -0,0 +1,48 @@ +"""The shell does not reload while locked, and a reload does not lock (lock/Service.qml). + +A reload destroys the session lock without unlocking it, a protocol error the +compositor answers by disconnecting the shell: the tablet stayed locked with +nothing on screen to unlock it after a shell file changed while it was locked. +""" +from pathlib import Path +import re +import unittest + +SERVICE = Path(__file__).resolve().parents[1] / 'desktop/shell/shell/plugins/lock/Service.qml' + + +def function(text, name): + """The braced body of function NAME.""" + at = text.index(f'function {name}(') + depth, i = 0, text.index('{', at) + for j in range(i, len(text)): + depth += {'{': 1, '}': -1}.get(text[j], 0) + if depth == 0: + return text[i:j + 1] + raise AssertionError(name) + + +class LockHoldsReloads(unittest.TestCase): + def setUp(self): + self.text = SERVICE.read_text() + + def test_file_watching_follows_the_lock(self): + self.assertIn('onLockedChanged: holdReloads(locked)', self.text) + self.assertIn('Quickshell.watchFiles = !hold', function(self.text, 'holdReloads')) + + def test_a_change_while_locked_reloads_after_the_unlock(self): + self.assertRegex(self.text, r'find \\"\$1\\" -cnewer \\"\$2\\"') + check = self.text[self.text.index('id: changedWhileLocked'):] + check = check[:check.index('Quickshell.reload(false)')] + # Never while locked: that reload is what strands the lock. + self.assertIn('root.currentlyLocked()) return', check) + + def test_the_start_lock_is_taken_once_per_shell_process(self): + body = function(self.text, 'takeStartLock') + self.assertIn('String(Quickshell.processId)', body) + self.assertLess(body.index('String(Quickshell.processId)'), body.index('beginLock()')) + self.assertRegex(body, re.compile(r'startLockMark\.setText\(Quickshell\.processId')) + + +if __name__ == '__main__': + unittest.main() From c78d49bf14b5dd3da31a48ae65d060cd0ba7ddc5 Mon Sep 17 00:00:00 2001 From: John Beatty Date: Fri, 4 Dec 2026 15:06:54 -0500 Subject: [PATCH 2/2] CHANGELOG: updates no longer break the lock screen --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67f4ea04..984d49bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,11 @@ release is checked here and released on by hand. the on-screen keyboard stays above the control center until it is put away, instead of being covered by it where it couldn't be dismissed. +- Updates no longer break the lock screen. An update that arrives while the + tablet is locked waits until you unlock it; before, it could leave the + screen locked with no way to enter the PIN. An update while the tablet is in + use no longer locks it. + ## [0.4.8] - 2026-12-03 ### Desktop