From b240aa5640b5e787930f811948dd27b2e8bc9ec4 Mon Sep 17 00:00:00 2001 From: Xpond Date: Sat, 5 Dec 2026 10:07:03 +0530 Subject: [PATCH 1/2] Rebase the bar and lock patches onto Omarchy 4.6 4.6 added the bar mist where our panel scrim was appended, and changed both lock files, so install.sh left all three stock. - Bar.qml: the scrim block moves above BarMoveGhostPanel, which merges cleanly on 4.5 and 4.6. - Lock: patches/orig is 4.6's. Our async wake keeps 4.6's sleep-aware countdown, its delay held until the display is back; 4.6's idle blank waits out a wake and the design's exit; its wrong-password shake carries the field's glass and glow. - Lid open: omarchy-shell lock wake reaches the bridge, which asks the worker to wake, so a blanked lock lights on a laptop. - The wallpaper design asks for the URL 4.6 preloads (?lockv=). --- docs/install.md | 6 +- lock-session/Bridge.qml | 6 + lock-session/shell.qml | 1 + lock/wallpaper/Scene.qml | 2 +- patches/orig/plugins/lock/LockView.qml | 34 ++++- patches/orig/plugins/lock/Service.qml | 163 +++++++++++++++++++---- patches/shell/plugins/bar/Bar.qml | 26 ++-- patches/shell/plugins/lock/LockView.qml | 32 +++++ patches/shell/plugins/lock/Service.qml | 167 ++++++++++++++++++++---- tests/lock-idle.js | 4 +- tests/lock-process.py | 7 +- tests/lock-render.py | 1 + 12 files changed, 372 insertions(+), 77 deletions(-) diff --git a/docs/install.md b/docs/install.md index 67cd15a3..13474745 100644 --- a/docs/install.md +++ b/docs/install.md @@ -4,10 +4,10 @@ What `install.sh` and `revert.sh` change, how updates are handled, and why `sudo ## Tested setup -Made for Omarchy stable (4.5); `scripts/test-channels.sh` also runs the tests against rc and edge's +Made for Omarchy stable (4.6); `scripts/test-channels.sh` also runs the tests against rc and edge's current packages. Used only with Quickshell 0.3.2.r7, on one NVIDIA GPU and one monitor, without -fingerprint unlock; a second screen only as a virtual display, at a different scale. Edge changed -Omarchy's lock in r8178, so there wheely keeps Omarchy's own lock. The installer refuses an Omarchy +fingerprint unlock; a second screen only as a virtual display, at a different scale. On 4.5 and on +edge, whose lock differs from 4.6's, wheely keeps Omarchy's own lock. The installer refuses an Omarchy older than 4.5.0rc3 and does not check Quickshell. It takes over `SUPER+A` and `SUPER+W`, and `Ctrl+Space` while one of its animated themes is diff --git a/lock-session/Bridge.qml b/lock-session/Bridge.qml index 7b3d5ad6..c6deabcd 100644 --- a/lock-session/Bridge.qml +++ b/lock-session/Bridge.qml @@ -121,6 +121,12 @@ Item { return "ok" } function isLocked(): string { return root.locked ? "true" : "false" } + // Opening a laptop lid asks for this; unlocked, omarchy-system-lid-open wakes the display itself. + function wake(): string { + if (!root.locked) return "unlocked" + root.request("wake") + return "ok" + } function status(): string { const result = Object.assign({}, root.lockState) result.locked = root.locked diff --git a/lock-session/shell.qml b/lock-session/shell.qml index ad9d7830..82098ea4 100644 --- a/lock-session/shell.qml +++ b/lock-session/shell.qml @@ -39,6 +39,7 @@ ShellRoot { service.previewVisible = true } } else if (pending.action === "hidePreview") service.previewVisible = false + else if (pending.action === "wake" && service.locked) service.runWake() serial = pending.serial pending = null } diff --git a/lock/wallpaper/Scene.qml b/lock/wallpaper/Scene.qml index f4d93976..9ff07a25 100644 --- a/lock/wallpaper/Scene.qml +++ b/lock/wallpaper/Scene.qml @@ -25,7 +25,7 @@ Item { // Built as Service.qml builds lockWallpaperUrl, so the service's decode serves this one: ahead // of the lock in-process, alongside it in each lock's fresh worker. Never re-read while locked. source: root.host.loadBackground && path - ? Util.fileUrl(path) + (root.host.backgroundVersion ? "?v=" + root.host.backgroundVersion : "") + ? Util.fileUrl(path) + "?" + root.host.backgroundVersionPrefix + "=" + root.host.backgroundVersion : "" fillMode: Image.PreserveAspectCrop asynchronous: true diff --git a/patches/orig/plugins/lock/LockView.qml b/patches/orig/plugins/lock/LockView.qml index 9f4aa693..397d620e 100644 --- a/patches/orig/plugins/lock/LockView.qml +++ b/patches/orig/plugins/lock/LockView.qml @@ -10,6 +10,8 @@ Item { property string backgroundPath: "" property string videoPosterPath: "" property int backgroundVersion: 0 + property string backgroundVersionPrefix: "v" + property size wallpaperDecodeSize: Qt.size(0, 0) property bool fingerprintConfigured: false property bool fingerprintUnavailable: false property bool authenticatingPassword: false @@ -19,6 +21,7 @@ Item { property bool loadBackground: true property string passwordText: "" property bool syncingPasswordText: false + property bool viewReady: false readonly property string placeholderText: Commons.I18n.t("lock.enterPassword") readonly property int fieldWidth: 381 @@ -79,6 +82,16 @@ Item { } onPasswordTextChanged: syncPasswordText() + // Shake on a wrong password, not on initial construction or reset to 0. + onFailedAttemptsChanged: { + if (!viewReady) return + if (failedAttempts > 0 && !Style.reduceMotion) { + shakeAnimation.restart() + } else { + shakeAnimation.stop() + shakeTransform.x = 0 + } + } onInputEnabledChanged: { if (inputEnabled) Qt.callLater(forcePasswordFocus) } @@ -88,6 +101,7 @@ Item { // when the keyboard returns, so typing went nowhere until the field was clicked. Window.onActiveFocusItemChanged: Qt.callLater(restorePasswordFocus) Component.onCompleted: { + viewReady = true syncPasswordText() if (inputEnabled) Qt.callLater(forcePasswordFocus) } @@ -112,13 +126,16 @@ Item { anchors.fill: parent path: root.loadBackground ? (root.video ? root.videoPosterPath : root.backgroundPath) : "" version: root.backgroundVersion + versionPrefix: root.backgroundVersionPrefix // Decode only once sized, at the lock's own size: an unsized first // request decoded the file at its native resolution, then again once // sized. That size is what the lock service keeps decoded ahead of the // lock, so the first frame has the wallpaper. cached: true constrainDecode: true - decodeSize: Qt.size(width, height) + decodeSize: root.wallpaperDecodeSize.width > 0 && root.wallpaperDecodeSize.height > 0 + ? root.wallpaperDecodeSize + : Qt.size(width, height) } MultiEffect { @@ -149,6 +166,21 @@ Item { radius: Style.cornerRadius clip: true + transform: Translate { + id: shakeTransform + + // A head shaking no: four swings that die down, 250ms in all. + SequentialAnimation on x { + id: shakeAnimation + running: false + NumberAnimation { to: -14; duration: Style.duration(45); easing.type: Easing.OutQuad } + NumberAnimation { to: 12; duration: Style.duration(65); easing.type: Easing.InOutSine } + NumberAnimation { to: -8; duration: Style.duration(55); easing.type: Easing.InOutSine } + NumberAnimation { to: 4; duration: Style.duration(45); easing.type: Easing.InOutSine } + NumberAnimation { to: 0; duration: Style.duration(40); easing.type: Easing.OutQuad } + } + } + TextInput { id: passwordInput anchors.fill: parent diff --git a/patches/orig/plugins/lock/Service.qml b/patches/orig/plugins/lock/Service.qml index a02708e0..cd349712 100644 --- a/patches/orig/plugins/lock/Service.qml +++ b/patches/orig/plugins/lock/Service.qml @@ -11,6 +11,7 @@ Item { id: root property var shell: null + property var publishSessionLocked: null property string omarchyPath: "" readonly property string home: Quickshell.env("HOME") @@ -63,6 +64,13 @@ Item { property bool strandedLockResolved: false readonly property bool locked: lockRequested || sessionLock.locked || sessionLock.secure + readonly property bool sessionLocked: locked || strandedLock + function syncSessionLocked() { + if (typeof publishSessionLocked === "function") publishSessionLocked(currentlyLocked() || strandedLock) + } + onSessionLockedChanged: syncSessionLocked() + onLockRequestedChanged: syncSessionLocked() + onPublishSessionLockedChanged: syncSessionLocked() // 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 @@ -244,19 +252,33 @@ Item { resetAuthenticationState() idleBlankTimer.stop() sessionLock.locked = false + syncSessionLocked() logEvent("unlocked") runWake() } function armBlankTimer(delayMs) { - idleBlankTimer.interval = delayMs || idleBlankTimer.idleMs - idleBlankTimer.armedAt = Date.now() + var now = Date.now() + var targetMs = delayMs || idleBlankTimer.idleMs + if (idleBlankTimer.running && idleBlankTimer.armedAt > 0) { + var elapsedMs = now - idleBlankTimer.armedAt + if (elapsedMs > idleBlankTimer.interval + 2000) targetMs = Math.max(targetMs, idleBlankTimer.resumeMs) + else if (elapsedMs >= 0 && idleBlankTimer.interval - elapsedMs > targetMs) return + } + idleBlankTimer.interval = targetMs + idleBlankTimer.armedAt = now idleBlankTimer.restart() } - function runWake() { + function runWake(delayMs) { + if (lockRequested && fingerprintPaused && fingerprintResumeTimer.running + && FingerprintModel.spannedSleep(Date.now() - fingerprintResumeTimer.lastTickMs, fingerprintResumeTimer.interval)) { + fingerprintResumeTimer.stop() + fingerprintSleptWhilePaused = true + delayMs = Math.max(delayMs || 0, idleBlankTimer.resumeMs) + } if (!wakeProcess.running) wakeProcess.running = true - if (lockRequested) armBlankTimer() + if (lockRequested) armBlankTimer(delayMs) resumeFingerprint() nudgeFingerprint() } @@ -286,9 +308,9 @@ Item { if (lockRequested && fingerprintConfigured && !fingerprintAuthenticating) fingerprintRetryTimer.restart() } - // A resume can light the panel with no input to wake the lock, so after a - // lock request the reader comes back once a sleep is seen; the blank - // countdown then pauses it again if nothing else happens. The idle service + // A resume brings no input to wake the lock, so after a lock request the + // panel and the reader come back once a sleep is seen; the blank countdown + // then takes both away again if nothing else happens. The idle service // repeats the same request without sleeping, so the sleep has to be seen. function noteSleepRequested() { if (!lockRequested || !fingerprintPaused) return @@ -375,12 +397,16 @@ Item { passwordPam.respond(pendingPassword) } + // onError and onCompleted can both fire; settle each password attempt once + // and always clear pendingPassword even if the lock was already dismissed. function handlePasswordFailure() { - if (!lockRequested) return + if (!authenticatingPassword) return authenticatingPassword = false - enteredPassword = "" pendingPassword = "" + if (!lockRequested) return + + enteredPassword = "" failedAttempts += 1 failureMessage = I18n.t("lock.authenticationFailed").arg(I18n.formatNumber(failedAttempts)) runWake() @@ -508,9 +534,12 @@ Item { LockView { id: lockView anchors.fill: parent + readonly property var wallpaperRequest: root.lockWallpaperRequest(lockSurface.screen, width, height) backgroundPath: root.backgroundPath videoPosterPath: root.videoPosterPath - backgroundVersion: root.backgroundVersion + backgroundVersion: wallpaperRequest.version + backgroundVersionPrefix: wallpaperRequest.versionPrefix + wallpaperDecodeSize: Qt.size(wallpaperRequest.width, wallpaperRequest.height) fingerprintConfigured: root.fingerprintConfigured || root.fingerprintUnavailable fingerprintUnavailable: root.fingerprintUnavailable authenticatingPassword: root.authenticatingPassword @@ -544,9 +573,12 @@ Item { LockView { anchors.fill: parent + readonly property var wallpaperRequest: root.lockWallpaperRequest(previewWindow.screen, width, height) backgroundPath: root.backgroundPath videoPosterPath: root.videoPosterPath - backgroundVersion: root.backgroundVersion + backgroundVersion: wallpaperRequest.version + backgroundVersionPrefix: wallpaperRequest.versionPrefix + wallpaperDecodeSize: Qt.size(wallpaperRequest.width, wallpaperRequest.height) fingerprintConfigured: root.fingerprintConfigured || root.fingerprintUnavailable fingerprintUnavailable: root.fingerprintUnavailable authenticatingPassword: false @@ -573,12 +605,19 @@ Item { onPamMessage: root.respondToPasswordPrompt() onCompleted: function(result) { - root.authenticatingPassword = false - root.pendingPassword = "" - - if (!root.lockRequested) return - if (result === PamResult.Success) root.finishUnlock() - else root.handlePasswordFailure() + if (!root.authenticatingPassword) return + if (!root.lockRequested) { + root.authenticatingPassword = false + root.pendingPassword = "" + return + } + if (result === PamResult.Success) { + root.authenticatingPassword = false + root.pendingPassword = "" + root.finishUnlock() + } else { + root.handlePasswordFailure() + } } onError: function(error) { @@ -604,24 +643,71 @@ Item { } } - // The lock only starts decoding its wallpaper once locked, and a machine - // suspending right after locking froze that decode partway: waking showed - // the password field on a bare background, then the wallpaper popped in. - // Keep each screen's lock wallpaper decoded in the image cache ahead of - // time, as the lock view requests it (same URL, the screen's logical size, - // PreserveAspectCrop), so the lock draws it on its first frame. + // The desktop background service already decodes and caches still wallpapers + // per output at physical screen size. Sharing that cache entry per output + // avoids decoding the wallpaper twice at startup and on theme changes, and + // avoids holding a second copy in RAM. Video posters, in-place overwrites, + // outputs without a desktop panel, and sessions without the background + // service keep the hidden preload so suspend-after-lock still draws frame 1. + readonly property var backgroundService: { + var _ = root.shell ? root.shell.services : null + return root.shell ? root.shell.serviceFor("omarchy.background") : null + } readonly property string lockWallpaperPath: videoBackground ? videoPosterPath : backgroundPath readonly property string lockWallpaperUrl: lockWallpaperPath && !Util.isVideoPath(lockWallpaperPath) - ? Util.fileUrl(lockWallpaperPath) + (backgroundVersion ? "?v=" + backgroundVersion : "") + ? Util.fileUrl(lockWallpaperPath) + "?lockv=" + backgroundVersion : "" + Connections { + target: root.backgroundService + function onDisplayedBackgroundChanged() { + root.refreshBackground() + } + } + + function desktopStillEntry(screen) { + if (!screen || videoBackground || !backgroundPath) return null + if (!backgroundService || typeof backgroundService.stillCacheEntry !== "function") return null + return backgroundService.stillCacheEntry(screen, backgroundPath, backgroundSignature) + } + + function desktopStillPending(screen) { + if (!screen || lockRequested || videoBackground || !backgroundPath) return false + if (!backgroundService || typeof backgroundService.stillPending !== "function") return false + if (readlinkProc.running) return true + return backgroundService.stillPending(screen, backgroundPath, backgroundSignature) + } + + function lockWallpaperRequest(screen, fallbackWidth, fallbackHeight) { + var entry = desktopStillEntry(screen) + if (entry) { + return { + version: entry.version, + versionPrefix: "v", + width: entry.width, + height: entry.height, + shared: true + } + } + return { + version: backgroundVersion, + versionPrefix: "lockv", + width: fallbackWidth, + height: fallbackHeight, + shared: false + } + } + Variants { model: Quickshell.screens Image { required property var modelData + // Skip the hidden preload on outputs where the desktop background panel + // already owns this still (or is probing its native dimensions at startup). + readonly property bool desktopOwnsOutput: root.desktopStillEntry(modelData) !== null || root.desktopStillPending(modelData) visible: false - source: root.lockWallpaperUrl + source: desktopOwnsOutput ? "" : root.lockWallpaperUrl sourceSize.width: modelData.width sourceSize.height: modelData.height fillMode: Image.PreserveAspectCrop @@ -669,8 +755,9 @@ Item { if (slept && root.lockRequested && root.fingerprintPaused) { stop() root.fingerprintSleptWhilePaused = true - root.resumeFingerprint() - root.armBlankTimer(idleBlankTimer.resumeMs) + // A panel blanked before the sleep stays dark through the resume, and + // opening the lid is no input that would light it. + root.runWake(idleBlankTimer.resumeMs) } else if (slept || !root.fingerprintPaused || --ticksLeft <= 0) { stop() } @@ -686,7 +773,7 @@ Item { Process { id: readlinkProc - command: ["bash", "-c", "path=$(readlink -f -- \"$1\") && printf '%s\\n%s\\n' \"$path\" \"$(stat -Lc %Y:%s -- \"$path\" 2>/dev/null)\"", "_", root.currentBackgroundLink] + command: ["bash", "-c", "path=$(readlink -f -- \"$1\") && printf '%s\\n%s\\n' \"$path\" \"$(stat -Lc '%y:%s:%i' -- \"$path\" 2>/dev/null)\"", "_", root.currentBackgroundLink] stdout: StdioCollector { waitForEnd: true onStreamFinished: { @@ -789,6 +876,20 @@ Item { } } + // Hyprland lights the panel for any key, but a bound key like volume never + // reaches the lock surface, so nothing re-arms the blank and the lock stays + // lit. Blank once input has been quiet for the run-up and no countdown is + // pending, so the resume run-up is left alone. + IdleMonitor { + id: lockIdleMonitor + enabled: root.lockRequested + timeout: idleBlankTimer.idleMs / 1000 + respectInhibitors: false + onIsIdleChanged: { + if (isIdle && root.lockRequested && !root.authenticatingPassword && !idleBlankTimer.running) root.runBlank() + } + } + Timer { id: sessionLockStabilizeTimer interval: 500 @@ -887,6 +988,12 @@ Item { return root.currentlyLocked() ? "true" : "false" } + function wake(): string { + if (!root.currentlyLocked()) return "unlocked" + root.runWake() + return "ok" + } + function status(): string { return JSON.stringify({ locked: root.currentlyLocked(), diff --git a/patches/shell/plugins/bar/Bar.qml b/patches/shell/plugins/bar/Bar.qml index 1bb7cf1e..79d862e1 100644 --- a/patches/shell/plugins/bar/Bar.qml +++ b/patches/shell/plugins/bar/Bar.qml @@ -1707,19 +1707,6 @@ Item { } } - Variants { - model: Quickshell.screens - - delegate: Component { - BarMoveGhostPanel { - required property var modelData - - screen: modelData - ghostScreen: modelData - } - } - } - Variants { model: Quickshell.screens @@ -1779,6 +1766,19 @@ Item { } } + Variants { + model: Quickshell.screens + + delegate: Component { + BarMoveGhostPanel { + required property var modelData + + screen: modelData + ghostScreen: modelData + } + } + } + component BarPanel: PanelWindow { id: barWindow diff --git a/patches/shell/plugins/lock/LockView.qml b/patches/shell/plugins/lock/LockView.qml index da014c53..951beed9 100644 --- a/patches/shell/plugins/lock/LockView.qml +++ b/patches/shell/plugins/lock/LockView.qml @@ -11,6 +11,8 @@ Item { property string backgroundPath: "" property string videoPosterPath: "" property int backgroundVersion: 0 + property string backgroundVersionPrefix: "v" + property size wallpaperDecodeSize: Qt.size(0, 0) property bool fingerprintConfigured: false property bool fingerprintUnavailable: false property bool authenticatingPassword: false @@ -27,6 +29,7 @@ Item { property string designs: Quickshell.env("HOME") + "/.local/share/wheely/lock/" // A name, never a path: the file is anyone's who can write it, and a scene is code beside the password. property string design: /^[a-z0-9-]+$/.test(chosen.text().trim()) ? chosen.text().trim() : "wallpaper" + property bool viewReady: false readonly property string placeholderText: Commons.I18n.t("lock.enterPassword") readonly property int fieldWidth: 380 @@ -100,6 +103,16 @@ Item { } onPasswordTextChanged: syncPasswordText() + // Shake on a wrong password, not on initial construction or reset to 0. + onFailedAttemptsChanged: { + if (!viewReady) return + if (failedAttempts > 0 && !Style.reduceMotion) { + shakeAnimation.restart() + } else { + shakeAnimation.stop() + shakeTransform.x = 0 + } + } onInputEnabledChanged: { if (inputEnabled) Qt.callLater(forcePasswordFocus) } @@ -109,6 +122,7 @@ Item { // when the keyboard returns, so typing went nowhere until the field was clicked. Window.onActiveFocusItemChanged: Qt.callLater(restorePasswordFocus) Component.onCompleted: { + viewReady = true syncPasswordText() if (inputEnabled) Qt.callLater(forcePasswordFocus) showDesign() @@ -174,6 +188,8 @@ Item { blur: 1 blurMax: 24 opacity: 0.55 * root.fieldOpacity + // A wrong password shakes the field; its glow and glass go with it. + transform: shakeTransform } // The design behind the field, with a margin so the blur reaches past its edge. @@ -204,6 +220,7 @@ Item { maskEnabled: true maskSource: glassShape opacity: root.fieldOpacity + transform: shakeTransform } Rectangle { @@ -221,6 +238,21 @@ Item { clip: true opacity: root.fieldOpacity + transform: Translate { + id: shakeTransform + + // A head shaking no: four swings that die down, 250ms in all. + SequentialAnimation on x { + id: shakeAnimation + running: false + NumberAnimation { to: -14; duration: Style.duration(45); easing.type: Easing.OutQuad } + NumberAnimation { to: 12; duration: Style.duration(65); easing.type: Easing.InOutSine } + NumberAnimation { to: -8; duration: Style.duration(55); easing.type: Easing.InOutSine } + NumberAnimation { to: 4; duration: Style.duration(45); easing.type: Easing.InOutSine } + NumberAnimation { to: 0; duration: Style.duration(40); easing.type: Easing.OutQuad } + } + } + TextInput { id: passwordInput anchors.fill: parent diff --git a/patches/shell/plugins/lock/Service.qml b/patches/shell/plugins/lock/Service.qml index 56db5048..54b93c6e 100644 --- a/patches/shell/plugins/lock/Service.qml +++ b/patches/shell/plugins/lock/Service.qml @@ -36,6 +36,7 @@ Item { id: root property var shell: null + property var publishSessionLocked: null property string omarchyPath: "" readonly property string home: Quickshell.env("HOME") @@ -97,10 +98,18 @@ Item { // logind's inhibitor delay, its default until read. property int sleepWindowMs: 5000 property bool waking: false + property int wakeDelayMs: 0 property double wakeUntil: 0 property double lastInput: 0 readonly property bool locked: lockRequested || sessionLock.locked || sessionLock.secure + readonly property bool sessionLocked: locked || strandedLock + function syncSessionLocked() { + if (typeof publishSessionLocked === "function") publishSessionLocked(currentlyLocked() || strandedLock) + } + onSessionLockedChanged: syncSessionLocked() + onLockRequestedChanged: syncSessionLocked() + onPublishSessionLockedChanged: syncSessionLocked() // 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 @@ -313,6 +322,7 @@ Item { idleBlankTimer.stop() sessionLock.locked = false unlocking = false + syncSessionLocked() logEvent("unlocked") runWake() } @@ -324,13 +334,28 @@ Item { idleBlankTimer.stop() return } + var now = Date.now() // DPMS returns before the monitor shows a picture (about 4.2 s later on one 4K display tested). - idleBlankTimer.interval = Math.max(delayMs || idleBlankTimer.idleMs, wakeUntil - Date.now()) - idleBlankTimer.armedAt = Date.now() + var targetMs = Math.max(delayMs || idleBlankTimer.idleMs, wakeUntil - now) + if (idleBlankTimer.running && idleBlankTimer.armedAt > 0) { + var elapsedMs = now - idleBlankTimer.armedAt + if (elapsedMs > idleBlankTimer.interval + 2000) targetMs = Math.max(targetMs, idleBlankTimer.resumeMs) + else if (elapsedMs >= 0 && idleBlankTimer.interval - elapsedMs > targetMs) return + } + idleBlankTimer.interval = targetMs + idleBlankTimer.armedAt = now idleBlankTimer.restart() } - function runWake() { + function runWake(delayMs) { + if (lockRequested && fingerprintPaused && fingerprintResumeTimer.running + && FingerprintModel.spannedSleep(Date.now() - fingerprintResumeTimer.lastTickMs, fingerprintResumeTimer.interval)) { + fingerprintResumeTimer.stop() + fingerprintSleptWhilePaused = true + delayMs = Math.max(delayMs || 0, idleBlankTimer.resumeMs) + } + // Held for finishWake, which arms the countdown once the display is back. + wakeDelayMs = Math.max(wakeDelayMs, delayMs || 0) waking = true idleBlankTimer.stop() // Finish an in-flight blank before waking, so its command cannot turn us off again. @@ -344,7 +369,9 @@ Item { wakeUntil = Date.now() + 30000 blanked = false } - if (lockRequested) armBlankTimer() + var delayMs = wakeDelayMs + wakeDelayMs = 0 + if (lockRequested) armBlankTimer(delayMs) resumeFingerprint() nudgeFingerprint() } @@ -374,9 +401,9 @@ Item { if (lockRequested && fingerprintConfigured && !fingerprintAuthenticating) fingerprintRetryTimer.restart() } - // A resume can light the panel with no input to wake the lock, so after a - // lock request the reader comes back once a sleep is seen; the blank - // countdown then pauses it again if nothing else happens. The idle service + // A resume brings no input to wake the lock, so after a lock request the + // panel and the reader come back once a sleep is seen; the blank countdown + // then takes both away again if nothing else happens. The idle service // repeats the same request without sleeping, so the sleep has to be seen. function noteSleepRequested() { // Asked for while the design drives off, the lock stays: a suspend then would wake unlocked. @@ -481,12 +508,16 @@ Item { passwordPam.respond(pendingPassword) } + // onError and onCompleted can both fire; settle each password attempt once + // and always clear pendingPassword even if the lock was already dismissed. function handlePasswordFailure() { - if (!lockRequested) return + if (!authenticatingPassword) return authenticatingPassword = false - enteredPassword = "" pendingPassword = "" + if (!lockRequested) return + + enteredPassword = "" failedAttempts += 1 failureMessage = I18n.t("lock.authenticationFailed").arg(I18n.formatNumber(failedAttempts)) runWake() @@ -616,9 +647,12 @@ Item { LockView { id: lockView anchors.fill: parent + readonly property var wallpaperRequest: root.lockWallpaperRequest(lockSurface.screen, width, height) backgroundPath: root.backgroundPath videoPosterPath: root.videoPosterPath - backgroundVersion: root.backgroundVersion + backgroundVersion: wallpaperRequest.version + backgroundVersionPrefix: wallpaperRequest.versionPrefix + wallpaperDecodeSize: Qt.size(wallpaperRequest.width, wallpaperRequest.height) fingerprintConfigured: root.fingerprintConfigured || root.fingerprintUnavailable fingerprintUnavailable: root.fingerprintUnavailable authenticatingPassword: root.authenticatingPassword @@ -659,7 +693,9 @@ Item { sourceComponent: LockView { backgroundPath: root.backgroundPath videoPosterPath: root.videoPosterPath - backgroundVersion: root.backgroundVersion + readonly property var wallpaperRequest: root.lockWallpaperRequest(previewWindow.screen, width, height) + backgroundVersion: wallpaperRequest.version + backgroundVersionPrefix: wallpaperRequest.versionPrefix fingerprintConfigured: root.fingerprintConfigured || root.fingerprintUnavailable fingerprintUnavailable: root.fingerprintUnavailable authenticatingPassword: false @@ -687,12 +723,19 @@ Item { onPamMessage: root.respondToPasswordPrompt() onCompleted: function(result) { - root.authenticatingPassword = false - root.pendingPassword = "" - - if (!root.lockRequested) return - if (result === PamResult.Success) root.driveOffThenUnlock() - else root.handlePasswordFailure() + if (!root.authenticatingPassword) return + if (!root.lockRequested) { + root.authenticatingPassword = false + root.pendingPassword = "" + return + } + if (result === PamResult.Success) { + root.authenticatingPassword = false + root.pendingPassword = "" + root.driveOffThenUnlock() + } else { + root.handlePasswordFailure() + } } onError: function(error) { @@ -718,24 +761,71 @@ Item { } } - // The lock only starts decoding its wallpaper once locked, and a machine - // suspending right after locking froze that decode partway: waking showed - // the password field on a bare background, then the wallpaper popped in. - // Keep each screen's lock wallpaper decoded in the image cache ahead of - // time, as the lock view requests it (same URL, the screen's logical size, - // PreserveAspectCrop), so the lock draws it on its first frame. + // The desktop background service already decodes and caches still wallpapers + // per output at physical screen size. Sharing that cache entry per output + // avoids decoding the wallpaper twice at startup and on theme changes, and + // avoids holding a second copy in RAM. Video posters, in-place overwrites, + // outputs without a desktop panel, and sessions without the background + // service keep the hidden preload so suspend-after-lock still draws frame 1. + readonly property var backgroundService: { + var _ = root.shell ? root.shell.services : null + return root.shell ? root.shell.serviceFor("omarchy.background") : null + } readonly property string lockWallpaperPath: videoBackground ? videoPosterPath : backgroundPath readonly property string lockWallpaperUrl: lockWallpaperPath && !Util.isVideoPath(lockWallpaperPath) - ? Util.fileUrl(lockWallpaperPath) + (backgroundVersion ? "?v=" + backgroundVersion : "") + ? Util.fileUrl(lockWallpaperPath) + "?lockv=" + backgroundVersion : "" + Connections { + target: root.backgroundService + function onDisplayedBackgroundChanged() { + root.refreshBackground() + } + } + + function desktopStillEntry(screen) { + if (!screen || videoBackground || !backgroundPath) return null + if (!backgroundService || typeof backgroundService.stillCacheEntry !== "function") return null + return backgroundService.stillCacheEntry(screen, backgroundPath, backgroundSignature) + } + + function desktopStillPending(screen) { + if (!screen || lockRequested || videoBackground || !backgroundPath) return false + if (!backgroundService || typeof backgroundService.stillPending !== "function") return false + if (readlinkProc.running) return true + return backgroundService.stillPending(screen, backgroundPath, backgroundSignature) + } + + function lockWallpaperRequest(screen, fallbackWidth, fallbackHeight) { + var entry = desktopStillEntry(screen) + if (entry) { + return { + version: entry.version, + versionPrefix: "v", + width: entry.width, + height: entry.height, + shared: true + } + } + return { + version: backgroundVersion, + versionPrefix: "lockv", + width: fallbackWidth, + height: fallbackHeight, + shared: false + } + } + Variants { model: Quickshell.screens Image { required property var modelData + // Skip the hidden preload on outputs where the desktop background panel + // already owns this still (or is probing its native dimensions at startup). + readonly property bool desktopOwnsOutput: root.desktopStillEntry(modelData) !== null || root.desktopStillPending(modelData) visible: false - source: root.lockWallpaperUrl + source: desktopOwnsOutput ? "" : root.lockWallpaperUrl sourceSize.width: modelData.width sourceSize.height: modelData.height fillMode: Image.PreserveAspectCrop @@ -815,8 +905,9 @@ Item { if (slept && root.lockRequested && root.fingerprintPaused) { stop() root.fingerprintSleptWhilePaused = true - root.resumeFingerprint() - root.armBlankTimer(idleBlankTimer.resumeMs) + // A panel blanked before the sleep stays dark through the resume, and + // opening the lid is no input that would light it. + root.runWake(idleBlankTimer.resumeMs) } else if (slept || !root.fingerprintPaused || --ticksLeft <= 0) { stop() } @@ -832,7 +923,7 @@ Item { Process { id: readlinkProc - command: ["bash", "-c", "path=$(readlink -f -- \"$1\") && printf '%s\\n%s\\n' \"$path\" \"$(stat -Lc %Y:%s -- \"$path\" 2>/dev/null)\"", "_", root.currentBackgroundLink] + command: ["bash", "-c", "path=$(readlink -f -- \"$1\") && printf '%s\\n%s\\n' \"$path\" \"$(stat -Lc '%y:%s:%i' -- \"$path\" 2>/dev/null)\"", "_", root.currentBackgroundLink] stdout: StdioCollector { waitForEnd: true onStreamFinished: { @@ -963,6 +1054,20 @@ Item { } } + // Hyprland lights the panel for any key, but a bound key like volume never + // reaches the lock surface, so nothing re-arms the blank and the lock stays + // lit. Blank once input has been quiet for the run-up and no countdown is + // pending, so the resume run-up is left alone. + IdleMonitor { + id: lockIdleMonitor + enabled: root.lockRequested + timeout: idleBlankTimer.idleMs / 1000 + respectInhibitors: false + onIsIdleChanged: { + if (isIdle && root.lockRequested && !root.authenticatingPassword && !root.waking && !root.unlocking && !idleBlankTimer.running) root.runBlank() + } + } + Timer { id: sessionLockStabilizeTimer interval: 500 @@ -1061,6 +1166,12 @@ Item { return root.currentlyLocked() ? "true" : "false" } + function wake(): string { + if (!root.currentlyLocked()) return "unlocked" + root.runWake() + return "ok" + } + function status(): string { return root.statusText } diff --git a/tests/lock-idle.js b/tests/lock-idle.js index cf79c9ba..555926fd 100644 --- a/tests/lock-idle.js +++ b/tests/lock-idle.js @@ -11,7 +11,8 @@ const wakeExit = source.match(/id: wakeProcess[^]*?onExited: (.+)/)[1] const blankExit = source.match(/id: blankProcess[^]*?onExited: (.+)/)[1] let now = 100000, blankAt = 0, hidden = false, plays = 0 const scope = { Date: { now: () => now }, lockRequested: true, waking: false, unlocking: false, - authenticatingPassword: false, lastInput: 0, wakeUntil: 0, logEvent() {}, + authenticatingPassword: false, lastInput: 0, wakeUntil: 0, wakeDelayMs: 0, logEvent() {}, + fingerprintPaused: false, fingerprintResumeTimer: { running: false }, pauseFingerprint() {}, resumeFingerprint() {}, nudgeFingerprint() {}, wakeProcess: { running: false }, blankProcess: { running: false }, unlockTimer: { starts: 0, running: false, restart() { this.starts++; this.running = true }, stop() { this.running = false } }, @@ -83,7 +84,6 @@ scope.driveOffThenUnlock() scope.driveOffThenUnlock() assert.equal(scope.unlockTimer.starts, 1, "authentication started the exit more than once") // A suspend asks for the lock first; mid-exit that request must hold it, or the machine wakes unlocked. -scope.fingerprintPaused = false scope.noteSleepRequested() assert.deepEqual([scope.unlocking, scope.unlockTimer.running], [false, false], "a lock asked for during the exit still unlocked") // The design, already leaving, comes back; after a finished unlock, its input off, it does not. diff --git a/tests/lock-process.py b/tests/lock-process.py index f3247051..84e089eb 100644 --- a/tests/lock-process.py +++ b/tests/lock-process.py @@ -169,12 +169,13 @@ def start(): assert ipc("hidePreview") == "ok" until(lambda: not child_pid(), "closed preview retained its worker") requests = re.findall(r"WALLPAPER_REQUEST (\S+)", logs()) - assert len(requests) == 1 and requests[0].endswith("?v=1"), requests + assert len(requests) == 1 and requests[0].endswith("?lockv=1"), requests (state / "background").unlink() (config / "lock-design").write_text("mycelium\n") print("ok: a fresh worker requests its wallpaper once", flush=True) requested_at = time.time() * 1000 + assert ipc("wake") == "unlocked", "an unlocked shell claimed the lid's wake" assert ipc("lock") == "ok" until(lambda: status().get("sessionLocked"), "lock never took hold") frame = until(lambda: re.search(r"LOCK_FRAME (\d+)", logs()), "lock surface never rendered") @@ -193,6 +194,10 @@ def start(): until(lambda: status()["lastEvent"] == "display: lit by resume", "a resume left a blanked lock dark") until(lambda: list(home.glob("wake.*")), "a resume ran no wake command", timeout=3) print("ok: a suspend waits for the lock's blank, and a resume lights it without playing the design", flush=True) + # Opening a laptop lid wakes a blanked lock through the shell, as omarchy-system-lid-open asks. + assert ipc("wake") == "ok" + until(lambda: status()["lastEvent"] == "display: wake", "the lid's wake left the lock blanked") + print("ok: a lid wake reaches the lock worker", flush=True) parent.terminate() parent.wait(timeout=3) time.sleep(1) diff --git a/tests/lock-render.py b/tests/lock-render.py index 54314212..56ef2be3 100644 --- a/tests/lock-render.py +++ b/tests/lock-render.py @@ -26,6 +26,7 @@ def standalone(source): source = re.sub(r"Util\.isVideoPath\([^)]*\)", "false", source) source = re.sub(r"Util\.fileUrl\(([^)]*)\)", r'("file://" + \1)', source) source = source.replace("Style.font.heading", "16").replace("Style.font.family", '"monospace"') + source = re.sub(r"Style\.duration\(([^)]*)\)", r"\1", source).replace("Style.reduceMotion", "false") return re.sub(r"Color\.(?:lock\.)?\w+", lambda m: json.dumps(colors[m[0][6:]]), source) shutil.rmtree(output / "lock", ignore_errors=True) shutil.copytree(repo / "lock", output / "lock") From 2e9506a490873219b9aaa840759b71e6d1a602c5 Mon Sep 17 00:00:00 2001 From: Xpond Date: Sat, 5 Dec 2026 10:18:46 +0530 Subject: [PATCH 2/2] Tell the shell when wheely's lock is locked 4.6's shell hands the lock service a publisher for sessionLocked, which the bar and plugins read (the media widget stops scrolling under the lock). Our service is a Loader, so the publisher went nowhere and the shell always saw the screen unlocked. The Loader passes it to the bridge, which reports its locked state, or to the in-process lock, which reports as 4.6's does. --- lock-session/Bridge.qml | 5 +++++ patches/shell/plugins/lock/Service.qml | 5 ++++- tests/lock-process.py | 18 +++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lock-session/Bridge.qml b/lock-session/Bridge.qml index c6deabcd..19e8d97a 100644 --- a/lock-session/Bridge.qml +++ b/lock-session/Bridge.qml @@ -11,6 +11,11 @@ Item { property int serial: 0 property bool passwordPamConfigured: false readonly property bool locked: !!lockState.locked || !!(pending && pending.action === "lock") + // Set by the shell, which tells the bar and plugins the screen is locked. + property var publishSessionLocked: null + function syncSessionLocked() { if (typeof publishSessionLocked === "function") publishSessionLocked(locked) } + onLockedChanged: syncSessionLocked() + onPublishSessionLockedChanged: syncSessionLocked() readonly property string directory: Quickshell.env("HOME") + "/.local/share/wheely/lock-session" readonly property string socketPath: Quickshell.env("XDG_RUNTIME_DIR") + "/omarchy-lock-" + Quickshell.env("WAYLAND_DISPLAY").replace(/[^a-zA-Z0-9_.-]/g, "_") + ".sock" diff --git a/patches/shell/plugins/lock/Service.qml b/patches/shell/plugins/lock/Service.qml index 54b93c6e..61d6abd3 100644 --- a/patches/shell/plugins/lock/Service.qml +++ b/patches/shell/plugins/lock/Service.qml @@ -17,12 +17,15 @@ Loader { "file://" + Quickshell.env("HOME") + "/.local/share/wheely/lock-session/Bridge.qml" sourceComponent: Quickshell.env("OMARCHY_LOCK_SESSION") === "1" || fallback ? session : undefined onStatusChanged: if (status === Loader.Error) fallback = true + // The shell hears the lock state through this; whichever lock is loaded reports it. + property var publishSessionLocked: null + onPublishSessionLockedChanged: if (item) item.publishSessionLocked = publishSessionLocked // The lock the worker never took is taken here once PAM is known. function takeOver() { if (relock && item && item.passwordPamConfigured) { relock = false; item.beginLock() } } - onLoaded: takeOver() + onLoaded: { item.publishSessionLocked = publishSessionLocked; takeOver() } Connections { target: loader.item ignoreUnknownSignals: true diff --git a/tests/lock-process.py b/tests/lock-process.py index 84e089eb..b5566863 100644 --- a/tests/lock-process.py +++ b/tests/lock-process.py @@ -93,8 +93,15 @@ def interrupted(signum, frame): }''') (out / "shell.qml").write_text('''import QtQuick import Quickshell +import Quickshell.Io import "Lock" as Lock -ShellRoot { Lock.Service {} } +// Hands the lock service a publisher after creating it, as Omarchy's shell does. +ShellRoot { + id: root + property bool locked: false + Lock.Service { Component.onCompleted: publishSessionLocked = value => root.locked = value } + IpcHandler { target: "shell"; function locked(): string { return String(root.locked) } } +} ''') env = dict(os.environ, HOME=str(home), PATH=str(stubs) + ":/usr/bin", QT_QPA_PLATFORM="offscreen", QT_QPA_PLATFORMTHEME="generic", QT_QUICK_BACKEND="rhi", @@ -107,6 +114,11 @@ def ipc(action, child=False): "call", "lock", action], env=env, capture_output=True, text=True, timeout=3) return result.stdout.strip() if result.returncode == 0 else "" + def shell_locked(): + result = subprocess.run(["quickshell", "ipc", "-p", str(out), "call", "shell", "locked"], + env=env, capture_output=True, text=True, timeout=3) + return result.stdout.strip() == "true" + def status(): return json.loads(ipc("status") or "{}") @@ -176,8 +188,10 @@ def start(): requested_at = time.time() * 1000 assert ipc("wake") == "unlocked", "an unlocked shell claimed the lid's wake" + assert not shell_locked() assert ipc("lock") == "ok" until(lambda: status().get("sessionLocked"), "lock never took hold") + assert shell_locked(), "the shell never heard the worker's lock" frame = until(lambda: re.search(r"LOCK_FRAME (\d+)", logs()), "lock surface never rendered") print(f"lock request to first frame: {int(frame[1]) - requested_at:.0f} ms", flush=True) pid = child_pid() @@ -220,6 +234,7 @@ def start(): assert status().get("locked") and status()["lastEvent"] == "unlock: cancelled", status() assert ipc("authenticated", child=True) == "ok" until(lambda: not status().get("locked"), "authenticated unlock did not release") + assert not shell_locked(), "the shell still thinks the screen is locked" assert "RELEASE_DELAY 550" in logs(), "mycelium's unlock did not wait its own releaseDelay" until(lambda: not child_pid(), "unlock retained its worker") until(lambda: not list(home.glob("wake.*")), "worker exited before its wake command finished", timeout=3) @@ -248,6 +263,7 @@ def start(): until(lambda: status().get("passwordPam"), "missing bridge left no lock service") assert ipc("lock") == "ok" until(lambda: status().get("sessionLocked"), "missing bridge did not lock in-process") + assert shell_locked(), "the shell never heard the in-process lock" assert not child_pid(), "missing bridge started a worker" print("ok: a failed worker or missing bridge locks in-process", flush=True) finally: