diff --git a/CHANGELOG.md b/CHANGELOG.md index f42501ee..d74a484c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## New features +* `@include` directives in config file now also search in `$XDG_CONFIG_HOME/picom/include` and `$XDG_CONFIG_DIRS/picom/include`, in addition to relative to the config file's parent directory. * Allow `corner-radius-rules` to override `corner-radius = 0`. Previously setting corner radius to 0 globally disables rounded corners. (#1170) * New `picom-inspect` tool, which lets you test out your picom rules. Sample output: @@ -49,7 +50,7 @@ * picom now uses some OpenGL 4.3 features. * picom now optionally depends on `rtkit` at runtime to give itself realtime scheduling priority. -* `libconfig` is now a mandatory dependency. +* `libconfig` is now a mandatory dependency, with a minimal supported version of 1.7. # v11.2 (2024-Feb-13) diff --git a/man/picom.1.asciidoc b/man/picom.1.asciidoc index cdd98a3c..5f995ff6 100644 --- a/man/picom.1.asciidoc +++ b/man/picom.1.asciidoc @@ -421,6 +421,8 @@ CONFIGURATION FILES ------------------- picom could read from a configuration file if libconfig support is compiled in. If *--config* is not used, picom will seek for a configuration file in `$XDG_CONFIG_HOME/picom.conf` (`~/.config/picom.conf`, usually), then `$XDG_CONFIG_HOME/picom/picom.conf`, then `$XDG_CONFIG_DIRS/picom.conf` (often `/etc/xdg/picom.conf`), then `$XDG_CONFIG_DIRS/picom/picom.conf`. +When `@include` directive is used in the config file, picom will first search for the included file in the parent directory of `picom.conf`, then in `$XDG_CONFIG_HOME/picom/include/`, then in `$XDG_CONFIG_DIRS/picom/include`. + picom uses general libconfig configuration file format. A sample configuration file is available as `picom.sample.conf` in the source tree. Most of commandline switches can be used as options in configuration file as well. For example, *--vsync* option documented above can be set in the configuration file using `vsync = `. Command line options will always overwrite the settings in the configuration file. Window-type-specific settings are exposed only in configuration file and has the following format: diff --git a/src/config_libconfig.c b/src/config_libconfig.c index 8867635a..659650e4 100644 --- a/src/config_libconfig.c +++ b/src/config_libconfig.c @@ -526,6 +526,21 @@ void generate_fading_config(struct options *opt) { } } +static const char **resolve_include(config_t * /* cfg */, const char *include_dir, + const char *path, const char **err) { + char *result = locate_auxiliary_file("include", path, include_dir); + if (result == NULL) { + *err = "Failed to locate included file"; + return NULL; + } + + log_debug("Resolved include file \"%s\" to \"%s\"", path, result); + const char **ret = ccalloc(2, const char *); + ret[0] = result; + ret[1] = NULL; + return ret; +} + /** * Parse a configuration file from default location. * @@ -568,6 +583,7 @@ char *parse_config_libconfig(options_t *opt, const char *config_file) { if (parent) { config_set_include_dir(&cfg, parent); } + config_set_include_func(&cfg, resolve_include); free(abspath); } diff --git a/src/meson.build b/src/meson.build index 1a522404..52baf220 100644 --- a/src/meson.build +++ b/src/meson.build @@ -34,7 +34,7 @@ endforeach foreach i : required_xcb_packages base_deps += [dependency(i, version: '>=1.12.0', required: true)] endforeach -base_deps += [dependency('libconfig', version: '>=1.4', required: true)] +base_deps += [dependency('libconfig', version: '>=1.7', required: true)] if not cc.has_header('uthash.h') error('Dependency uthash not found')