Skip to content

Implement a configuration directory hierarchy

Peter Hutterer requested to merge whot/wireplumber:wip/usr-config-dir into master

The previous approach to loading config files was to ask WP for the directory and then search those for the config files. This patch changes the approach - a caller now asks WP to search for a specific config file or iterate over a config file directory.

This allows us to implement a directory lookup order, i.e. "wireplumber.conf" may be in XDG_CONFIG_DIR, /etc/, /usr/share and the first one found is used.

For configuration directories, the new method iterates over all matching entries (files + directories) and invokes a callback for each entry.

This enables distributions to ship default files in /usr/share/wireplumber but have admins and users override them on a local basis. For lua scripts in particular, overriding a distribution-provided file with an empty file effectively disables it, adding a file adds it in the right sort order.

todo

  • The main: assemble the full config file name and pass that to pipewire patch somewhat relies on pipewire@fb2d3589, if the environment variable is set we may get weird behaviour here without that pipewire commit. Not sure how niche that is.
  • Need to figure out what the exact behaviour of WIREPLUMBER_CONFIG_DIR and WIREPLUMBER_DATA_DIR should be. Right now the former is prefixed to the lookup path and thus adds to XDG and /etc. The latter replaces the default lookup directory. But since we still use g_get_system_data_dirs () for any real-world case we will still load the default data dir anyway. Either way, it's inconsistent, hard to understand for the casual reviewer and we should figure out what we really want to do here. The problem is amplified by config vs config dir. A config is easy to override, a config directory always merges with the next one. Much of this decision hangs on what the most common use-cases are (outside the default debugging) but I'm not sure I have much input here.
  • wp_get_config_dir, wp_get_data_dir should be deprecated and/or removed. How do we do that?
  • find whatever C style issues I've missed

Meanwhile, I'll take comments from the audience 😃

Edited by Peter Hutterer

Merge request reports