]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
firstboot: Populate XKBLAYOUT and friends as well in vconsole.conf 36275/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 5 Feb 2025 13:31:33 +0000 (14:31 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 7 Feb 2025 00:18:36 +0000 (09:18 +0900)
Let's derive XKBLAYOUT and friends from the given keymap and populate
these as well in vconsole.conf so that if the user configures a keymap
it's also respected in display managers such as gdm.

src/firstboot/firstboot.c

index bfd4bbe9fb2efd667e393f2627f29d370e1dc459..d00886fb808b81fab73233b848c5d92c7e7f02fc 100644 (file)
@@ -51,6 +51,7 @@
 #include "tmpfile-util.h"
 #include "umask-util.h"
 #include "user-util.h"
+#include "vconsole-util.h"
 
 static char *arg_root = NULL;
 static char *arg_image = NULL;
@@ -461,7 +462,7 @@ static int prompt_keymap(int rfd) {
 static int process_keymap(int rfd) {
         _cleanup_close_ int pfd = -EBADF;
         _cleanup_free_ char *f = NULL;
-        char **keymap;
+        _cleanup_strv_free_ char **keymap = NULL;
         int r;
 
         assert(rfd >= 0);
@@ -502,7 +503,18 @@ static int process_keymap(int rfd) {
         if (isempty(arg_keymap))
                 return 0;
 
-        keymap = STRV_MAKE(strjoina("KEYMAP=", arg_keymap));
+        VCContext vc = {
+                .keymap = arg_keymap,
+        };
+        _cleanup_(x11_context_clear) X11Context xc = {};
+
+        r = vconsole_convert_to_x11(&vc, /* verify= */ NULL, &xc);
+        if (r < 0)
+                return log_error_errno(r, "Failed to convert keymap data: %m");
+
+        r = vconsole_serialize(&vc, &xc, &keymap);
+        if (r < 0)
+                return log_error_errno(r, "Failed to serialize keymap data: %m");
 
         r = write_vconsole_conf(pfd, f, keymap);
         if (r < 0)