hneemann / Digital

A digital logic designer and circuit simulator.
GNU General Public License v3.0
4.13k stars 416 forks source link

Add XDG config support #1251

Closed jackbashford closed 5 months ago

jackbashford commented 5 months ago

Use XDG_CONFIG_HOME (if defined) to store digital.cfg file instead of HOME. Fixes #1070.

Successfully passes mvn verify.

hneemann commented 5 months ago

If this change were to be merged, all existing users would lose their settings after an update.

jackbashford commented 5 months ago

In that case, does the following checklist satisfy all possibilities?

  1. If the user has pre-existing settings at the default location (under $HOME, the current behaviour) then those should be used, as is the current behaviour.
  2. If that file does not currently exist, then: a. If the environment variable $XDG_CONFIG_HOME is set then use that as the location of the settings file. (the behaviour I have in my PR) b. If the environment variable $XDG_CONFIG_HOME is not set, then use $HOME as the location of the settings file.

This can be logically restructured to read 'if no configuration file exists under $HOME and the $XDG_CONFIG_HOME environment variable exists, then place the configuration file in $XDG_CONFIG_HOME, otherwise use $HOME'.

This should hopefully mean no deletion of settings files, but if a user wishes to use the XDG directory, they can simply move their settings file to the desired location and it will be recognised. Or am I missing something?

hneemann commented 5 months ago

I think that would work.

jackbashford commented 5 months ago

I've added that functionality now, and mvn verify still passes. I've also checked that it handles the expected cases/scenarios correctly, including no noticeable changes when you load settings from the current release into my patched version (i.e. settings still transfer successfully and are not overwritten, even with $XDG_CONFIG_HOME set.)