]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
vconsole: support KEYMAP=kernel for preserving kernel keymap
authorMike Yuan <me@yhndnzj.com>
Thu, 3 Aug 2023 13:42:00 +0000 (21:42 +0800)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 3 Aug 2023 17:20:39 +0000 (02:20 +0900)
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
meson.build
src/vconsole/vconsole-setup.c

index b03a3de04076317a58a5fbb3d7eaf4d2927dfa7d..667105109b1944be10407653281d9a0b5e395704 100644 (file)
         <term><varname>KEYMAP_TOGGLE=</varname></term>
 
         <listitem><para>Configures the key mapping table for the keyboard.
-        <varname>KEYMAP=</varname> defaults to <literal>&DEFAULT_KEYMAP;</literal> if not set. The
-        <varname>KEYMAP_TOGGLE=</varname> can be used to configure a second toggle keymap and is by
-        default unset.</para></listitem>
+        <varname>KEYMAP=</varname> defaults to <literal>&DEFAULT_KEYMAP;</literal> if not set. Specially,
+        if <literal>kernel</literal> is specified, no keymap will be loaded, i.e. the kernel keymap is used.
+        The <varname>KEYMAP_TOGGLE=</varname> can be used to configure a second toggle keymap and is by default
+        unset.</para></listitem>
       </varlistentry>
 
       <varlistentry>
index 9d10d76d9f9f151dab0643e4ded2301c369b8c08..0e1eecfd2093a621a34d7977ce4e6178b3b174e4 100644 (file)
@@ -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')
index dd6e884335b6d5aed6a448fc38165051a9b9252b..921e587e948ad20350e01931eccb488b79997408 100644 (file)
@@ -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;