[PATCH v2 app/setxkbmap] Add ~/.xkb and xdg dir to search path
Mihail Konev
k.mvc at ya.ru
Tue Nov 22 05:37:04 UTC 2016
Signed-off-by: Mihail Konev <k.mvc at ya.ru>
---
Whichever directories get added, they should not differ from libxkbcommon
not to "break per-user installs" between setxkbmap and users of the latter :)
setxkbmap.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/setxkbmap.c b/setxkbmap.c
index cf0f02d6e704..42b8c3f04137 100644
--- a/setxkbmap.c
+++ b/setxkbmap.c
@@ -381,6 +381,40 @@ setOptString(int *arg, int argc, char **argv, setting_t *setting, enum source sr
/***====================================================================***/
/**
+ * Retrieve name of ~/.config/xkb directory.
+ */
+char *
+get_xdg_dir()
+{
+ static char path[PATH_MAX];
+
+ const char *home = getenv("HOME");
+ const char *xdg = getenv("XDG_CONFIG_HOME");
+ int rc;
+
+ if (xdg != NULL)
+ snprintf(path, sizeof path, "%s/xkb", xdg);
+ else
+ snprintf(path, sizeof path, "%s/.config/xkb", home);
+ return path;
+}
+/**
+ * Retrieve name of ~/.xkb directory.
+ */
+char *
+get_dot_dir()
+{
+ static char path[PATH_MAX];
+
+ const char *home = getenv("HOME");
+ snprintf(path, sizeof path, "%s/.config/xkb", home);
+ return path;
+}
+
+
+/***====================================================================***/
+
+/**
* Parse commandline arguments.
* Return True on success or False if an unrecognized option has been
* specified.
@@ -394,6 +428,8 @@ parseArgs(int argc, char **argv)
ok = True;
addToList(&inclPath, ".");
+ addToList(&inclPath, get_xdg_dir());
+ addToList(&inclPath, get_dot_dir());
addToList(&inclPath, DFLT_XKB_CONFIG_ROOT);
for (i = 1; (i < argc) && ok; i++)
{
--
2.9.2
More information about the xorg-devel
mailing list