summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2020-07-10 08:50:02 +1000
committerRan Benita <ran@unusedvar.com>2020-08-30 21:49:41 +0300
commitd7b39f6ffbe9b46181c5597b0d0e7373eb2e9070 (patch)
tree9cc4b5e240b5532c822a5f9106a983a3a8d84425 /src
parent05d6efc41723601d4d38e0c43129d2ab9d53fa48 (diff)
downloadxorg-lib-libxkbcommon-d7b39f6ffbe9b46181c5597b0d0e7373eb2e9070.tar.gz
Add /etc/xkb as extra lookup path for system data files
This completes the usual triplet of configuration locations available for most processes: - vendor-provided data files in /usr/share/X11/xkb - system-specific data files in /etc/xkb - user-specific data files in $XDG_CONFIG_HOME/xkb The default lookup order user, system, vendor, just like everything else that uses these conventions. For include directives in rules files, the '%E' resolves to that path. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/context.c11
-rw-r--r--src/context.h3
-rw-r--r--src/registry.c8
-rw-r--r--src/xkbcomp/rules.c7
4 files changed, 27 insertions, 2 deletions
diff --git a/src/context.c b/src/context.c
index ef9b774..2abaa9b 100644
--- a/src/context.c
+++ b/src/context.c
@@ -84,6 +84,13 @@ err:
}
const char *
+xkb_context_include_path_get_extra_path(struct xkb_context *ctx)
+{
+ const char *extra = secure_getenv("XKB_CONFIG_EXTRA_PATH");
+ return extra ? extra : DFLT_XKB_CONFIG_EXTRA_PATH;
+}
+
+const char *
xkb_context_include_path_get_system_path(struct xkb_context *ctx)
{
const char *root = secure_getenv("XKB_CONFIG_ROOT");
@@ -96,7 +103,7 @@ xkb_context_include_path_get_system_path(struct xkb_context *ctx)
XKB_EXPORT int
xkb_context_include_path_append_default(struct xkb_context *ctx)
{
- const char *home, *xdg, *root;
+ const char *home, *xdg, *root, *extra;
char *user_path;
int ret = 0;
@@ -126,6 +133,8 @@ xkb_context_include_path_append_default(struct xkb_context *ctx)
}
}
+ extra = xkb_context_include_path_get_extra_path(ctx);
+ ret |= xkb_context_include_path_append(ctx, extra);
root = xkb_context_include_path_get_system_path(ctx);
ret |= xkb_context_include_path_append(ctx, root);
diff --git a/src/context.h b/src/context.h
index 9584dbc..ead2508 100644
--- a/src/context.h
+++ b/src/context.h
@@ -60,6 +60,9 @@ xkb_context_failed_include_path_get(struct xkb_context *ctx,
unsigned int idx);
const char *
+xkb_context_include_path_get_extra_path(struct xkb_context *ctx);
+
+const char *
xkb_context_include_path_get_system_path(struct xkb_context *ctx);
/*
diff --git a/src/registry.c b/src/registry.c
index 956d850..d3d95f5 100644
--- a/src/registry.c
+++ b/src/registry.c
@@ -583,7 +583,7 @@ err:
XKB_EXPORT bool
rxkb_context_include_path_append_default(struct rxkb_context *ctx)
{
- const char *home, *xdg, *root;
+ const char *home, *xdg, *root, *extra;
char *user_path;
bool ret = false;
@@ -618,6 +618,12 @@ rxkb_context_include_path_append_default(struct rxkb_context *ctx)
}
}
+ extra = secure_getenv("XKB_CONFIG_EXTRA_PATH");
+ if (extra != NULL)
+ ret |= rxkb_context_include_path_append(ctx, extra);
+ else
+ ret |= rxkb_context_include_path_append(ctx, DFLT_XKB_CONFIG_EXTRA_PATH);
+
root = secure_getenv("XKB_CONFIG_ROOT");
if (root != NULL)
ret |= rxkb_context_include_path_append(ctx, root);
diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c
index 3359552..099500a 100644
--- a/src/xkbcomp/rules.c
+++ b/src/xkbcomp/rules.c
@@ -399,6 +399,13 @@ matcher_include(struct matcher *m, struct scanner *parent_scanner,
return;
}
}
+ else if (chr(&s, 'E')) {
+ const char *default_root = xkb_context_include_path_get_extra_path(m->ctx);
+ if (!buf_appends(&s, default_root) || !buf_appends(&s, "/rules")) {
+ scanner_err(&s, "include path after expanding %%E is too long");
+ return;
+ }
+ }
else {
scanner_err(&s, "unknown %% format (%c) in include statement", peek(&s));
return;