From ef7f5baae8224960f78651e8a3cf4c1f1b870a31 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Thu, 3 Aug 2023 21:42:00 +0800 Subject: [PATCH] vconsole: support KEYMAP=kernel for preserving kernel keymap Follow-up for #26089 and #28505 Currently, if default-keymap is not empty, there's no way to ask vconsole-setup to retain the kernel keymap. Let's accept a special value "kernel" for that purpose. Addresses the problem mentioned in https://github.com/systemd/systemd/pull/28505#issuecomment-1663681665 --- man/vconsole.conf.xml | 7 ++++--- meson.build | 5 +++++ src/vconsole/vconsole-setup.c | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/man/vconsole.conf.xml b/man/vconsole.conf.xml index b03a3de040..667105109b 100644 --- a/man/vconsole.conf.xml +++ b/man/vconsole.conf.xml @@ -75,9 +75,10 @@ KEYMAP_TOGGLE= Configures the key mapping table for the keyboard. - KEYMAP= defaults to &DEFAULT_KEYMAP; if not set. The - KEYMAP_TOGGLE= can be used to configure a second toggle keymap and is by - default unset. + KEYMAP= defaults to &DEFAULT_KEYMAP; if not set. Specially, + if kernel is specified, no keymap will be loaded, i.e. the kernel keymap is used. + The KEYMAP_TOGGLE= can be used to configure a second toggle keymap and is by default + unset. diff --git a/meson.build b/meson.build index 9d10d76d9f..0e1eecfd20 100644 --- a/meson.build +++ b/meson.build @@ -947,6 +947,11 @@ nspawn_locale = get_option('nspawn-locale') conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale) default_keymap = get_option('default-keymap') +if default_keymap == '' + # We canonicalize empty keymap to 'kernel', as it makes the default value + # in the factory provided /etc/vconsole.conf more obvious. + default_keymap = 'kernel' +endif conf.set_quoted('SYSTEMD_DEFAULT_KEYMAP', default_keymap) localegen_path = get_option('localegen-path') diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c index dd6e884335..921e587e94 100644 --- a/src/vconsole/vconsole-setup.c +++ b/src/vconsole/vconsole-setup.c @@ -281,7 +281,7 @@ static int keyboard_load_and_wait(const char *vc, Context *c, bool utf8) { map_toggle = context_get_config(c, VC_KEYMAP_TOGGLE); /* An empty map means kernel map */ - if (isempty(map)) + if (isempty(map) || streq(map, "kernel")) return 0; args[i++] = KBD_LOADKEYS;