Skip to content

Commit

Permalink
zfsbootmenu: add modal power menu on main screen
Browse files Browse the repository at this point in the history
  • Loading branch information
classabbyamp committed Mar 18, 2024
1 parent 7436b1b commit 59ac317
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
4 changes: 4 additions & 0 deletions docs/online/main-screen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ Keyboard Shortcuts
*[MOD+L]* **view logs**

View logs, as indicated by *[!]*. The indicator will be yellow for warning conditions and red for errors.

*[MOD+X]* **power menu**

Show menu with options to shutdown, reboot, or reboot to UEFI firmware setup (if available).
3 changes: 3 additions & 0 deletions zfsbootmenu/bin/zfsbootmenu
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,8 @@ while true; do
"mod-o")
change_sort
;;
"mod-x")
/libexec/zpowermenu
;;
esac
done
8 changes: 4 additions & 4 deletions zfsbootmenu/lib/zfsbootmenu-ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ draw_be() {
fi

header="$( column_wrap "\
^[RETURN] boot:[ESCAPE] refresh view:[CTRL+P] pool status
^[CTRL+D] set bootfs:[CTRL+S] snapshots:[CTRL+K] kernels
^[CTRL+E] edit kcl:[CTRL+J] jump into chroot:[CTRL+R] recovery shell
^[RETURN] boot:[CTRL+K] kernels:[CTRL+P] pool status
^[CTRL+D] set bootfs:[CTRL+R] recovery shell:[CTRL+S] snapshots
^[CTRL+E] edit kcl:[CTRL+J] jump into chroot:[CTRL+X] power menu
^${kcl_text:+${kcl_text}:}[CTRL+L] view logs:${blank}[CTRL+H] help" \
"\
^[RETURN] boot
Expand All @@ -160,7 +160,7 @@ draw_be() {
sort_key="$( get_sort_key )"
preview_label="Sorted by: ${sort_key^}"

expects="--expect=alt-e,alt-k,alt-d,alt-s,alt-c,alt-r,alt-p,alt-w,alt-j,alt-o${kcl_bind:+,${kcl_bind}},right"
expects="--expect=alt-e,alt-k,alt-d,alt-s,alt-c,alt-r,alt-p,alt-w,alt-j,alt-o,alt-x${kcl_bind:+,${kcl_bind}},right"

# shellcheck disable=SC2086
if ! selected="$( ${FUZZYSEL} -0 --prompt "BE > " \
Expand Down
14 changes: 14 additions & 0 deletions zfsbootmenu/libexec/zpowermenu
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# vim: softtabstop=2 shiftwidth=2 expandtab

source /lib/efi-firmware-lib.sh >/dev/null 2>&1 || exit 1
source /lib/zfsbootmenu-ui.sh >/dev/null 2>&1 || exit 1

PROMPT=("/bin/poweroff:Shutdown" "/bin/reboot:Reboot")
if check_fw_setup; then
PROMPT+=("/bin/firmware-setup:Reboot to UEFI Firmware")
fi

if execute="$(draw_modal_prompt "Power Menu" "${PROMPT[@]}")" && [ -x "$execute" ]; then
exec "$execute"
fi

0 comments on commit 59ac317

Please sign in to comment.