Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
60 changes: 59 additions & 1 deletion desktop/shell/shell/plugins/lock/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions tests/test_lock_holds_reloads.py
Original file line number Diff line number Diff line change
@@ -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()