default keymap directories (/usr/share/keymaps/, /usr/share/kbd/keymaps/, and
/usr/lib/kbd/keymaps/) will be used.
+* `$SYSTEMD_XKB_DIRECTORY=` — The directory must be absolute and normalized.
+ If unset, the default XKB directory (/usr/share/X11/xkb) will be used.
+
`systemd-resolved`:
* `$SYSTEMD_RESOLVED_SYNTHESIZE_HOSTNAME` — if set to "0", `systemd-resolved`
#include "memory-util.h"
#include "pager.h"
#include "parse-argument.h"
+#include "path-util.h"
#include "polkit-agent.h"
#include "pretty-print.h"
#include "runtime-scope.h"
return 0;
}
+static const char* xkb_directory(void) {
+ static const char *cached = NULL;
+
+ if (!cached)
+ cached = secure_getenv("SYSTEMD_XKB_DIRECTORY") ?: "/usr/share/X11/xkb";
+ return cached;
+}
+
static int list_x11_keymaps(int argc, char **argv, void *userdata) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_strv_free_ char **list = NULL;
} state = NONE, look_for;
int r;
- f = fopen("/usr/share/X11/xkb/rules/base.lst", "re");
+ _cleanup_free_ char *xkb_base = path_join(xkb_directory(), "rules/base.lst");
+ if (!xkb_base)
+ return log_oom();
+
+ f = fopen(xkb_base, "re");
if (!f)
- return log_error_errno(errno, "Failed to open keyboard mapping list: %m");
+ return log_error_errno(errno,
+ "Failed to open keyboard mapping list %s: %m",
+ xkb_base);
if (streq(argv[0], "list-x11-keymap-models"))
look_for = MODELS;
r = read_stripped_line(f, LONG_LINE_MAX, &line);
if (r < 0)
- return log_error_errno(r, "Failed to read keyboard mapping list: %m");
+ return log_error_errno(r,
+ "Failed to read keyboard mapping list %s: %m",
+ xkb_base);
if (r == 0)
break;
if (strv_isempty(list))
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
- "Couldn't find any entries.");
+ "Couldn't find any entries in keyboard mapping list %s.",
+ xkb_base);
strv_sort_uniq(list);