summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mpower
blob: 8886cfd9585a3a53321565078264c1f2498e2d61 (plain) (blame)
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
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
choice="$(
cat <<EOF | commander -c -w 1 -y 8
poweroff
suspend
reboot
firmware
hibernate
windows
EOF
)"

# Same on both
case "$choice" in
 "windows")
  doas efibootmgr --bootnext "$(efibootmgr -u | grep 'Windows' | grep '^Boot[0-9]\{4\}' | cut -c 5-8)"
  doas reboot
  exit
  ;;
 "firmware") rebootfw; exit ;;
esac

# Winter
if [ "$(hostname)" = "winter" ]; then 
 case "$choice" in
  "suspend") systemctl hybrid-sleep ;;
  "") exit 1 ;;
  *) systemctl "$choice" ;;
 esac
# Spring
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 ;;
  "windows")
   ;;
		"") exit 1 ;;
		*) ;;
	esac 
fi