From a7d9da8dda105cdc1a6430cb79dd6f3d4a9c08fb Mon Sep 17 00:00:00 2001 From: coolneng Date: Sat, 3 Jul 2021 17:37:55 +0200 Subject: [PATCH] Convert power menu into a rofi selection screen --- scripts/.local/share/scripts/power-menu | 21 +++++++++++++++++++++ sway/.config/sway/config | 12 +----------- 2 files changed, 22 insertions(+), 11 deletions(-) create mode 100755 scripts/.local/share/scripts/power-menu diff --git a/scripts/.local/share/scripts/power-menu b/scripts/.local/share/scripts/power-menu new file mode 100755 index 0000000..ca968ee --- /dev/null +++ b/scripts/.local/share/scripts/power-menu @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +select_action() { + action_content=( + "Shutdown" + "Reboot" + "Suspend" + ) + action=$(printf '%s\n' "${action_content[@]}" | rofi -no-auto-select -i "$@" -dmenu -p "Choose an action") + execute_action "$action" +} + +execute_action() { + case "$1" in + "Shutdown") ~/.local/share/scripts/power-manager "poweroff" ;; + "Reboot") ~/.local/share/scripts/power-manager "reboot" ;; + "Suspend") systemctl suspend -i ;; + esac +} + +select_action "$@" diff --git a/sway/.config/sway/config b/sway/.config/sway/config index 85a0651..a85b0db 100644 --- a/sway/.config/sway/config +++ b/sway/.config/sway/config @@ -286,17 +286,7 @@ bindsym $mod+p exec ~/.local/share/scripts/popup-window # tmuxp session menu bindsym $mod+Shift+s exec ~/.local/share/scripts/tmuxp-session # power menu -bindsym $mod+Shift+p mode "$Pause-break" - -set $Pause-break (p) poweroff, (r) reboot - -mode "$Pause-break" { - bindsym s exec --no-startup-id ~/.local/share/scripts/power-manager "poweroff", mode "default" - bindsym r exec --no-startup-id ~/.local/share/scripts/power-manager "reboot", mode "default" - - bindsym Return mode "default" - bindsym Escape mode "default" -} +bindsym $mod+Shift+p exec ~/.local/share/scripts/power-menu # theme switcher menu bindsym $mod+Shift+t mode "$Theme-switch"