}
char *
+get_xdg_xcompose_file_path(void)
+{
+ const char *xdg_config_home;
+ const char *home;
+
+ xdg_config_home = secure_getenv("XDG_CONFIG_HOME");
+ if (!xdg_config_home || xdg_config_home[0] != '/') {
+ home = secure_getenv("HOME");
+ if (!home)
+ return NULL;
+ return asprintf_safe("%s/.config/XCompose", home);
+ }
+
+ return asprintf_safe("%s/XCompose", xdg_config_home);
+}
+
+char *
get_home_xcompose_file_path(void)
{
const char *home;
goto found_path;
}
+ cpath = path = get_xdg_xcompose_file_path();
+ if (path) {
+ file = fopen(path, "rb");
+ if (file)
+ goto found_path;
+ }
+ free(path);
+ path = NULL;
+
cpath = path = get_home_xcompose_file_path();
if (path) {
file = fopen(path, "rb");
* affected by the following environment variables:
*
* 1. `XCOMPOSEFILE` - see Compose(5).
- * 2. `HOME` - see Compose(5).
- * 3. `XLOCALEDIR` - if set, used as the base directory for the system's
+ * 2. `XDG_CONFIG_HOME` - before `$HOME/.XCompose` is checked,
+ * `$XDG_CONFIG_HOME/XCompose` is checked (with a fall back to
+ * `$HOME/.config/XCompose` if `XDG_CONFIG_HOME` is not defined).
+ * This is a libxkbcommon extension to the search procedure in
+ * Compose(5) (since libxkbcommon 0.11.0). Note that other
+ * implementations, such as libX11, might not find a Compose file in
+ * this path.
+ * 3. `HOME` - see Compose(5).
+ * 4. `XLOCALEDIR` - if set, used as the base directory for the system's
* X locale files, e.g. `/usr/share/X11/locale`, instead of the
* preconfigured directory.
*