dmedvinsky / gsimplecal

Simple and lightweight GTK calendar (BSD license)
http://dmedvinsky.github.io/gsimplecal
Other
198 stars 19 forks source link

Follow freedesktop specifications for config location #32

Closed uniquestring closed 6 years ago

uniquestring commented 6 years ago

Gsimplecal doesn't find my configuration file, which is located at ~/.config/gsimplecal/config. The reason for that is, that $XDG_CONFIG_HOME isn't defined. I think this behaviour is a bug.

Currently, gsimplecal's behaviour for searching the config file is decribed like this:

To configure the application you should manually create the configuration file. The file is first searched in $XDG_CONFIG_HOME/gsimplecal/config. Usually that will be ~/.config/gsimplecal/config. If found, it is used. If not found, system-wide configuration is searched in all the $XDG_CONFIG_DIRS/gsimplecal/config locations.

Problem is, that $XDG_CONFIG_HOME isn't always set. In fact, you should only need set it if you want to use a different location than $HOME/.config

The specification at freedesktop.org says:

$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.

Please add $HOME/.config/gsimplecal/config to the search locations. If you want to keep the $XDG_CONFIG_DIRS part, you could search in this order:

  1. $XDG_CONFIG_HOME/gsimplecal/config
  2. $HOME/.config/gsimplecal/config
  3. $XDG_CONFIG_DIRS/gsimplecal/config
uniquestring commented 6 years ago

I cloned this project to see if I could fix this myself. After some time playing around, I noticed, that my original installation found the config all of a sudden. All I did was installing libgtk-3-dev and compiling gsimplecal a few times.

I checked if I replaced the original binary with the newly compiled one, but thats not the case. Also $XDG_CONFIG_HOME is still not set.

I'll try to reproduce my original problem on a fresh VM. If I can reproduce it, I'll post details here.

dmedvinsky commented 6 years ago

gsimplecal uses the g_get_user_config_dir function from glib: https://github.com/dmedvinsky/gsimplecal/blob/2dc6bbab18f51ee2ad0eb33f9b8ff48db849f95e/src/Config.cpp#L76

which in turn uses g_init_user_config_dir internally: https://github.com/GNOME/glib/blob/0d49cd1b11b1bd0bae2671da9ddd83a6227eb947/glib/gutils.c#L1270

which actually does what you are describing is the desired behavior -- tries the env var first, then falls back to $HOME/.config: https://github.com/GNOME/glib/blob/0d49cd1b11b1bd0bae2671da9ddd83a6227eb947/glib/gutils.c#L1234

So, my guess is maybe it somehow changed at some point in time and when installing libgtk-3-dev you somehow updated the glib and compiled gsimplecal against the newer version which has this behavior?.. I'm not sure.