diff options
| author | ryukamish <[email protected]> | 2026-04-27 21:53:37 +0530 |
|---|---|---|
| committer | ryukamish <[email protected]> | 2026-04-27 21:53:37 +0530 |
| commit | b49ad049acdc6f4f19d4db1268ad417663b9873e (patch) | |
| tree | 4cb9df021fa46f26e7f3c49dbe5a0ecb83a65e29 | |
| parent | b98814569dfaff9f04fe5a5e45592068482710e3 (diff) | |
fix: proper working powermenu
| -rwxr-xr-x | scripts/rofi-powermenu | 55 |
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 |
