Files
infra/dotfiles/desktop/.local/bin/powermenu
2026-04-17 12:15:41 +02:00

43 lines
803 B
Bash

#!/bin/sh
set -eu
choice="$(printf 'Shutdown\nReboot\nLogout\nLock\nSuspend' \
| rofi -dmenu \
-i \
-p 'Power' \
-theme ~/.config/rofi/config.rasi \
-theme-str 'window { width: 20%; location: center; anchor: center; } listview { columns: 1; spacing: 6px; }')"
[ -n "$choice" ] || exit 0
case "$choice" in
Lock)
"$HOME/.local/bin/lock-session"
;;
Logout)
case "${XDG_CURRENT_DESKTOP:-}" in
*sway*|*Sway*)
swaymsg exit
;;
*i3*|*I3*)
i3-msg exit
;;
*)
printf '%s\n' 'Unsupported desktop session for logout.' >&2
exit 1
;;
esac
;;
Suspend)
"$HOME/.local/bin/lock-session" || true
loginctl suspend
;;
Reboot)
loginctl reboot
;;
Shutdown)
loginctl poweroff
;;
esac