]> git.mdlowis.com Git - proto/labwc.git/commit
config: support merging multiple config files
authorJohan Malm <jgm323@gmail.com>
Tue, 9 Jan 2024 22:00:45 +0000 (22:00 +0000)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 18 Jan 2024 20:20:36 +0000 (20:20 +0000)
commit698c7ace076b7c1c57c6871bca73c1301c42a540
treecdf6cb7ca61565291764abf97e8e8f85fc8cafd4
parentd0aff49c8192aa1435ecd808c963a3c80f891a56
config: support merging multiple config files

Add the -m|--merge-config command line option to iterate backwards over
XDG Base Dir paths and read config/theme files multiple times.

For example if both ~/.config/labwc/rc.xml and /etc/xdg/labwc/rc.xml
exist, the latter will be read first and then the former (if
--merge-config is enabled).

When $XDG_CONFIG_HOME is defined, make it replace (not augment)
$HOME/.config. Similarly, make $XDG_CONFIG_DIRS replace /etc/xdg when
defined.

XDG Base Dir Spec does not specify whether or not an application (or a
compositor!) should (a) define that only the file under the most important
base directory should be used, or (b) define rules for merging the
information from the different files.

ref: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

In the case of labwc there is a use-case for both positions, just to be
clear, the default behaviour, described by position (a) above, does NOT
change.

This change affects the following config/theme files:
  - rc.xml
  - menu.xml
  - autostart
  - environment
  - themerc
  - themerc-override
  - Theme buttons, for example max.xbm

Instead of caching global config/theme directories, create lists of paths
(e.g.  '/home/foo/.config/labwc/rc.xml', '/etc/xdg/labwc/rc.xml', etc).
This creates more common parsing logic and just reversing the direction
of iteration and breaks early if config-merge is not wanted.

Enable better fallback for themes. For example if a particular theme does
not exist in $HOME/.local/share/themes, it will be searched for in
~/.themes/ and so on. This also applies to theme buttons which now
fallback on an individual basis.

Avoid using stat() in most situations and just go straight to fopen().

Fixes #1406
14 files changed:
docs/labwc-config.5.scd
docs/labwc-theme.5.scd
docs/labwc.1.scd
include/common/dir.h
include/config/rcxml.h
include/config/session.h
src/button/common.c
src/common/dir.c
src/config/rcxml.c
src/config/session.c
src/main.c
src/menu/menu.c
src/server.c
src/theme.c