summaryrefslogtreecommitdiff
path: root/bin/.bin/power.sh
blob: e17bae3edcf640736bb14a9414b4c1cf1c03850e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash
set -euo pipefail

declare -A actions
actions[Reboot]="systemctl reboot"
actions[Shutdown]="systemctl poweroff"

SELECTION=$(printf "Reboot\nShutdown" | rofi -dmenu -p "")

if [ -z "$SELECTION" ]; then
  exit 0
fi

if [ -z "${actions[$SELECTION]:-}" ]; then
  notify-send "ERROR" "Invalid choice: $SELECTION"
  exit 1
fi

notify-send "System" "Initiating $SELECTION..."
sleep 0.5

${actions[$SELECTION]}