From ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 23 Sep 2026 21:08:35 +0200 Subject: ... --- .../gkleen@skadhi/shell/quickshell/Lockscreen.qml | 128 +++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 accounts/gkleen@skadhi/shell/quickshell/Lockscreen.qml (limited to 'accounts/gkleen@skadhi/shell/quickshell/Lockscreen.qml') diff --git a/accounts/gkleen@skadhi/shell/quickshell/Lockscreen.qml b/accounts/gkleen@skadhi/shell/quickshell/Lockscreen.qml new file mode 100644 index 00000000..0b4a68b2 --- /dev/null +++ b/accounts/gkleen@skadhi/shell/quickshell/Lockscreen.qml @@ -0,0 +1,128 @@ +import Quickshell +import Quickshell.Wayland +import Quickshell.Io +import Quickshell.Services.Pam +import Quickshell.Services.Mpris +import Custom as Custom +import qs.Services +import QtQml + +Scope { + id: lockscreen + + property string currentText: "" + + PamContext { + id: pam + + property list messages: [] + + config: "quickshell" + onCompleted: result => { + if (result === PamResult.Success) { + lock.locked = false; + } + } + onPamMessage: { + messages = Array.from(messages).concat([{ "text": pam.message, "error": pam.messageIsError }]) + } + onActiveChanged: { + messages = []; + } + } + + Connections { + target: Custom.Systemd + function onSleep(before: bool) { + console.log(`received prepare for sleep ${before}`); + if (before) { + lock.locked = true; + if (pam.active) + pam.abort(); + } + } + function onLock() { lock.locked = true; } + function onUnlock() { lock.locked = false; } + } + + IdleMonitor { + id: idleMonitor + enabled: !lock.secure && !InhibitorState.lockscreenInhibited + timeout: 600 + respectInhibitors: true + + onIsIdleChanged: { + if (idleMonitor.isIdle) + lock.locked = true; + } + } + + Custom.SystemdInhibitor { + enabled: !lock.secure + + what: Custom.SystemdInhibitorParams.Sleep + who: "quickshell" + why: "Lock session" + mode: Custom.SystemdInhibitorParams.Delay + } + + Binding { + target: NotificationManager + property: "lockscreenActive" + value: lock.locked + } + + WlSessionLock { + id: lock + + onLockStateChanged: { + if (!locked && pam.active) + pam.abort(); + + if (locked) { + NiriService.sendCommand({ "Action": { "PowerOffMonitors": {} } }, _ => {}); + Custom.KeePassXC.lockAllDatabases(); + Array.from(MprisProxy.players).forEach(player => { + if (player.canPause && player.isPlaying) + player.pause(); + }); + // Custom.Systemd.stopUserUnit("gpg-agent.service", "replace"); + GpgAgent.reloadAgent(); + } + } + Component.onCompleted: { (_ => {})(MprisProxy.players); } + + onSecureStateChanged: Custom.Systemd.lockedHint = lock.secure + + WlSessionLockSurface { + id: lockSurface + + color: "black" + + LockSurface { + id: surfaceContent + + onResponse: responseText => pam.respond(responseText) + onAuthRunningChanged: { + if (authRunning) + pam.start(); + } + Connections { + target: pam + function onMessagesChanged() { surfaceContent.messages = pam.messages; } + function onResponseRequiredChanged() { surfaceContent.responseRequired = pam.responseRequired; } + function onActiveChanged() { surfaceContent.authRunning = pam.active; } + } + onCurrentTextChanged: lockscreen.currentText = currentText + Connections { + target: lockscreen + function onCurrentTextChanged() { surfaceContent.currentText = lockscreen.currentText; } + } + Connections { + target: lockSurface + function onScreenChanged() { surfaceContent.screen = lockSurface.screen; } + } + } + } + } +} -- cgit v1.2.3