1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-01 19:18:28 -04:00

lock: fix custom lock commands with lock before suspend and hibernate

fixes #2326
This commit is contained in:
bbedward
2026-07-02 15:41:05 -04:00
parent 2663bcd96c
commit 4c43bed2f8
3 changed files with 33 additions and 6 deletions
+25 -5
View File
@@ -41,6 +41,7 @@ Scope {
property bool pendingLock: false
property bool lockPowerOffArmed: false
property bool lockWakeAllowed: false
property bool customLockerSpawned: false
Component.onCompleted: {
IdleService.lockComponent = this;
@@ -57,13 +58,26 @@ Scope {
DMSService.unlockSession(() => {});
}
function spawnCustomLocker() {
Quickshell.execDetached(["sh", "-c", SettingsData.customPowerActionLock]);
// The custom locker manages its own surface; DMS never engages
// WlSessionLock here, so isShellLocked stays false and the fade
// overlay would never be dismissed. Hand off by dismissing it now.
IdleService.dismissFadeToLock();
customLockerSpawned = true;
}
function handleLoginctlCustomLock(): bool {
if (!(SettingsData.customPowerActionLock?.length > 0))
return false;
if (!customLockerSpawned)
spawnCustomLocker();
return true;
}
function lock() {
if (SettingsData.customPowerActionLock?.length > 0) {
Quickshell.execDetached(["sh", "-c", SettingsData.customPowerActionLock]);
// The custom locker manages its own surface; DMS never engages
// WlSessionLock here, so isShellLocked stays false and the fade
// overlay would never be dismissed. Hand off by dismissing it now.
IdleService.dismissFadeToLock();
spawnCustomLocker();
return;
}
if (shouldLock || pendingLock)
@@ -94,6 +108,7 @@ Scope {
lockInitiatedLocally = false;
pendingLock = false;
shouldLock = false;
customLockerSpawned = false;
}
function activate() {
@@ -106,6 +121,8 @@ Scope {
function onSessionLocked() {
if (shouldLock || pendingLock)
return;
if (handleLoginctlCustomLock())
return;
if (!SessionService.active && SessionService.loginctlAvailable && SettingsData.loginctlLockIntegration) {
pendingLock = true;
lockInitiatedLocally = false;
@@ -117,6 +134,7 @@ Scope {
}
function onSessionUnlocked() {
customLockerSpawned = false;
if (pendingLock) {
pendingLock = false;
lockInitiatedLocally = false;
@@ -136,6 +154,8 @@ Scope {
return;
}
if (SessionService.locked && !shouldLock && !pendingLock) {
if (handleLoginctlCustomLock())
return;
lockInitiatedLocally = false;
lockPowerOffArmed = SettingsData.lockScreenPowerOffMonitorsOnLock;
shouldLock = true;
@@ -536,6 +536,7 @@ Item {
iconName: "developer_mode"
title: I18n.tr("Custom Power Actions")
settingKey: "customPowerActions"
tags: ["lock", "logout", "suspend", "hibernate", "reboot", "poweroff", "power off", "shutdown", "command", "script", "override"]
Repeater {
model: [
@@ -602,7 +603,6 @@ Item {
}
}
}
}
}
}
@@ -6778,12 +6778,19 @@
"category": "Power & Sleep",
"keywords": [
"actions",
"command",
"custom",
"energy",
"hibernate",
"lock",
"logout",
"override",
"power",
"power off",
"poweroff",
"reboot",
"restart",
"script",
"shutdown",
"sleep",
"suspend"