1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-07 05:55:37 -05:00
Files
DankMaterialShell/Modules/Lock/Lock.qml
2025-08-12 11:35:30 -04:00

94 lines
1.8 KiB
QML

pragma ComponentBehavior
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Wayland
import qs.Common
Item {
id: root
function activate() {
loader.activeAsync = true
}
function checkLockedOnStartup() {
lockStateChecker.running = true
}
Component.onCompleted: {
checkLockedOnStartup()
}
Process {
id: lockStateChecker
command: ["loginctl", "show-session", Quickshell.env("XDG_SESSION_ID"), "--property=LockedHint"]
running: false
onExited: (exitCode, exitStatus) => {
if (exitCode !== 0) {
console.warn("Failed to check session lock state, exit code:", exitCode)
}
}
stdout: StdioCollector {
onStreamFinished: {
if (text.trim() === "LockedHint=yes") {
console.log("Session is locked on startup, activating lock screen")
loader.activeAsync = true
}
}
}
}
LazyLoader {
id: loader
WlSessionLock {
id: sessionLock
property bool unlocked: false
property string sharedPasswordBuffer: ""
locked: true
onLockedChanged: {
if (!locked)
loader.active = false
}
LockSurface {
id: lockSurface
lock: sessionLock
sharedPasswordBuffer: sessionLock.sharedPasswordBuffer
onPasswordChanged: newPassword => {
sessionLock.sharedPasswordBuffer = newPassword
}
}
}
}
LockScreenDemo {
id: demoWindow
}
IpcHandler {
target: "lock"
function lock(): void {
console.log("Lock screen requested via IPC")
loader.activeAsync = true
}
function demo(): void {
console.log("Lock screen DEMO mode requested via IPC")
demoWindow.showDemo()
}
function isLocked(): bool {
return loader.active
}
}
}