mini-calc: 3.3.3 -> 3.3.5 (#372274)
[NixPkgs.git] / pkgs / by-name / li / libxklavier / honor-XKB_CONFIG_ROOT.patch
blob93b768eeb202f754849fe9d786482a07aeb1387c
1 From 999a419f4b36764a7269650a7f965d48bd4b73f7 Mon Sep 17 00:00:00 2001
2 From: Louis Bettens <louis@bettens.info>
3 Date: Sat, 28 Dec 2019 14:30:58 +0100
4 Subject: [PATCH] honor $XKB_CONFIG_ROOT
6 ---
7 libxklavier/xklavier_config_xkb.c | 30 +++++++++++++++++++++++++-----
8 1 file changed, 25 insertions(+), 5 deletions(-)
10 diff --git a/libxklavier/xklavier_config_xkb.c b/libxklavier/xklavier_config_xkb.c
11 index baec569..00e8de5 100644
12 --- a/libxklavier/xklavier_config_xkb.c
13 +++ b/libxklavier/xklavier_config_xkb.c
14 @@ -45,6 +45,18 @@
15 #define XK_XKB_KEYS
16 #include <X11/keysymdef.h>
18 +static const gchar *
19 +xkl_xkb_get_base_path(void)
21 + const gchar *base_path;
23 + base_path = g_getenv ("XKB_CONFIG_ROOT");
24 + if (!base_path)
25 + base_path = XKB_BASE;
27 + return base_path;
30 #ifdef LIBXKBFILE_PRESENT
31 static XkbRF_RulesPtr xkl_rules;
33 @@ -65,7 +77,8 @@ xkl_rules_set_load(XklEngine * engine)
35 locale = setlocale(LC_ALL, NULL);
37 - g_snprintf(file_name, sizeof file_name, XKB_BASE "/rules/%s", rf);
38 + g_snprintf(file_name, sizeof file_name, "%s/rules/%s",
39 + xkl_xkb_get_base_path(), rf);
40 xkl_debug(160, "Loading rules from [%s]\n", file_name);
42 rules_set = XkbRF_Load(file_name, locale, True, True);
43 @@ -98,10 +111,14 @@ gboolean
44 xkl_xkb_load_config_registry(XklConfigRegistry * config,
45 gboolean if_extras_needed)
47 - return xkl_config_registry_load_helper(config,
48 + const gchar *rules_path = g_strdup_printf("%s/rules",
49 + xkl_xkb_get_base_path());
50 + gboolean ok = xkl_config_registry_load_helper(config,
51 XKB_DEFAULT_RULESET,
52 - XKB_BASE "/rules",
53 + rules_path,
54 if_extras_needed);
55 + g_free(rules_path);
56 + return ok;
59 #ifdef LIBXKBFILE_PRESENT
60 @@ -249,6 +266,7 @@ xkl_config_get_keyboard(XklEngine * engine,
61 pid_t cpid, pid;
62 int status = 0;
63 FILE *tmpxkb;
64 + const gchar *opt_I;
66 xkl_debug(150, "tmp XKB/XKM file names: [%s]/[%s]\n",
67 xkb_fn, xkm_fn);
68 @@ -296,14 +314,16 @@ xkl_config_get_keyboard(XklEngine * engine,
69 break;
70 case 0:
71 /* child */
72 + opt_I = g_strdup_printf("-I%s", xkl_xkb_get_base_path());
73 xkl_debug(160, "Executing %s\n", XKBCOMP);
74 xkl_debug(160, "%s %s %s %s %s %s %s %s\n",
75 XKBCOMP, XKBCOMP, "-w0", "-I",
76 - "-I" XKB_BASE, "-xkm", xkb_fn,
77 + opt_I, "-xkm", xkb_fn,
78 xkm_fn);
79 execl(XKBCOMP, XKBCOMP, "-w0", "-I",
80 - "-I" XKB_BASE, "-xkm", xkb_fn,
81 + opt_I, "-xkm", xkb_fn,
82 xkm_fn, NULL);
83 + g_free(opt_I);
84 xkl_debug(0, "Could not exec %s: %d\n",
85 XKBCOMP, errno);
86 exit(1);
87 --
88 2.24.1