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 20, 2024
1 parent 29fb17e commit 08dda60
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 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
10 changes: 5 additions & 5 deletions zfsbootmenu/lib/zfsbootmenu-ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ 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
^${kcl_text:+${kcl_text}:}[CTRL+L] view logs:${blank}[CTRL+H] help" \
^[RETURN] boot:[CTRL+K] kernels:[CTRL+P] pool status
^[CTRL+D] set bootfs:[CTRL+J] jump into chroot:[CTRL+L] view logs
^[CTRL+S] snapshots:[CTRL+R] recovery shell:[CTRL+X] power menu
^[CTRL+E] edit kcl${kcl_text:+:${kcl_text}}:${blank}[CTRL+H] help" \
"\
^[RETURN] boot
^[CTRL+R] recovery shell
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 08dda60

Please sign in to comment.