diff options
| author | ryukamish <[email protected]> | 2026-04-11 18:25:38 +0530 |
|---|---|---|
| committer | ryukamish <[email protected]> | 2026-04-11 18:25:38 +0530 |
| commit | b3474e85dcce03e7de0b4a4e30ff7fad1f38ee26 (patch) | |
| tree | bcfe42ad76a825c283eec653140ab4052f0b3017 /scripts/rofi-powermenu | |
| parent | 607891801fbf2051a0c9062d15a445dd238c1e1b (diff) | |
add: small bash scripts for added functionality
Diffstat (limited to 'scripts/rofi-powermenu')
| -rwxr-xr-x | scripts/rofi-powermenu | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/rofi-powermenu b/scripts/rofi-powermenu new file mode 100755 index 0000000..6209944 --- /dev/null +++ b/scripts/rofi-powermenu @@ -0,0 +1,38 @@ +#!/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;}') + +case "$power_args" in +*Lock) + if [[ "$XDG_CURRENT_DESKTOP" == "niri" ]]; then + command -v swaylock &>/dev/null && swaylock + elif [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then + hyprlock + fi + ;; +*Logout) + if [[ "$XDG_CURRENT_DESKTOP" == "niri" ]]; then + niri msg action quit + elif [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then + hyprctl dispatch exit + fi + ;; +*Restart) + systemctl reboot + ;; +*Suspend) + systemctl suspend + ;; +*Hibernate) + systemctl hibernate + ;; +*Shutdown) + if [[ "$XDG_CURRENT_DESKTOP" == "niri" ]]; 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 |
