1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-22 06:50:18 +03:00

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.
This commit is contained in:
Daan De Meyer 2025-02-05 14:31:33 +01:00 committed by Yu Watanabe
parent c4b4d42cae
commit 8a008fa792

View 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)