> XDG_CONFIG_DIRS acts like PATH does: first match wins, which
> I would not expect to happen with conffiles.

In general I believe the expectation is for the XDG variables with the plural 
suffix (i.e. ending in “S”) to return array values. String arrays in C are 
weird, but it’s possible that you have the option of checking each item in the 
array rather than just using the first one.

I just checked the GLib documentation, and g_get_system_config_dirs(), and it 
says:

> Returns an ordered list of base directories in which to access system-wide 
> configuration information.
> 
> …
> 
> 
> Returns:      An array of filename
>       
> a `NULL`-terminated array of strings owned by GLib that must not be
> modified or freed.

https://docs.gtk.org/glib/func.get_system_config_dirs.html

So how to access subsequent array entries would probably depend on if or 
whether you’re using one of GObject’s other language bindings.

Looking at Qt’s implementation, by comparison, they have these values that look 
relevant:

> ConfigLocation        "~/.config", "/etc/xdg"
> GenericConfigLocation "~/.config", "/etc/xdg”
> AppConfigLocation     "~/.config/<APPNAME>", "/etc/xdg/<APPNAME>"

https://doc.qt.io/qt-5/qstandardpaths.html

I don’t remember exactly how GLib implements this, but it probably returns the 
same values as QStandardPaths, albeit possibly in a different order.

Basically if you have a preferred config directory (or an ordered list of 
preferred directories), you could check each directory on your own list against 
the directories returned by g_get_system_config_dirs(), or other define an 
algorithm creating an alternatively sorted array from the 
g_get_system_config_dirs() return values.

It sounds like what you would want to do here is prefer any array value outside 
the user’s home directory and only use an array value inside the user’s home 
directory as a fallback.

> I think that's why: you cannot write inside such a container, so system-
> wide configs cannot be changed. XDG_CONFIG_HOME has the problem, that
> one cannot provide a default for everyone, which is the purpose of a
> system-wide config and it cannot be installed by make install, unless
> each user installs the software to $HOME/.local. Now, that can't be
> right. ;)

If you’re specifically trying to work within Flatpak, the Flathub Discourse 
might also be a good place to ask:

https://discourse.flathub.org/

Also the Freedesktop Flatpak list:

https://lists.freedesktop.org/mailman/listinfo/flatpak

I don’t know what the application you’re working on does, but it might also 
need to be a Flatpak runtime or be packaged within a Flatpak runtime, in which 
case it might also be worth asking the maintainers of the Freedesktop SDK about 
it:

https://gitlab.com/freedesktop-sdk/freedesktop-sdk

(I’ve been on this mailing list for a couple months, and it’s extremely quiet, 
hence why I’m suggesting other places to reach out.)

Reply via email to