Opened 12 years ago

Closed 8 years ago

Last modified 6 years ago

#6036 closed defect

POSIX: Use XDG dirs instead of HOME

Reported by: SF/mccannwj Owned by: lordhoto
Priority: high Component: Port: Linux
Version: Keywords:
Cc: Game:


We store information in ~/.scummvm. It would be better to use the locations defined in the XDG Base Directory Specification.

Ticket imported from: #3527150. Ticket imported from: bugs/6036.

Change History (19)

comment:1 by sev-, 12 years ago

Well, ~/.* is the Right Thing(TM), Unix style, and 99.95% of programs use that. Gnome works mainly on *nix clones. I see no point of moving it anywhere.

What are the advantages specific to our project? None of the things mentioned in the list you point to are applicable to ScummVM. E.g. it is safe to kill this file anytime, it is universal, backing it up = copy single file, data file paths are specified via GUI and are not enforced by the program, etc.

comment:2 by SF/mccannwj, 12 years ago

Storing in $HOME is no longer the Right Thing(TM) on any unix style machine. This has nothing to do with GNOME. In fact this standard supports not only unix style systems but also mac and windows in most implementations. The GLib apis are particularly good in this respect.

The advantages are for the user and admin, mostly. Not necessarily your project. Just being considerate to your users and a good citizen of the ecosystem I suppose. I don't think it really involves any cost. I can provide a patch myself soon I hope.

comment:3 by sev-, 12 years ago

Does it mean that reading XDG_CONFIG_HOME environment variables is enough?

Looking into glib sources, I see that if this variable is not set, it uses ~/.config, however the specifications mention /etc/xdg directory. So there is an inconsistency.

Also this variable is not set neither on my Ubuntu 12.04 (with Unity), nor on Mac OS 10.7.4.

Adding dependency on glib for the sake of retrieving this value looks like an overkill for me.

So, any suggestions or hints?

comment:4 by SF/mccannwj, 12 years ago

XDG_CONFIG_HOME and XDG_CONFIG_DIRS are different. The first is per-user and typically in the home directory. The second is systemy typically.

The variable isn't normally set because the default is usually correct. However, a system admin or vendor can set it to whatever they wish. This is sometimes done when multiple operating systems need to be supported using a shared home directory.

So, from a quick look it seems that dot files are used for a few things.

log files -> syslog or XDG_CACHE_HOME/scummvm saved games -> XDG_DATA_HOME/scummvm/ configuration -> XDG_CONFIG_HOME/scummvm

One nice thing about glib (there are lots of nice things about glib) is that it takes care of windows support for you. But if you don't want to add a dependency on it you can just do the same things that it does. g_get_user_cache_dir() for example.

Hope that helps.

comment:5 by tsoliman, 12 years ago

I did some digging to find this out since some other games are putting their saves in ~/Documents/

Basically shell scripts are supposed to check for and source ~/.config/user-dirs.dirs (they should look for $XDG_CONFIG_HOME and fall back to ~/.config) Then they'll get the environment variables. Stuff that runs at logs uses /etc/xdg to populate that file.

(~/.config is the default for XDG_CONFIG_HOME)

Implementing this shouldn't be too hard and ScummVM could probably fall back to the old behavior if anything goes wrong.

Migration is a different story.

comment:6 by SF/mccannwj, 12 years ago

Just curious, what games? Using Documents sounds wrong to me. I think using USER_DATA_HOME is better.

comment:7 by tsoliman, 12 years ago

botanicula is the game but that's besides the point. The environment variables for xdg in debian sid are the following:


There is no USER_DATA_HOME that I can see

comment:8 by SF/mccannwj, 12 years ago

Ok, I'll try to follow up with that game and file a bug. Thanks for that info.

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

comment:9 by lordhoto, 12 years ago

I agree that adding glib as dependancy is really a bit much. Especially for using it on Windows, where it seemed a PITA to build it easily with MSVC. At least I had some troubles when I tired to do an x64 build. But that has been a while, so maybe it's better these days.

As I understand it the base-dir specification was made to declutter $HOME and give some standard paths for different types of files used by programs on desktop machines. Then again the whole specification fails to point out any benefits, so maybe the intention here was something completly different... So I am not really sure I can say I like it too much. It would really be better when it would at least point to other documents which points out why using $HOME etc. is bad for example.

It might make sense to adpot that standard never the less, looking at my $HOME/.local/share and $HOME/.config more and more programs seem to adopt it. The proposed places to put the config file, saved games seem fine to me. I am not sure whether I feel that "XDG_CACHE_HOME" sounds really a place to put a log, but I guess from the specification it seems the place which fits best.

Anyway we need to make sure people with config files etc. in the old locations don't need to manually migrate to the new locations IMHO. That might need some small effort.

comment:10 by sev-, 12 years ago

This bug is nice to get fixed before the release. Raising priority for keeping the track.

comment:11 by sev-, 12 years ago

Priority: normalhigh

comment:12 by SF/eheintzmann, 11 years ago

What is planned now about FreeDesktop XDG basedir specification for ScummVM?

comment:13 by lordhoto, 11 years ago

As it seems, there's currently nobody working on that.

comment:14 by SF/eheintzmann, 11 years ago

According to XDG Base directory specification: User data should go into $XDG_DATA_HOME (which default to ~/.local/share), user preferences should go into $XDG_CONFIG_HOME (which default to ~/.config) and cached data should go to $XDG_CACHE_HOME (which default to ~/.cache). More details at :

Full specification can be found at:

The XDG base directory specification have good de facto adoption. It has been adopted by: - GNOME ( ) - GTK+ ( ) - KDE ( ) - QT ( ) - XFCE ( in Files and Environment Variables ) - LXDE - Razor-qt - VLC ( ) - GStreamer ( ) - Chrome ( ) - many more upstream applications - Ubuntu ( & ) - Debian ( ) - Red Hat - Fedora - Suse - many more distributions

I think that ScummVM should use same locations than the vast majority of Desktop environment and applications.

There are real advantages of following this specification : - a lot less cluttered $HOME - Make backups a lot more safer and easier. Backuping your $XDG_DATA_HOME along with your files is enough (or just excluding $XDG_CACHE_HOME) - A lot easier to reset a default configuration if you want/need it (and without any risk to loose informations). Even for the software itself could choose to reset $XDG_CONFIG_HOME if needed. - Avoid some strange bugs that happens because you had a old version of some configuration file - A lot more of flexibility and portability because no path are hardcoded.

comment:15 by lordhoto, 8 years ago

Summary: use XDG dirs instead of HOMEPOSIX: Use XDG dirs instead of HOME

comment:16 by lordhoto, 8 years ago

Appareantly nobody else bothered to work on this. I opened a pull request now which switches to this style, but still uses the old one if that has been around before:

comment:17 by lordhoto, 8 years ago

Owner: set to lordhoto
Status: newclosed

comment:18 by lordhoto, 8 years ago

Merged the PR so this is finally implemented.

Users will need to migrate to new paths themselves for the time being. We still use the old locations if they are present.

comment:19 by digitall, 6 years ago

Component: Port: Linux
Note: See TracTickets for help on using tickets.