diff options
| author | Tim Hämisch <tim@thaemisch.net> | 2025-06-13 18:04:45 +0200 |
|---|---|---|
| committer | Tim Hämisch <tim@thaemisch.net> | 2025-06-13 18:04:45 +0200 |
| commit | 0bcee304e5170214cb85aa2236c81299d01ab792 (patch) | |
| tree | 119cc073d119440e0164ec3cd01c6793c39f35dd /modules/launcher/Actions.qml | |
| parent | Merge branch 'caelestia-dots:main' into betteractions (diff) | |
| download | caelestia-shell-0bcee304e5170214cb85aa2236c81299d01ab792.tar.gz caelestia-shell-0bcee304e5170214cb85aa2236c81299d01ab792.tar.bz2 caelestia-shell-0bcee304e5170214cb85aa2236c81299d01ab792.zip | |
launcher: add opt-in for dangerous actions
Diffstat (limited to 'modules/launcher/Actions.qml')
| -rw-r--r-- | modules/launcher/Actions.qml | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/modules/launcher/Actions.qml b/modules/launcher/Actions.qml index 4d74e05..47607c3 100644 --- a/modules/launcher/Actions.qml +++ b/modules/launcher/Actions.qml @@ -71,30 +71,33 @@ Singleton { name: qsTr("Shutdown") desc: qsTr("Shutdown the system") icon: "power_settings_new" + disabled: !LauncherConfig.allowDangerousActions + disabledReason: qsTr("Enable dangerous actions in config/LauncherConfig.qml first") function onClicked(list: AppList): void { - list.visibilities.launcher = false; - shutdown.running = true; + root.handleDangerousAction(list, shutdown); } }, Action { name: qsTr("Reboot") desc: qsTr("Reboot the system") icon: "cached" + disabled: !LauncherConfig.allowDangerousActions + disabledReason: qsTr("Enable dangerous actions in config/LauncherConfig.qml first") function onClicked(list: AppList): void { - list.visibilities.launcher = false; - reboot.running = true; + root.handleDangerousAction(list, reboot); } }, Action { name: qsTr("Logout") desc: qsTr("Logout of the current session") - icon: "logout" + icon: "exit_to_app" + disabled: !LauncherConfig.allowDangerousActions + disabledReason: qsTr("Enable dangerous actions in config/LauncherConfig.qml first") function onClicked(list: AppList): void { - list.visibilities.launcher = false; - logout.running = true; + root.handleDangerousAction(list, logout); } }, Action { @@ -137,6 +140,21 @@ Singleton { list.search.text = `${LauncherConfig.actionPrefix}${text} `; } + function handleDangerousAction(list: AppList, process: QtObject): void { + list.visibilities.launcher = false; + if (!LauncherConfig.allowDangerousActions) { + dangerousActions.running = true; + return; + } + process.running = true; + } + + Process { + id: dangerousActions + + command: ["notify-send", "Quickshell", qsTr("Enable dangerous actions in config/LauncherConfig.qml to use this action."), "-i", "dialog-warning"] + } + Process { id: shutdown @@ -152,8 +170,8 @@ Singleton { Process { id: logout - command: ["sh", "-c", "(uwsm stop | grep -q 'Compositor is not running' && loginctl terminate-user $USER) || uwsm stop"] - } + command: ["hyprctl", "dispatch", "exit", "1"] + } Process { id: lock @@ -171,6 +189,8 @@ Singleton { required property string name required property string desc required property string icon + property bool disabled + property string disabledReason function onClicked(list: AppList): void { } |