benmwebb / dopewars

Game simulating the life of a drug dealer in New York
https://dopewars.sourceforge.io/
GNU General Public License v2.0
88 stars 13 forks source link

Comply with XDG Base Directory Specification #77

Open hildigerr opened 1 year ago

hildigerr commented 1 year ago

According to the XDG Base Directory Specification, user-specific configuration files should be stored with $XDG_CONFIG_HOME or else default to "$HOME/.config". Currently, we are saving it within the user's $HOME directory.

I attempted to use the --config-file option to alias dopewars and enable XDG compliance, but I realize that the option is intended to be able to load different configurations rather than also to save the configuration.

In order to enable compliance with the XDG specification, I've made a series of commits for consideration. The first will at least enable the use of a user's XDG_CONFIG_HOME setting (commit 482f451). If unset, it will default to the current behavior. The next commit (2bb72a4) will update the default to "$HOME/.config" as per the XDG spec. And finally (commit f6dc40e) will create a dopewars subdirectory under $XDG_CONFIG_HOME for saving the user's configurations.

I would prefer to have the configuration subdirectory so that I may create multiple config files, such as for different cities for use with the --config-file option. However, even if at least my XDG_CONFIG_HOME is respected I could alias dopewars to get that behavior.

hildigerr commented 1 year ago

Alternatively, we may want to use XDG_STATE_HOME since it is intended to store the "current state of the application that can be reused on a restart." See the last two commits in: https://github.com/hildigerr/dopewars/commits/issue77_xdg_state