diff --git a/docs/online/main-screen.rst b/docs/online/main-screen.rst index 6358c1730..a7ec87e29 100644 --- a/docs/online/main-screen.rst +++ b/docs/online/main-screen.rst @@ -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). diff --git a/zfsbootmenu/bin/zfsbootmenu b/zfsbootmenu/bin/zfsbootmenu index 5792a7753..6b53ab0e2 100755 --- a/zfsbootmenu/bin/zfsbootmenu +++ b/zfsbootmenu/bin/zfsbootmenu @@ -282,5 +282,8 @@ while true; do "mod-o") change_sort ;; + "mod-x") + /libexec/zpowermenu + ;; esac done diff --git a/zfsbootmenu/lib/zfsbootmenu-ui.sh b/zfsbootmenu/lib/zfsbootmenu-ui.sh index 2f7e40fbe..60d344d2f 100755 --- a/zfsbootmenu/lib/zfsbootmenu-ui.sh +++ b/zfsbootmenu/lib/zfsbootmenu-ui.sh @@ -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 @@ -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 > " \ diff --git a/zfsbootmenu/libexec/zpowermenu b/zfsbootmenu/libexec/zpowermenu new file mode 100755 index 000000000..23b0b5ca0 --- /dev/null +++ b/zfsbootmenu/libexec/zpowermenu @@ -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