move lock dir up to shell/lock as sibling of modules

This commit is contained in:
Damocles 2026-04-17 18:32:33 +02:00
parent d6cd2f173a
commit b5b1f4f406
7 changed files with 5 additions and 5 deletions

78
shell/lock/Lock.qml Normal file
View file

@ -0,0 +1,78 @@
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Wayland
import "../modules" as M
Scope {
id: root
readonly property bool _enabled: M.Modules.lock.enable
property string _sessionPath: ""
WlSessionLock {
id: _lock
LockSurface {
lock: _lock
auth: _auth
}
}
LockAuth {
id: _auth
lock: _lock
}
// Resolve the actual logind session object path at startup
Process {
id: _sessionResolver
command: ["busctl", "call", "--system", "org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "GetSession", "s", "auto"]
running: root._enabled
stdout: SplitParser {
onRead: data => {
// Output: o "/org/freedesktop/login1/session/_32"
const match = data.match(/"([^"]+)"/);
if (match)
root._sessionPath = match[1];
}
}
onExited: {
if (root._sessionPath)
_logindMonitor.running = true;
}
}
// Listen for logind Lock/Unlock signals via gdbus monitor.
// TODO: replace with native D-Bus integration when nova-stats becomes a quickshell plugin
Process {
id: _logindMonitor
command: ["gdbus", "monitor", "--system", "--dest", "org.freedesktop.login1", "--object-path", root._sessionPath]
running: false
stdout: SplitParser {
onRead: data => {
if (data.indexOf(".Lock ()") !== -1 && root._enabled)
_lock.locked = true;
// Unlock is PAM-driven, ignore logind Unlock signal
}
}
}
// Set logind LockedHint when lock state changes
Process {
id: _lockedHint
command: ["busctl", "call", "--system", "org.freedesktop.login1", root._sessionPath || "/org/freedesktop/login1/session/auto", "org.freedesktop.login1.Session", "SetLockedHint", "b", _lock.locked ? "true" : "false"]
}
Connections {
target: _lock
function onLockStateChanged() {
if (root._sessionPath)
_lockedHint.running = true;
}
}
}