From 4750a7553bd2e8b9fc20d720a2fbc433886e910b Mon Sep 17 00:00:00 2001 From: purian23 Date: Wed, 25 Feb 2026 14:33:09 -0500 Subject: [PATCH] feat: Add independent power action confirmation settings for dms greeter --- quickshell/Common/SettingsData.qml | 1 + quickshell/Common/settings/SettingsSpec.js | 1 + quickshell/Modules/Greetd/GreetdSettings.qml | 4 ++++ quickshell/Modules/Greetd/GreeterContent.qml | 3 +++ quickshell/Modules/Lock/LockPowerMenu.qml | 13 ++++++---- quickshell/Modules/Settings/PowerSleepTab.qml | 24 ++++++++++++++++++- .../translations/settings_search_index.json | 20 ++++++++++++++++ 7 files changed, 61 insertions(+), 5 deletions(-) diff --git a/quickshell/Common/SettingsData.qml b/quickshell/Common/SettingsData.qml index edc3087d..7d74fba0 100644 --- a/quickshell/Common/SettingsData.qml +++ b/quickshell/Common/SettingsData.qml @@ -527,6 +527,7 @@ Singleton { property bool osdAudioOutputEnabled: true property bool powerActionConfirm: true + property bool powerActionConfirmGreeter: true property real powerActionHoldDuration: 0.5 property var powerMenuActions: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"] property string powerMenuDefaultAction: "logout" diff --git a/quickshell/Common/settings/SettingsSpec.js b/quickshell/Common/settings/SettingsSpec.js index d347e271..1d983664 100644 --- a/quickshell/Common/settings/SettingsSpec.js +++ b/quickshell/Common/settings/SettingsSpec.js @@ -350,6 +350,7 @@ var SPEC = { osdAudioOutputEnabled: { def: true }, powerActionConfirm: { def: true }, + powerActionConfirmGreeter: { def: true }, powerActionHoldDuration: { def: 0.5 }, powerMenuActions: { def: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"] }, powerMenuDefaultAction: { def: "logout" }, diff --git a/quickshell/Modules/Greetd/GreetdSettings.qml b/quickshell/Modules/Greetd/GreetdSettings.qml index 01020ce1..e29fbb2b 100644 --- a/quickshell/Modules/Greetd/GreetdSettings.qml +++ b/quickshell/Modules/Greetd/GreetdSettings.qml @@ -41,6 +41,8 @@ Singleton { property string lockDateFormat: "" property bool lockScreenShowPowerActions: true property bool lockScreenShowProfileImage: true + property bool powerActionConfirmGreeter: true + property real powerActionHoldDuration: 0.5 property var screenPreferences: ({}) property int animationSpeed: 2 property string wallpaperFillMode: "Fill" @@ -75,6 +77,8 @@ Singleton { lockDateFormat = settings.lockDateFormat !== undefined ? settings.lockDateFormat : ""; lockScreenShowPowerActions = settings.lockScreenShowPowerActions !== undefined ? settings.lockScreenShowPowerActions : true; lockScreenShowProfileImage = settings.lockScreenShowProfileImage !== undefined ? settings.lockScreenShowProfileImage : true; + powerActionConfirmGreeter = settings.powerActionConfirmGreeter !== undefined ? settings.powerActionConfirmGreeter : true; + powerActionHoldDuration = settings.powerActionHoldDuration !== undefined ? settings.powerActionHoldDuration : 0.5; screenPreferences = settings.screenPreferences !== undefined ? settings.screenPreferences : ({}); animationSpeed = settings.animationSpeed !== undefined ? settings.animationSpeed : 2; wallpaperFillMode = settings.wallpaperFillMode !== undefined ? settings.wallpaperFillMode : "Fill"; diff --git a/quickshell/Modules/Greetd/GreeterContent.qml b/quickshell/Modules/Greetd/GreeterContent.qml index e0ebbd47..e491b729 100644 --- a/quickshell/Modules/Greetd/GreeterContent.qml +++ b/quickshell/Modules/Greetd/GreeterContent.qml @@ -1231,6 +1231,9 @@ Item { LockPowerMenu { id: powerMenu showLogout: false + useGreeterPowerSettings: true + greeterPowerActionConfirm: GreetdSettings.powerActionConfirmGreeter + greeterPowerActionHoldDuration: GreetdSettings.powerActionHoldDuration onClosed: { if (isPrimaryScreen && inputField && inputField.forceActiveFocus) { Qt.callLater(() => inputField.forceActiveFocus()); diff --git a/quickshell/Modules/Lock/LockPowerMenu.qml b/quickshell/Modules/Lock/LockPowerMenu.qml index 1694fd25..a9ad89e7 100644 --- a/quickshell/Modules/Lock/LockPowerMenu.qml +++ b/quickshell/Modules/Lock/LockPowerMenu.qml @@ -24,8 +24,12 @@ Rectangle { property real holdProgress: 0 property bool showHoldHint: false - readonly property bool needsConfirmation: SettingsData.powerActionConfirm - readonly property int holdDurationMs: SettingsData.powerActionHoldDuration * 1000 + property bool useGreeterPowerSettings: false + property bool greeterPowerActionConfirm: true + property real greeterPowerActionHoldDuration: 0.5 + + readonly property bool needsConfirmation: useGreeterPowerSettings ? greeterPowerActionConfirm : (typeof SettingsData !== "undefined" && SettingsData.powerActionConfirm) + readonly property int holdDurationMs: useGreeterPowerSettings ? (greeterPowerActionHoldDuration * 1000) : ((typeof SettingsData !== "undefined" ? SettingsData.powerActionHoldDuration : 0.5) * 1000) signal closed @@ -780,8 +784,9 @@ Rectangle { } StyledText { - readonly property real totalMs: SettingsData.powerActionHoldDuration * 1000 + readonly property real totalMs: root.holdDurationMs readonly property int remainingMs: Math.ceil(totalMs * (1 - root.holdProgress)) + readonly property real durationSec: root.holdDurationMs / 1000 text: { if (root.showHoldHint) return I18n.tr("Hold longer to confirm"); @@ -792,7 +797,7 @@ Rectangle { } if (totalMs < 1000) return I18n.tr("Hold to confirm (%1 ms)").arg(totalMs); - return I18n.tr("Hold to confirm (%1s)").arg(SettingsData.powerActionHoldDuration); + return I18n.tr("Hold to confirm (%1s)").arg(durationSec); } font.pixelSize: Theme.fontSizeSmall color: root.showHoldHint ? Theme.warning : Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6) diff --git a/quickshell/Modules/Settings/PowerSleepTab.qml b/quickshell/Modules/Settings/PowerSleepTab.qml index 7282d342..2914479d 100644 --- a/quickshell/Modules/Settings/PowerSleepTab.qml +++ b/quickshell/Modules/Settings/PowerSleepTab.qml @@ -1,4 +1,5 @@ import QtQuick +import Quickshell.Io import qs.Common import qs.Services import qs.Widgets @@ -7,6 +8,17 @@ import qs.Modules.Settings.Widgets Item { id: root + property bool greeterInstalled: false + + Process { + id: greeterCheck + command: ["sh", "-c", "command -v dms-greeter 2>/dev/null || [ -f /usr/share/quickshell/dms-greeter/shell.qml ]"] + running: false + onExited: exitCode => root.greeterInstalled = exitCode === 0 + } + + Component.onCompleted: greeterCheck.running = true + readonly property var timeoutOptions: [I18n.tr("Never"), I18n.tr("1 minute"), I18n.tr("2 minutes"), I18n.tr("3 minutes"), I18n.tr("5 minutes"), I18n.tr("10 minutes"), I18n.tr("15 minutes"), I18n.tr("20 minutes"), I18n.tr("30 minutes"), I18n.tr("1 hour"), I18n.tr("1 hour 30 minutes"), I18n.tr("2 hours"), I18n.tr("3 hours")] readonly property var timeoutValues: [0, 60, 120, 180, 300, 600, 900, 1200, 1800, 3600, 5400, 7200, 10800] @@ -475,6 +487,16 @@ Item { onToggled: checked => SettingsData.set("powerActionConfirm", checked) } + SettingsToggleRow { + settingKey: "powerActionConfirmGreeter" + tags: ["power", "confirm", "hold", "greeter", "login", "screen"] + text: I18n.tr("Hold to Confirm Power Actions on the Login Screen") + description: I18n.tr("Require holding to confirm power off, restart, suspend and hibernate on the DMS Greeter login screen") + checked: SettingsData.powerActionConfirmGreeter + visible: root.greeterInstalled + onToggled: checked => SettingsData.set("powerActionConfirmGreeter", checked) + } + SettingsDropdownRow { id: holdDurationDropdown settingKey: "powerActionHoldDuration" @@ -484,7 +506,7 @@ Item { text: I18n.tr("Hold Duration") options: durationOptions - visible: SettingsData.powerActionConfirm + visible: SettingsData.powerActionConfirm || SettingsData.powerActionConfirmGreeter Component.onCompleted: { const currentDuration = SettingsData.powerActionHoldDuration; diff --git a/quickshell/translations/settings_search_index.json b/quickshell/translations/settings_search_index.json index f3820ff4..cdf2411f 100644 --- a/quickshell/translations/settings_search_index.json +++ b/quickshell/translations/settings_search_index.json @@ -5776,6 +5776,26 @@ ], "description": "Require holding button/key to confirm power off, restart, suspend, hibernate and logout" }, + { + "section": "powerActionConfirmGreeter", + "label": "Hold to confirm on login screen", + "tabIndex": 21, + "category": "Power & Sleep", + "keywords": [ + "confirm", + "greeter", + "hold", + "holding", + "login", + "power", + "reboot", + "restart", + "screen", + "shutdown", + "suspend" + ], + "description": "Require holding to confirm power off, restart, suspend and hibernate on the greetd login screen" + }, { "section": "idleSettings", "label": "Idle Settings",