1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

Sync lock/unlock events with loginctl

This commit is contained in:
bbedward
2025-10-13 19:46:18 -04:00
parent 0e3d3d1a40
commit 9b96dae744
2 changed files with 47 additions and 6 deletions

View File

@@ -8,26 +8,59 @@ import qs.Common
import qs.Services import qs.Services
Scope { Scope {
id: root
property string sharedPasswordBuffer: "" property string sharedPasswordBuffer: ""
property bool shouldLock: false property bool shouldLock: false
property bool processingExternalEvent: false
Component.onCompleted: { Component.onCompleted: {
IdleService.lockComponent = this IdleService.lockComponent = this
} }
function lock() {
if (!processingExternalEvent && SessionData.loginctlLockIntegration && DMSService.isConnected) {
DMSService.lockSession(response => {
if (response.error) {
console.warn("Lock: Failed to call loginctl.lock:", response.error)
shouldLock = true
}
})
} else {
shouldLock = true
}
}
function unlock() {
if (!processingExternalEvent && SessionData.loginctlLockIntegration && DMSService.isConnected) {
DMSService.unlockSession(response => {
if (response.error) {
console.warn("Lock: Failed to call loginctl.unlock:", response.error)
shouldLock = false
}
})
} else {
shouldLock = false
}
}
function activate() { function activate() {
shouldLock = true lock()
} }
Connections { Connections {
target: SessionService target: SessionService
function onSessionLocked() { function onSessionLocked() {
processingExternalEvent = true
shouldLock = true shouldLock = true
processingExternalEvent = false
} }
function onSessionUnlocked() { function onSessionUnlocked() {
processingExternalEvent = true
shouldLock = false shouldLock = false
processingExternalEvent = false
} }
} }
@@ -35,7 +68,7 @@ Scope {
target: IdleService target: IdleService
function onLockRequested() { function onLockRequested() {
shouldLock = true lock()
} }
} }
@@ -50,12 +83,12 @@ Scope {
LockSurface { LockSurface {
anchors.fill: parent anchors.fill: parent
lock: sessionLock lock: sessionLock
sharedPasswordBuffer: sharedPasswordBuffer sharedPasswordBuffer: root.sharedPasswordBuffer
onUnlockRequested: { onUnlockRequested: {
shouldLock = false root.unlock()
} }
onPasswordChanged: newPassword => { onPasswordChanged: newPassword => {
sharedPasswordBuffer = newPassword root.sharedPasswordBuffer = newPassword
} }
} }
} }
@@ -69,7 +102,7 @@ Scope {
target: "lock" target: "lock"
function lock() { function lock() {
shouldLock = true root.lock()
} }
function demo() { function demo() {

View File

@@ -394,4 +394,12 @@ Singleton {
} }
}) })
} }
function lockSession(callback) {
sendRequest("loginctl.lock", null, callback)
}
function unlockSession(callback) {
sendRequest("loginctl.unlock", null, callback)
}
} }