Add "reboot to MacOS" option in lock.sh when detected

This commit is contained in:
Adam Goldsmith 2024-06-10 15:23:47 -04:00
parent a80e42d85f
commit 0738f48d8f

View File

@ -43,6 +43,9 @@ case "$1" in
"reboot to Windows") "reboot to Windows")
sudo refind-next-boot 'Microsoft' && systemctl reboot sudo refind-next-boot 'Microsoft' && systemctl reboot
;; ;;
"reboot to MacOS")
sudo refind-next-boot 'macOS' && systemctl reboot
;;
shutdown) shutdown)
systemctl poweroff systemctl poweroff
;; ;;
@ -51,10 +54,15 @@ case "$1" in
then then
extra_reboot_options="reboot to Windows\n" extra_reboot_options="reboot to Windows\n"
fi fi
if jc efibootmgr | jq -e '.boot_options|any(.display_name == "Mac OS X")'
then
extra_reboot_options="${extra_reboot_options}reboot to MacOS\n"
fi
$0 "$(echo -e 'lock\nlogout\nsuspend\nhibernate\nreboot\n'"${extra_reboot_options}shutdown" | rofi -dmenu -i)" $0 "$(echo -e 'lock\nlogout\nsuspend\nhibernate\nreboot\n'"${extra_reboot_options}shutdown" | rofi -dmenu -i)"
;; ;;
*) *)
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|reboot to Windows|shutdown|pick}" echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|reboot to MacOS|shutdown|pick}"
exit 2 exit 2
;; ;;
esac esac