Am Mi, Sep 23, 2026 am 05:08:05 +0000 schrieb Laurent Bercot:
>>When some `XDG_*_HOME` variable aren't set, I get this:
>
> Right, there needs to be a fallback.
>
>
>>a) Add another interpretable config variable for `$HOME`, that can be
>>set in the config instead of XDG variable usage.
>>Resolve `$HOME` like this:
>>Get it from env, fallback to `getpwuid(getuid())` when it isn't set.
>
> That sounds good, but doesn't work for e.g. XDG_RUNTIME_DIR, that you
>cannot easily derive from HOME.
>
>
>>b) When an `XDG_*_HOME` variable isn't set, fallback to default XDG
>>paths relative to the home directory. Example:
>>`XDG_CONFIG_HOME` isn't set -> resolve the home directory,
>>and construct it as `/home/user/.config`.
>
> That also sounds good and also doesn't work for XDG_RUNTIME_DIR. The
>fundamental problem is that any fallback needs to encode policy, and
>there are too many ways that things can go wrong to feel comfortable
>adding policy here. I think it's better to avoid fallbacks altogether,
>and just fail.
>
>
>>For problem 2, I propose showing a simple error when **any**
>>of the paths in the config is unresolvable.
>
> Yes, erroring out on any failure to resolve is a better solution, just
>like it is the better solution to problem 1.
I think you should error out on a missing XDG_RUNTIME_DIR, as I agree its path
is highly a matter of policy and should be set. However, for other XDG
variables, I’d rather have the standard fallback be used. On my systems,
XDG_RUNTIME_DIR is usually the only XDG variable set, I’ve never bothered with
the others, and some pam plugins only set XDG_RUNTIME_DIR.
> The thing is, I want to keep it simple, and avoid writing a full parser
>just for the treatment of the XDG variables. For now, a simple sed
>substitution is used, which is as complex as I'm willing to make it.
> Erroring out on failure requires:
> - list which XDG variables are undefined
> - grep the config file for occurrences of those, with or without curly
>braces
> - fail on match.
So in my opinion, the process should be:
- list whether HOME or XDG variables are undefined
- grep the config file for occurences of those
- if HOME or XDG_RUNTIME_DIR matches, fail
- if any other XDG variable matches, fail if HOME is undefined
Hoël
Received on Wed Sep 23 2026 - 20:00:18 CEST