Skip to content

Commit 08dda60

Browse files
committed
zfsbootmenu: add modal power menu on main screen
1 parent 29fb17e commit 08dda60

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

docs/online/main-screen.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ Keyboard Shortcuts
6666
*[MOD+L]* **view logs**
6767

6868
View logs, as indicated by *[!]*. The indicator will be yellow for warning conditions and red for errors.
69+
70+
*[MOD+X]* **power menu**
71+
72+
Show menu with options to shutdown, reboot, or reboot to UEFI firmware setup (if available).

zfsbootmenu/bin/zfsbootmenu

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,5 +282,8 @@ while true; do
282282
"mod-o")
283283
change_sort
284284
;;
285+
"mod-x")
286+
/libexec/zpowermenu
287+
;;
285288
esac
286289
done

zfsbootmenu/lib/zfsbootmenu-ui.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ draw_be() {
148148
fi
149149

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

163-
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"
163+
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"
164164

165165
# shellcheck disable=SC2086
166166
if ! selected="$( ${FUZZYSEL} -0 --prompt "BE > " \

zfsbootmenu/libexec/zpowermenu

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
# vim: softtabstop=2 shiftwidth=2 expandtab
3+
4+
source /lib/efi-firmware-lib.sh >/dev/null 2>&1 || exit 1
5+
source /lib/zfsbootmenu-ui.sh >/dev/null 2>&1 || exit 1
6+
7+
PROMPT=("/bin/poweroff:Shutdown" "/bin/reboot:Reboot")
8+
if check_fw_setup; then
9+
PROMPT+=("/bin/firmware-setup:Reboot to UEFI Firmware")
10+
fi
11+
12+
if execute="$(draw_modal_prompt "Power Menu" "${PROMPT[@]}")" && [ -x "$execute" ]; then
13+
exec "$execute"
14+
fi

0 commit comments

Comments
 (0)