summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mpower
blob: 8cbf1d07fe415ea6f5898d959124a7fa1a48a380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
choice="$(
cat <<EOF | commander -c -w 1 -y 7
poweroff
suspend
reboot
firmware
hibernate
EOF
)"

if [ "$(hostname)" = "winter" ]; then 
	if [ "$choice" = "firmware" ]; then
		systemctl reboot --firmware-setup
	elif [ "$choice" = "suspend" ]; then
		systemctl hybrid-sleep
	else
		systemctl "$choice"
	fi
elif [ "$(hostname)" = "spring" ]; then
	case "$choice" in
		"suspend") doas /usr/sbin/zzz -H ;;
		"hibernate") doas /usr/sbin/zzz -Z ;;
		"poweroff") doas /usr/sbin/poweroff ;;
		"reboot") doas /usr/sbin/reboot ;;
		"firmware") rebootfw ;;
		"") exit 1 ;;
		*) ;;
	esac 
fi