Skip to content

set config_dir properly when XDG_CONFIG_HOME is set#8

Open
Cj-bc wants to merge 1 commit intozwin-project:mainfrom
Cj-bc:set-config_dir-properly-with-XDG_CONFIG_HOME
Open

set config_dir properly when XDG_CONFIG_HOME is set#8
Cj-bc wants to merge 1 commit intozwin-project:mainfrom
Cj-bc:set-config_dir-properly-with-XDG_CONFIG_HOME

Conversation

@Cj-bc
Copy link

@Cj-bc Cj-bc commented Feb 18, 2023

Context

With current implementation, when XDG_CONFIG_HOME is defined (regardless its value) ./zen-release generate-config will generate config at $XDG_CONFIG_HOME/.config/zen-desktop/config.toml.

Actually, $XDG_CONFIG_HOME should contains .config as part of it according to Freedesktop's document:

$XDG_CONFIG_HOME defines the base directory relative to which user-specific
configuration files should be stored.
If $XDG_CONFIG_HOME is either not set or empty, a default equal to
$HOME/.config should be used.

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

Therefore, previous code generates config file at e.g.
~/.config/.config/zen-desktop/config.toml when XDG_CONFIG_HOME is defined, which isn't expected.

As Implementation of zen/config/config-parser.c of zwin-project/zen repository reads config file at ~/.config/zen-desktop/config.toml, it couldn't read config file at all.

Reproduce the problem

run

$ export XDG_CONFIG_HOME="$HOME/.config"
$ ./zen-release build deps

It'll generate $HOME/.config/.config/zen-desktop/config.toml

Summary

Append .config/ only if $XDG_CONFIG_HOME isn't defined.

How to check the behavior

run

$ export XDG_CONFIG_HOME="$HOME/.config"
$ ./zen-release build deps

Then now it should generate $HOME/.config/zen-desktop/config.toml as expected.

XDG_CONFIG_HOME by default contains '.config' part:

> $XDG_CONFIG_HOME defines the base directory relative to which user-specific
> configuration files should be stored.
> If $XDG_CONFIG_HOME is either not set or empty, a default equal to
> $HOME/.config should be used.
>
> from: <https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html>

Therefore, previous code generates config file at
`~/.config/.config/zen-desktop/config.toml' when XDG_CONFIG_HOME is defined,
which isn't expected.

As Implementation of zen/config/config-parser.c of zwin-project/zen repository reads
config file at `~/.config/zen-desktop/config.toml', it couldn't read config file at all.

<https://github.com/zwin-project/zen/blob/736f1423db869cc7f86dfdbb16dc809c30264be4/zen/config/config-parser.c#L29-L31>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant