From ce6c16214c00dad676227985b1278a7c1a5353c0 Mon Sep 17 00:00:00 2001 From: bbedward Date: Fri, 17 Oct 2025 08:36:11 -0400 Subject: [PATCH] lock: allow custom lock command --- Common/SettingsData.qml | 12 ++++++++++-- Modals/Settings/PowerSettings.qml | 32 +++++++++++++++++++++++++++++++ Modules/Lock/Lock.qml | 4 ++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/Common/SettingsData.qml b/Common/SettingsData.qml index d640c00b..4c13db4d 100644 --- a/Common/SettingsData.qml +++ b/Common/SettingsData.qml @@ -238,6 +238,7 @@ Singleton { property bool osdAlwaysShowValue: false property bool powerActionConfirm: true + property string customPowerActionLock: "" property string customPowerActionLogout: "" property string customPowerActionSuspend: "" property string customPowerActionHibernate: "" @@ -452,6 +453,7 @@ Singleton { notificationPopupPosition = settings.notificationPopupPosition !== undefined ? settings.notificationPopupPosition : SettingsData.Position.Top osdAlwaysShowValue = settings.osdAlwaysShowValue !== undefined ? settings.osdAlwaysShowValue : false powerActionConfirm = settings.powerActionConfirm !== undefined ? settings.powerActionConfirm : true + customPowerActionLock = settings.customPowerActionLock != undefined ? settings.customPowerActionLock : "" customPowerActionLogout = settings.customPowerActionLogout != undefined ? settings.customPowerActionLogout : "" customPowerActionSuspend = settings.customPowerActionSuspend != undefined ? settings.customPowerActionSuspend : "" customPowerActionHibernate = settings.customPowerActionHibernate != undefined ? settings.customPowerActionHibernate : "" @@ -646,6 +648,7 @@ Singleton { "notificationPopupPosition": notificationPopupPosition, "osdAlwaysShowValue": osdAlwaysShowValue, "powerActionConfirm": powerActionConfirm, + "customPowerActionLock": customPowerActionLock, "customPowerActionLogout": customPowerActionLogout, "customPowerActionSuspend": customPowerActionSuspend, "customPowerActionHibernate": customPowerActionHibernate, @@ -716,8 +719,8 @@ Singleton { "hideBrightnessSlider", "widgetBackgroundColor", "surfaceBase", "notificationTimeoutLow", "notificationTimeoutNormal", "notificationTimeoutCritical", "notificationPopupPosition", "osdAlwaysShowValue", "powerActionConfirm", - "customPowerActionLogout", "customPowerActionSuspend", "customPowerActionHibernate", - "customPowerActionReboot", "customPowerActionPowerOff", + "customPowerActionLock", "customPowerActionLogout", "customPowerActionSuspend", + "customPowerActionHibernate", "customPowerActionReboot", "customPowerActionPowerOff", "updaterUseCustomCommand", "updaterCustomCommand", "updaterTerminalAdditionalParams", "screenPreferences", "animationSpeed", "acMonitorTimeout", "acLockTimeout", "acSuspendTimeout", "acHibernateTimeout", "batteryMonitorTimeout", "batteryLockTimeout", @@ -1713,6 +1716,11 @@ Singleton { saveSettings(); } + function setCustomPowerActionLock(command) { + customPowerActionLock = command; + saveSettings(); + } + function setCustomPowerActionLogout(command) { customPowerActionLogout = command; saveSettings(); diff --git a/Modals/Settings/PowerSettings.qml b/Modals/Settings/PowerSettings.qml index 8c87fef2..075d93ff 100644 --- a/Modals/Settings/PowerSettings.qml +++ b/Modals/Settings/PowerSettings.qml @@ -391,6 +391,38 @@ Item { } } + Column { + width: parent.width + spacing: Theme.spacingXS + anchors.left: parent.left + + StyledText { + text: I18n.tr("Command or script to run instead of the standard lock procedure") + font.pixelSize: Theme.fontSizeSmall + color: Theme.surfaceVariantText + } + + DankTextField { + id: customLockCommand + width: parent.width + height: 48 + placeholderText: "/usr/bin/myLock.sh" + backgroundColor: Theme.surfaceVariant + normalBorderColor: Theme.primarySelected + focusedBorderColor: Theme.primary + + Component.onCompleted: { + if (SettingsData.customPowerActionLock) { + text = SettingsData.customPowerActionLock; + } + } + + onTextEdited: { + SettingsData.setCustomPowerActionLock(text.trim()); + } + } + } + Column { width: parent.width spacing: Theme.spacingXS diff --git a/Modules/Lock/Lock.qml b/Modules/Lock/Lock.qml index 9aa2d41a..74494d6a 100644 --- a/Modules/Lock/Lock.qml +++ b/Modules/Lock/Lock.qml @@ -19,6 +19,10 @@ Scope { } function lock() { + if (SettingsData.customPowerActionLock && SettingsData.customPowerActionLock.length > 0) { + Quickshell.execDetached(SettingsData.customPowerActionLock.split(" ")) + return + } if (!processingExternalEvent && SettingsData.loginctlLockIntegration && DMSService.isConnected) { DMSService.lockSession(response => { if (response.error) {