[PATCH libxkbcommon 1/2] src/context: add XDG search path
Mihail Konev
k.mvc at ya.ru
Thu Nov 17 17:43:44 UTC 2016
Search in $XDG_CONFIG_HOME/xkb, falling back to ~/.config/xkb
Signed-off-by: Mihail Konev <k.mvc at ya.ru>
---
src/context.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/context.c b/src/context.c
index 50993e108af6..e9e939b6b0eb 100644
--- a/src/context.c
+++ b/src/context.c
@@ -75,8 +75,8 @@ err:
XKB_EXPORT int
xkb_context_include_path_append_default(struct xkb_context *ctx)
{
- const char *home, *root;
- char *user_path;
+ const char *home, *root, *xdg;
+ char *user_path, *xdg_path = NULL;
int err;
int ret = 0;
@@ -86,9 +86,27 @@ xkb_context_include_path_append_default(struct xkb_context *ctx)
else
ret |= xkb_context_include_path_append(ctx, DFLT_XKB_CONFIG_ROOT);
+ xdg = secure_getenv("XDG_CONFIG_HOME");
+ if (xdg != NULL) {
+ err = asprintf(&xdg_path, "%s/xkb", xdg);
+ if (err <= 0)
+ return ret;
+ ret |= xkb_context_include_path_append(ctx, xdg_path);
+ free(xdg_path);
+ }
+
home = secure_getenv("HOME");
if (!home)
return ret;
+
+ if (!xdg_path) {
+ err = asprintf(&xdg_path, "%s/.config/xkb", home);
+ if (err <= 0)
+ return ret;
+ ret |= xkb_context_include_path_append(ctx, xdg_path);
+ free(xdg_path);
+ }
+
err = asprintf(&user_path, "%s/.xkb", home);
if (err <= 0)
return ret;
--
2.9.2
More information about the xorg-devel
mailing list