mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-08 06:28:27 -04:00
lock: fix custom lock commands with lock before suspend and hibernate
fixes #2326
This commit is contained in:
@@ -41,6 +41,7 @@ Scope {
|
|||||||
property bool pendingLock: false
|
property bool pendingLock: false
|
||||||
property bool lockPowerOffArmed: false
|
property bool lockPowerOffArmed: false
|
||||||
property bool lockWakeAllowed: false
|
property bool lockWakeAllowed: false
|
||||||
|
property bool customLockerSpawned: false
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
IdleService.lockComponent = this;
|
IdleService.lockComponent = this;
|
||||||
@@ -57,13 +58,26 @@ Scope {
|
|||||||
DMSService.unlockSession(() => {});
|
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() {
|
function lock() {
|
||||||
if (SettingsData.customPowerActionLock?.length > 0) {
|
if (SettingsData.customPowerActionLock?.length > 0) {
|
||||||
Quickshell.execDetached(["sh", "-c", SettingsData.customPowerActionLock]);
|
spawnCustomLocker();
|
||||||
// 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();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (shouldLock || pendingLock)
|
if (shouldLock || pendingLock)
|
||||||
@@ -94,6 +108,7 @@ Scope {
|
|||||||
lockInitiatedLocally = false;
|
lockInitiatedLocally = false;
|
||||||
pendingLock = false;
|
pendingLock = false;
|
||||||
shouldLock = false;
|
shouldLock = false;
|
||||||
|
customLockerSpawned = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function activate() {
|
function activate() {
|
||||||
@@ -106,6 +121,8 @@ Scope {
|
|||||||
function onSessionLocked() {
|
function onSessionLocked() {
|
||||||
if (shouldLock || pendingLock)
|
if (shouldLock || pendingLock)
|
||||||
return;
|
return;
|
||||||
|
if (handleLoginctlCustomLock())
|
||||||
|
return;
|
||||||
if (!SessionService.active && SessionService.loginctlAvailable && SettingsData.loginctlLockIntegration) {
|
if (!SessionService.active && SessionService.loginctlAvailable && SettingsData.loginctlLockIntegration) {
|
||||||
pendingLock = true;
|
pendingLock = true;
|
||||||
lockInitiatedLocally = false;
|
lockInitiatedLocally = false;
|
||||||
@@ -117,6 +134,7 @@ Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onSessionUnlocked() {
|
function onSessionUnlocked() {
|
||||||
|
customLockerSpawned = false;
|
||||||
if (pendingLock) {
|
if (pendingLock) {
|
||||||
pendingLock = false;
|
pendingLock = false;
|
||||||
lockInitiatedLocally = false;
|
lockInitiatedLocally = false;
|
||||||
@@ -136,6 +154,8 @@ Scope {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (SessionService.locked && !shouldLock && !pendingLock) {
|
if (SessionService.locked && !shouldLock && !pendingLock) {
|
||||||
|
if (handleLoginctlCustomLock())
|
||||||
|
return;
|
||||||
lockInitiatedLocally = false;
|
lockInitiatedLocally = false;
|
||||||
lockPowerOffArmed = SettingsData.lockScreenPowerOffMonitorsOnLock;
|
lockPowerOffArmed = SettingsData.lockScreenPowerOffMonitorsOnLock;
|
||||||
shouldLock = true;
|
shouldLock = true;
|
||||||
|
|||||||
@@ -536,6 +536,7 @@ Item {
|
|||||||
iconName: "developer_mode"
|
iconName: "developer_mode"
|
||||||
title: I18n.tr("Custom Power Actions")
|
title: I18n.tr("Custom Power Actions")
|
||||||
settingKey: "customPowerActions"
|
settingKey: "customPowerActions"
|
||||||
|
tags: ["lock", "logout", "suspend", "hibernate", "reboot", "poweroff", "power off", "shutdown", "command", "script", "override"]
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: [
|
model: [
|
||||||
@@ -602,7 +603,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6778,12 +6778,19 @@
|
|||||||
"category": "Power & Sleep",
|
"category": "Power & Sleep",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"actions",
|
"actions",
|
||||||
|
"command",
|
||||||
"custom",
|
"custom",
|
||||||
"energy",
|
"energy",
|
||||||
"hibernate",
|
"hibernate",
|
||||||
|
"lock",
|
||||||
|
"logout",
|
||||||
|
"override",
|
||||||
"power",
|
"power",
|
||||||
|
"power off",
|
||||||
|
"poweroff",
|
||||||
"reboot",
|
"reboot",
|
||||||
"restart",
|
"restart",
|
||||||
|
"script",
|
||||||
"shutdown",
|
"shutdown",
|
||||||
"sleep",
|
"sleep",
|
||||||
"suspend"
|
"suspend"
|
||||||
|
|||||||
Reference in New Issue
Block a user