summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/rofi-powermenu55
1 files changed, 27 insertions, 28 deletions
diff --git a/scripts/rofi-powermenu b/scripts/rofi-powermenu
index 67f7170..d7c2927 100755
--- a/scripts/rofi-powermenu
+++ b/scripts/rofi-powermenu
@@ -1,43 +1,42 @@
#!/usr/bin/env bash
power_args=$(printf '%b' ' Lock\nLogout\n Restart\n󰒲 Suspend\n󰋊 Hibernate\n󰚦 Shutdown' |
- rofi -dmenu -p "󰐥" -i -theme-str 'window {width: 12em; padding: 2px; height: 16em;}')
+ rofi -dmenu -p "󰐥" -i -theme-str 'window {width: 12em; padding: 2px; height: 16em;}')
_have_cmd() {
- command -v "$1" &>/dev/null
+ command -v "$1" &>/dev/null
}
case "$power_args" in
*Lock)
- if [[ -n "$NIRI_SOCKET" ]]; then
- niri msg action power-off-monitors
- _have_cmd swaylock && swaylock
- elif [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then
- hyprlock
- fi
- ;;
+ if [[ -n "$NIRI_SOCKET" ]]; then
+ _have_cmd swaylock && swaylock --daemonize && niri msg action power-off-monitors
+ elif [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then
+ hyprlock
+ fi
+ ;;
*Logout)
- if [[ -n "$NIRI_SOCKET" ]]; then
- niri msg action quit
- elif [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then
- hyprctl dispatch exit
- fi
- ;;
+ if [[ -n "$NIRI_SOCKET" ]]; then
+ niri msg action quit
+ elif [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then
+ hyprctl dispatch exit
+ fi
+ ;;
*Restart)
- systemctl reboot
- ;;
+ systemctl reboot
+ ;;
*Suspend)
- systemctl suspend
- ;;
+ _have_cmd swaylock && swaylock --daemonize && sleep 0.5 && niri msg action power-off-monitors && systemctl suspend
+ ;;
*Hibernate)
- systemctl hibernate
- ;;
+ systemctl hibernate
+ ;;
*Shutdown)
- if [[ -n "$NIRI_SOCKET" ]]; then
- systemctl poweroff
- elif [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then
- hyprctl dispatch killactive && sleep 0.1 && hyprctl dispatch killactive && sleep 0.1 && systemctl poweroff
- # hyprctl clients -j | jq -r '.[].pid' | xargs -r kill -9; systemctl poweroff
- fi
- ;;
+ if [[ -n "$NIRI_SOCKET" ]]; then
+ systemctl poweroff
+ elif [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then
+ hyprctl dispatch killactive && sleep 0.1 && hyprctl dispatch killactive && sleep 0.1 && systemctl poweroff
+ # hyprctl clients -j | jq -r '.[].pid' | xargs -r kill -9; systemctl poweroff
+ fi
+ ;;
esac