davmac314 / dinit

Service monitoring / "init" system
Apache License 2.0
583 stars 45 forks source link

Add $XDG_CONFIG_HOME/dinit.d/ to default user service directories #264

Closed into-the-v0id closed 9 months ago

into-the-v0id commented 9 months ago

Dinit's default user service directory is $HOME/.config/dinit.d/. It does not respect / comply with the XDG Base Directory Specification. This PR adds $XDG_CONFIG_HOME/dinit.d/ as an additional default user service directory (alongside $HOME/.config/dinit.d/ for backwards compatibility).

When searching for service definition files as a user instance, the following cases are possible:

As far as I can tell, this should provide full backwards compatibility: The $HOME/.config/dinit.d/ directory is still always searched and it's unreasonable to assume that the user already has a custom $XDG_CONFIG_HOME with a dinit.d/ directory.

Feel free to ask for any changes to this PR or to reject it :)

Fixes #222

davmac314 commented 9 months ago

Thanks for submitting this. Could you add a check whether $XDG_CONFIG_HOME is actually $HOME/.config and not add the directory a second time if so? I know that adding it twice basically has no effect, but it still seems like the wrong thing to do. Everything else looks good.

into-the-v0id commented 9 months ago

Sure thing - I've added an additional check to only add $HOME/.config/dinit.d/ to the default user service directories if it is not set already (through $XDG_CONFIG_HOME/dinit.d/)

davmac314 commented 9 months ago

Merged, thanks!