From: Daan De Meyer Date: Wed, 5 Feb 2025 13:31:33 +0000 (+0100) Subject: firstboot: Populate XKBLAYOUT and friends as well in vconsole.conf X-Git-Tag: v258-rc1~1401^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F36275%2Fhead;p=thirdparty%2Fsystemd.git firstboot: Populate XKBLAYOUT and friends as well in vconsole.conf 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. --- diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index bfd4bbe9fb2..d00886fb808 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -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)