bds icon indicating copy to clipboard operation
bds copied to clipboard

Support for XDG directories

Open silwol opened this issue 7 years ago • 3 comments

In recent years, the usage of the ~/.<program_name> directories for application configuration and data has been replaced by using the paths from the XDG specification. It would be great to see support for this in BDS as well, storing the configuration in $XDG_CONFIG_HOME/bds-game and the player data in $XDG_DATA_HOME/bds-game, because that's what usually is expected by users.

silwol avatar Aug 10 '18 03:08 silwol

What is the default behavior if those variables are not defined?

You can change the save and data directories with the makefile by defining DATAPATH or SAVEPATH which will be then compiled into the program, so you already have the ability to do this with minor modification. I will have to add a variable to change the default home directory, because right now it is set to $HOME on UNIX.

Will that suffice, again I think this is a convenience issue and perhaps I just need better documentation. Not sure?

Aaron-SP avatar Aug 10 '18 19:08 Aaron-SP

The default behavior for missing or empty environment variables is to fall back to the default paths, which is described in https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html for each of them. Usually, the vast majority of (still maintained) free software nowadays respect these variables. Compiling the paths directly into the program means that users (probably using pre-compiled binaries, maybe flatpak or distribution packages, in the future) loose the ability to configure them as they wish in their environment.

silwol avatar Aug 11 '18 08:08 silwol

Originally the default structure was just to play the game from the directory the game was built in. Now you must define DATALOCAL when building to get this feature.

Then I added the capability to save to HOME folders by checking the $HOME environment variable or defaulting to the original SAVEPATH which was the HOME folder for the user who compiled the program. This totally sucks TBH. However it works as expected.

Flatpak's and binary distributions will just come compiled in a fixed format zip file which can be unzipped anywhere and won't have any of these concerns.

If I change the $HOME environment variable to be customizable, you will probably be able to do any configuration that you want, since you will have the option of defining your own environment variable. Something like adding BDS_DYNAMIC_PATH which would be a definable environment variable to replace with HOME when compiling and would default to HOME if not specified.

The only thing that I hate about this is that it adds to confusion and I will have to remember why we have so much spaghetti hanging around saving files.

Aaron-SP avatar Aug 12 '18 13:08 Aaron-SP