OpenTTD

Tasklist

FS#6630 - Follow XDG basedir specification

Attached to Project: OpenTTD
Opened by Lucki (Lucki) - Sunday, 22 October 2017, 13:51 GMT
Last edited by frosch (frosch) - Tuesday, 24 October 2017, 14:47 GMT
Type Feature Request
Category Core
Status Closed
Assigned To No-one
Operating System Linux
Severity Low
Priority Normal
Reported Version other
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Right now a new folder for configurations and userdata is created in `$HOME/.openttd`.
To be more flexible it would be nice to implement the XDG Base Directory Specification [1].
This is partly related to FS#6603.

> `$XDG_DATA_HOME` defines the base directory relative to which user specific data files should be stored. If `$XDG_DATA_HOME` is either not set or empty, a default equal to `$HOME/.local/share` should be used.
> `$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.
> `$XDG_CACHE_HOME` defines the base directory relative to which user specific non-essential data files should be stored. If `$XDG_CACHE_HOME` is either not set or empty, a default equal to `$HOME/.cache` should be used.
An easy explanation can be found in the gnome wiki [2].

This would result in the following folders:

- `$XDG_CONFIG_HOME/openttd/<HOTKEYS.CFG|OPENTTD.CFG|WINDOWS.CFG>` defaulting to `$HOME/.config/openttd/<HOTKEYS.CFG|OPENTTD.CFG|WINDOWS.CFG>` when `$XDG_CONFIG_HOME` is not set or empty.
- `$XDG_DATA_HOME/openttd/<AI|BASESET|GAME|HS.DAT|NEWGRF|SCENARIO|SAVE|SCREENSHOT>` defaulting to `$HOME/.local/share/openttd/<AI|BASESET|GAME|HS.DAT|NEWGRF|SCENARIO|SAVE|SCREENSHOT>` when `$XDG_DATA_HOME` is not set or empty.
- `$XDG_CACHE_HOME/openttd/<CONTENT_DOWNLOAD>` defaulting to `$HOME/.cache/openttd/<CONTENT_DOWNLOAD>` when `$XDG_CACHE_HOME` is not set or empty. - I'm not sure about this one.

Advantages are:
- No predefined paths. The user can decide where his or her data is located.
- No cluttered home directory. Some selectors will automatically show dotfiles, finding the files you want will be easier.
- A shared storage location for data. Application data does not have to be searched for, as these are no longer located in different places. This also benefits a backup.
- Resetting the settings and keeping the application data at the same time becomes easier, as there is a clear separation.

[1]: https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
[2]: https://wiki.gnome.org/Initiatives/GnomeGoals/XDGConfigFolders#Guidelines
This task depends upon

Closed by  frosch (frosch)
Tuesday, 24 October 2017, 14:47 GMT
Reason for closing:  Implemented
Additional comments about closing:  3 years ago
Comment by frosch (frosch) - Tuesday, 24 October 2017, 14:46 GMT
XDG base directories are used since OpenTTD 1.4.0.

However, OpenTTD uses libxdg-basedir to support it, which is not commonly available.
If you compile yourself, make sure to install libxdg-basedir first.
The "linux generic" binaries are compiled without libxdg-basedir, and thus do not use XDG dirs.
Comment by Lucki (Lucki) - Wednesday, 25 October 2017, 17:36 GMT
Thanks for your answer!
Seems to be a packaging issue :)

Loading...