mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-30 00:12:50 -05:00
Add lock before suspend option to power settings
This commit is contained in:
@@ -58,6 +58,8 @@ Singleton {
|
|||||||
property int batterySuspendTimeout: 0 // Never
|
property int batterySuspendTimeout: 0 // Never
|
||||||
property int batteryHibernateTimeout: 0 // Never
|
property int batteryHibernateTimeout: 0 // Never
|
||||||
|
|
||||||
|
property bool lockBeforeSuspend: false
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
loadSettings()
|
loadSettings()
|
||||||
}
|
}
|
||||||
@@ -121,6 +123,7 @@ Singleton {
|
|||||||
batteryLockTimeout = settings.batteryLockTimeout !== undefined ? settings.batteryLockTimeout : 0
|
batteryLockTimeout = settings.batteryLockTimeout !== undefined ? settings.batteryLockTimeout : 0
|
||||||
batterySuspendTimeout = settings.batterySuspendTimeout !== undefined ? settings.batterySuspendTimeout : 0
|
batterySuspendTimeout = settings.batterySuspendTimeout !== undefined ? settings.batterySuspendTimeout : 0
|
||||||
batteryHibernateTimeout = settings.batteryHibernateTimeout !== undefined ? settings.batteryHibernateTimeout : 0
|
batteryHibernateTimeout = settings.batteryHibernateTimeout !== undefined ? settings.batteryHibernateTimeout : 0
|
||||||
|
lockBeforeSuspend = settings.lockBeforeSuspend !== undefined ? settings.lockBeforeSuspend : false
|
||||||
|
|
||||||
// Generate system themes but don't override user's theme choice
|
// Generate system themes but don't override user's theme choice
|
||||||
if (typeof Theme !== "undefined") {
|
if (typeof Theme !== "undefined") {
|
||||||
@@ -170,7 +173,8 @@ Singleton {
|
|||||||
"batteryMonitorTimeout": batteryMonitorTimeout,
|
"batteryMonitorTimeout": batteryMonitorTimeout,
|
||||||
"batteryLockTimeout": batteryLockTimeout,
|
"batteryLockTimeout": batteryLockTimeout,
|
||||||
"batterySuspendTimeout": batterySuspendTimeout,
|
"batterySuspendTimeout": batterySuspendTimeout,
|
||||||
"batteryHibernateTimeout": batteryHibernateTimeout
|
"batteryHibernateTimeout": batteryHibernateTimeout,
|
||||||
|
"lockBeforeSuspend": lockBeforeSuspend
|
||||||
}, null, 2))
|
}, null, 2))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,6 +461,11 @@ Singleton {
|
|||||||
saveSettings()
|
saveSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setLockBeforeSuspend(enabled) {
|
||||||
|
lockBeforeSuspend = enabled
|
||||||
|
saveSettings()
|
||||||
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
id: settingsFile
|
id: settingsFile
|
||||||
|
|
||||||
|
|||||||
@@ -223,6 +223,14 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DankToggle {
|
||||||
|
width: parent.width
|
||||||
|
text: "Lock before suspend"
|
||||||
|
description: "Automatically lock the screen when the system prepares to suspend"
|
||||||
|
checked: SessionData.lockBeforeSuspend
|
||||||
|
onToggled: checked => SessionData.setLockBeforeSuspend(checked)
|
||||||
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: "Idle monitoring not supported - requires newer Quickshell version"
|
text: "Idle monitoring not supported - requires newer Quickshell version"
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
|||||||
@@ -79,25 +79,39 @@ Item {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: lockStateMonitor
|
id: lockStateMonitor
|
||||||
command: root.sessionPath ? ["gdbus", "monitor", "--system", "--dest", "org.freedesktop.login1", "--object-path", root.sessionPath] : []
|
command: root.sessionPath ? ["gdbus", "monitor", "--system", "--dest", "org.freedesktop.login1"] : []
|
||||||
running: false
|
running: false
|
||||||
|
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
splitMarker: "\n"
|
splitMarker: "\n"
|
||||||
|
|
||||||
onRead: line => {
|
onRead: line => {
|
||||||
if (line.includes("org.freedesktop.login1.Session.Lock")) {
|
if (line.includes(root.sessionPath)) {
|
||||||
console.log("login1: Lock signal received -> show lock")
|
if (line.includes("org.freedesktop.login1.Session.Lock")) {
|
||||||
|
console.log("login1: Lock signal received -> show lock")
|
||||||
|
loader.activeAsync = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (line.includes("org.freedesktop.login1.Session.Unlock")) {
|
||||||
|
console.log("login1: Unlock signal received -> hide lock")
|
||||||
|
loader.active = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (line.includes("LockedHint") && line.includes("true")) {
|
||||||
|
console.log("login1: LockedHint=true -> show lock")
|
||||||
|
loader.activeAsync = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (line.includes("LockedHint") && line.includes("false")) {
|
||||||
|
console.log("login1: LockedHint=false -> hide lock")
|
||||||
|
loader.active = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (line.includes("PrepareForSleep") &&
|
||||||
|
line.includes("true") &&
|
||||||
|
SessionData.lockBeforeSuspend) {
|
||||||
loader.activeAsync = true
|
loader.activeAsync = true
|
||||||
} else if (line.includes("org.freedesktop.login1.Session.Unlock")) {
|
|
||||||
console.log("login1: Unlock signal received -> hide lock")
|
|
||||||
loader.active = false
|
|
||||||
} else if (line.includes("LockedHint") && line.includes("true")) {
|
|
||||||
console.log("login1: LockedHint=true -> show lock")
|
|
||||||
loader.activeAsync = true
|
|
||||||
} else if (line.includes("LockedHint") && line.includes("false")) {
|
|
||||||
console.log("login1: LockedHint=false -> hide lock")
|
|
||||||
loader.active = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user