summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mpower
diff options
context:
space:
mode:
authorRaymaekers Luca <luca@spacehb.net>2025-10-12 15:34:44 +0200
committerRaymaekers Luca <luca@spacehb.net>2025-10-12 15:34:44 +0200
commit62879b384864bd656cea0ed08e2b54ebf00c9015 (patch)
treed6ffb09080d893b9df01aca793bb88e1a70d608b /bin/menuscripts/mpower
parent54fe02166f9c0a1eafd7c29bf597c0aaea8c048d (diff)
checkpoint
Diffstat (limited to 'bin/menuscripts/mpower')
-rwxr-xr-xbin/menuscripts/mpower27
1 files changed, 20 insertions, 7 deletions
diff --git a/bin/menuscripts/mpower b/bin/menuscripts/mpower
index 8886cfd..d96e09a 100755
--- a/bin/menuscripts/mpower
+++ b/bin/menuscripts/mpower
@@ -1,6 +1,11 @@
#!/bin/sh
-choice="$(
-cat <<EOF | commander -c -w 1 -y 8
+
+if [ "$1" ]
+then
+ choice="$1"
+else
+ choice="$(
+ cat <<EOF | commander -c -w 1 -y 8
poweroff
suspend
reboot
@@ -8,15 +13,23 @@ firmware
hibernate
windows
EOF
-)"
+ )"
+fi
+
+>&2 printf 'choice: %s\n' "$choice"
# 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
- ;;
+ NextBoot="$(efibootmgr -u | grep 'Windows' | grep '^Boot[0-9]\{4\}' | cut -c 5-8)"
+ expect -f - <<EOF
+set pw [exec pass show aluc]
+spawn doas efibootmgr --bootnext "$NextBoot" -u
+expect "password:"
+send "\$pw\r"
+expect eof
+EOF
+ choice="reboot" ;;
"firmware") rebootfw; exit ;;
esac