diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/menuscripts/mpower | 27 |
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 |
