From f6531b11d21931b3952d566ceded672ba21681cc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 21 Aug 2023 22:59:53 +0200 Subject: [PATCH 1/3] boot: add hotkeys for rebooting/powering off the system from the boot menu In a an environment with a serial console it's just too useful to directly reboot/power off the machine without any further tooling. --- man/systemd-boot.xml | 10 ++++++++++ src/boot/efi/boot.c | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/man/systemd-boot.xml b/man/systemd-boot.xml index 30908e398a..56044281d4 100644 --- a/man/systemd-boot.xml +++ b/man/systemd-boot.xml @@ -192,6 +192,16 @@ may also be reached with F2, F10, Del and Esc. + + + Shifto + Power off the system. + + + + Shiftb + Reboot the system. + The following keys may be pressed during bootup or in the boot menu to directly boot a specific diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index b1c8814286..30272ce2dd 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -881,7 +881,7 @@ static bool menu_run( case KEYPRESS(0, 0, 'H'): case KEYPRESS(0, 0, '?'): /* This must stay below 80 characters! Q/v/Ctrl+l/f deliberately not advertised. */ - status = xstrdup16(u"(d)efault (t/T)timeout (e)dit (r/R)resolution (p)rint (h)elp"); + status = xstrdup16(u"(d)efault (t/T)imeout (e)dit (r/R)esolution (p)rint (O)ff re(B)oot (h)elp"); break; case KEYPRESS(0, 0, 'Q'): @@ -1008,6 +1008,14 @@ static bool menu_run( status = xstrdup16(u"Reboot into firmware interface not supported."); break; + case KEYPRESS(0, 0, 'O'): /* Only uppercase, so that it can't be hit so easily fat-fingered, but still works safely over serial */ + RT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL); + break; + + case KEYPRESS(0, 0, 'B'): /* ditto */ + RT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL); + break; + default: /* jump with a hotkey directly to a matching entry */ idx = entry_lookup_key(config, idx_highlight+1, KEYCHAR(key)); From 1b9af63f551ccc4848d25a3da257800cf34a2207 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 22 Aug 2023 11:28:10 +0200 Subject: [PATCH 2/3] boot: add control-less alias for Ctrl-l hotkey I couldn't get ctrl work properly over serial line/qemu. Hence, let's add an alias for Ctrl-l: a simple Shift-l (i.e. uppercase L) (Note that lowercase L will result in selection of the first Linux entry, hence we stay away from that) --- src/boot/efi/boot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 30272ce2dd..3704ee6846 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -963,6 +963,7 @@ static bool menu_run( case KEYPRESS(EFI_CONTROL_PRESSED, 0, 'l'): case KEYPRESS(EFI_CONTROL_PRESSED, 0, CHAR_CTRL('l')): + case 'L': /* only uppercase, do not conflict with lower-case 'l' which picks first Linux entry */ clear = true; break; From 321261c7d927071af50ac8ca2a7f20b4a1763102 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 21 Aug 2023 23:27:21 +0200 Subject: [PATCH 3/3] update TODO --- TODO | 2 -- 1 file changed, 2 deletions(-) diff --git a/TODO b/TODO index 2ba0666d4a..eda525dc44 100644 --- a/TODO +++ b/TODO @@ -949,8 +949,6 @@ Features: appropriate qemu cmdline. That way qemu payloads could talk sd_notify() directly to host service manager. -* sd-boot: add menu item for shutdown? or hotkey? - * sd-device has an API to create an sd_device object from a device id, but has no api to query the device id