From c3233fbf61162d84e099d7d76b8c429757ea7db3 Mon Sep 17 00:00:00 2001 From: bbedward Date: Fri, 5 Dec 2025 16:05:11 -0500 Subject: [PATCH] power menu: shorter hold durations --- quickshell/Common/SettingsData.qml | 2 +- quickshell/Common/settings/SettingsSpec.js | 2 +- quickshell/Modals/PowerMenuModal.qml | 12 ++++++--- quickshell/Modules/Lock/LockPowerMenu.qml | 12 ++++++--- quickshell/Modules/Settings/PowerSleepTab.qml | 26 ++++++++++++++----- 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/quickshell/Common/SettingsData.qml b/quickshell/Common/SettingsData.qml index c862f48c..63c94fb4 100644 --- a/quickshell/Common/SettingsData.qml +++ b/quickshell/Common/SettingsData.qml @@ -318,7 +318,7 @@ Singleton { property bool osdAudioOutputEnabled: true property bool powerActionConfirm: true - property int powerActionHoldDuration: 1 + property real powerActionHoldDuration: 0.5 property var powerMenuActions: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"] property string powerMenuDefaultAction: "logout" property bool powerMenuGridLayout: false diff --git a/quickshell/Common/settings/SettingsSpec.js b/quickshell/Common/settings/SettingsSpec.js index d25a8b4c..80f0b89c 100644 --- a/quickshell/Common/settings/SettingsSpec.js +++ b/quickshell/Common/settings/SettingsSpec.js @@ -217,7 +217,7 @@ var SPEC = { osdAudioOutputEnabled: { def: true }, powerActionConfirm: { def: true }, - powerActionHoldDuration: { def: 1 }, + powerActionHoldDuration: { def: 0.5 }, powerMenuActions: { def: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"] }, powerMenuDefaultAction: { def: "logout" }, powerMenuGridLayout: { def: false }, diff --git a/quickshell/Modals/PowerMenuModal.qml b/quickshell/Modals/PowerMenuModal.qml index 40802319..062dc818 100644 --- a/quickshell/Modals/PowerMenuModal.qml +++ b/quickshell/Modals/PowerMenuModal.qml @@ -787,12 +787,18 @@ DankModal { } StyledText { - readonly property int remainingSeconds: Math.ceil(SettingsData.powerActionHoldDuration * (1 - root.holdProgress)) + readonly property real totalMs: SettingsData.powerActionHoldDuration * 1000 + readonly property int remainingMs: Math.ceil(totalMs * (1 - root.holdProgress)) text: { if (root.showHoldHint) return I18n.tr("Hold longer to confirm"); - if (root.holdProgress > 0) - return I18n.tr("Hold to confirm (%1s)").arg(remainingSeconds); + if (root.holdProgress > 0) { + if (totalMs < 1000) + return I18n.tr("Hold to confirm (%1 ms)").arg(remainingMs); + return I18n.tr("Hold to confirm (%1s)").arg(Math.ceil(remainingMs / 1000)); + } + if (totalMs < 1000) + return I18n.tr("Hold to confirm (%1 ms)").arg(totalMs); return I18n.tr("Hold to confirm (%1s)").arg(SettingsData.powerActionHoldDuration); } font.pixelSize: Theme.fontSizeSmall diff --git a/quickshell/Modules/Lock/LockPowerMenu.qml b/quickshell/Modules/Lock/LockPowerMenu.qml index c6be049a..1694fd25 100644 --- a/quickshell/Modules/Lock/LockPowerMenu.qml +++ b/quickshell/Modules/Lock/LockPowerMenu.qml @@ -780,12 +780,18 @@ Rectangle { } StyledText { - readonly property int remainingSeconds: Math.ceil(SettingsData.powerActionHoldDuration * (1 - root.holdProgress)) + readonly property real totalMs: SettingsData.powerActionHoldDuration * 1000 + readonly property int remainingMs: Math.ceil(totalMs * (1 - root.holdProgress)) text: { if (root.showHoldHint) return I18n.tr("Hold longer to confirm"); - if (root.holdProgress > 0) - return I18n.tr("Hold to confirm (%1s)").arg(remainingSeconds); + if (root.holdProgress > 0) { + if (totalMs < 1000) + return I18n.tr("Hold to confirm (%1 ms)").arg(remainingMs); + return I18n.tr("Hold to confirm (%1s)").arg(Math.ceil(remainingMs / 1000)); + } + if (totalMs < 1000) + return I18n.tr("Hold to confirm (%1 ms)").arg(totalMs); return I18n.tr("Hold to confirm (%1s)").arg(SettingsData.powerActionHoldDuration); } font.pixelSize: Theme.fontSizeSmall diff --git a/quickshell/Modules/Settings/PowerSleepTab.qml b/quickshell/Modules/Settings/PowerSleepTab.qml index 68d973d1..da093077 100644 --- a/quickshell/Modules/Settings/PowerSleepTab.qml +++ b/quickshell/Modules/Settings/PowerSleepTab.qml @@ -408,15 +408,27 @@ Item { onToggled: checked => SettingsData.set("powerActionConfirm", checked) } - SettingsSliderRow { + SettingsDropdownRow { + id: holdDurationDropdown + property var durationOptions: ["250 ms", "500 ms", "750 ms", "1 second", "2 seconds", "3 seconds", "5 seconds", "10 seconds"] + property var durationValues: [0.25, 0.5, 0.75, 1, 2, 3, 5, 10] + text: I18n.tr("Hold Duration") - description: I18n.tr("How long to hold the button to confirm the action") - minimum: 1 - maximum: 10 - unit: "s" + options: durationOptions visible: SettingsData.powerActionConfirm - value: SettingsData.powerActionHoldDuration - onSliderValueChanged: newValue => SettingsData.set("powerActionHoldDuration", newValue) + + Component.onCompleted: { + const currentDuration = SettingsData.powerActionHoldDuration; + const index = durationValues.indexOf(currentDuration); + currentValue = index >= 0 ? durationOptions[index] : "500 ms"; + } + + onValueChanged: value => { + const index = durationOptions.indexOf(value); + if (index < 0) + return; + SettingsData.set("powerActionHoldDuration", durationValues[index]); + } } }