Page 1 of 1

[Linux] Comply with the XDG directory standard

Posted: Sat Aug 06, 2016 4:55 pm
by Zok
Not sure if this belongs in a bug report or a suggestion, I'll post it here feel free to move it if its out of place.

On linux, the XDG Base Directory Specification[1] defines the paths inside the users home directory that should be used for different purposes. Factorio currently saves the data files in $HOME/.factorio which ends up cluttering the home directory even more than it already is or needs to be.

To comply with the standard factorio should:
* Check if $XDG_CONFIG_DIR $XDG_DATA_DIR and $XDG_CACHE_DIR environment variables are set and determine the location of the directories as defined in the standard
$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_DATA_DIRS defines the preference-ordered set of base directories to search for data files in addition to the $XDG_DATA_HOME base directory. The directories in $XDG_DATA_DIRS should be separated with a colon ':'.

If $XDG_DATA_DIRS is either not set or empty, a value equal to /usr/local/share/:/usr/share/ should be used.

$XDG_CONFIG_DIRS defines the preference-ordered set of base directories to search for configuration files in addition to the $XDG_CONFIG_HOME base directory. The directories in $XDG_CONFIG_DIRS should be seperated with a colon ':'.

If $XDG_CONFIG_DIRS is either not set or empty, a value equal to /etc/xdg should be used.
* Once the XDG data dirs have been established factorio should place its files as follows:
o .factorio/config/* should be placed in $XDG_CONFIG_HOME/factorio/
o .factorio/temp/* should be placed in $XDG_CACHE_HOME/factorio/
o Everything else(data files, logs etc) should be placed in $XDG_DATA_HOME/factorio/

A simpler to implement but not-so-compliant alternative that a lot of steam games use is to simply put everything in $XDG_DATA_HOME/factorio/. While this technically achieves the purpose of getting the files off the home directory root, full compliance with the standard would be much better in my opinion.

[1] https://specifications.freedesktop.org/ ... atest.html

Re: [Linux] Comply with the XDG directory standard

Posted: Sat Aug 06, 2016 8:10 pm
by golfmiketango
Although I really dislike some of the naming decisions that XDG has implemented this is probably a good idea. For example, I notice baloo or whatever the kde file indexer is named this week is being confused by my save files:

Code: Select all

Jul 17 18:20:19 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/config/config.ini" -> "/home/greg/factorio13/config/config.bak.ini"
Jul 17 18:20:19 moneypit baloo_file[3100]: File moved to path which now no longer exists - "/home/greg/factorio13/config/config.bak.ini"
Jul 17 18:20:19 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/config/config.tmp.ini" -> "/home/greg/factorio13/config/config.ini"
Jul 17 18:20:19 moneypit baloo_file[3100]: org.kde.baloo: Moved without data
Jul 17 18:20:20 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/saves/_autosave2.zip" -> "/home/greg/factorio13/saves/_autosave2.bak.zip"
Jul 17 18:20:20 moneypit baloo_file[3100]: org.kde.baloo: Moved without data
Jul 17 18:20:20 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/saves/_autosave2.tmp.zip" -> "/home/greg/factorio13/saves/_autosave2.zip"
Jul 17 18:20:20 moneypit baloo_file[3100]: org.kde.baloo: Moved without data
Jul 17 18:22:18 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/config/config.ini" -> "/home/greg/factorio13/config/config.bak.ini"
Jul 17 18:22:18 moneypit baloo_file[3100]: File moved to path which now no longer exists - "/home/greg/factorio13/config/config.bak.ini"
Jul 17 18:22:18 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/config/config.tmp.ini" -> "/home/greg/factorio13/config/config.ini"
Jul 17 18:22:18 moneypit baloo_file[3100]: org.kde.baloo: Moved without data
Jul 17 18:22:18 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/config/config.ini" -> "/home/greg/factorio13/config/config.bak.ini"
Jul 17 18:22:18 moneypit baloo_file[3100]: File moved to path which now no longer exists - "/home/greg/factorio13/config/config.bak.ini"
Jul 17 18:22:18 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/config/config.tmp.ini" -> "/home/greg/factorio13/config/config.ini"
Jul 17 18:22:18 moneypit baloo_file[3100]: org.kde.baloo: Moved without data
Jul 17 18:22:19 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/saves/second_try_008.zip" -> "/home/greg/factorio13/saves/second_try_008.bak.zip"
Jul 17 18:22:19 moneypit baloo_file[3100]: File moved to path which now no longer exists - "/home/greg/factorio13/saves/second_try_008.bak.zip"
Jul 17 18:22:19 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/saves/second_try_008.tmp.zip" -> "/home/greg/factorio13/saves/second_try_008.zip"
Jul 17 18:22:19 moneypit baloo_file[3100]: org.kde.baloo: Moved without data
Jul 17 18:22:24 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/config/config.ini" -> "/home/greg/factorio13/config/config.bak.ini"
Jul 17 18:22:24 moneypit baloo_file[3100]: File moved to path which now no longer exists - "/home/greg/factorio13/config/config.bak.ini"
Jul 17 18:22:24 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/config/config.tmp.ini" -> "/home/greg/factorio13/config/config.ini"
Jul 17 18:22:24 moneypit baloo_file[3100]: org.kde.baloo: Moved without data
Jul 17 18:22:24 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/config/config.ini" -> "/home/greg/factorio13/config/config.bak.ini"
Jul 17 18:22:24 moneypit baloo_file[3100]: File moved to path which now no longer exists - "/home/greg/factorio13/config/config.bak.ini"
Jul 17 18:22:24 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/config/config.tmp.ini" -> "/home/greg/factorio13/config/config.ini"
Jul 17 18:22:24 moneypit baloo_file[3100]: org.kde.baloo: Moved without data
Jul 17 18:22:25 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/saves/_autosave3.zip" -> "/home/greg/factorio13/saves/_autosave3.bak.zip"
Jul 17 18:22:25 moneypit baloo_file[3100]: File moved to path which now no longer exists - "/home/greg/factorio13/saves/_autosave3.bak.zip"
Jul 17 18:22:25 moneypit baloo_file[3100]: org.kde.baloo: "/home/greg/factorio13/saves/_autosave3.tmp.zip" -> "/home/greg/factorio13/saves/_autosave3.zip"
Jul 17 18:22:25 moneypit baloo_file[3100]: org.kde.baloo: Moved without data
Of course this would mean that there would no longer be a nice consistent layout across platforms like we have now. Actually isn't there already some kind of .ini file that controls where these things go?

Re: [Linux] Comply with the XDG directory standard

Posted: Sat Aug 06, 2016 8:38 pm
by Zok
golfmiketango wrote:Of course this would mean that there would no longer be a nice consistent layout across platforms like we have now.
Thats why I suggested the alternative of using $XDG_DATA_HOME for everything instead of scattering the files across the XDG directories. Would get stuff out of the way in an XDG compliant way but still keep the data directory in the same format across all platforms.

Re: [Linux] Comply with the XDG directory standard

Posted: Sun Aug 07, 2016 1:52 am
by Oxyd
Zok wrote:Not sure if this belongs in a bug report or a suggestion, I'll post it here feel free to move it if its out of place.
Moved to Ideas and Suggestions.

Re: [Linux] Comply with the XDG directory standard

Posted: Wed Feb 28, 2018 12:28 pm
by betrok
Up.
Not a big deal, but it is better to keep ~ clean.
Just move everything from ~/.factorio to ~/.local/share/factorio (or $XDG_DATA_HOM/factorio in case variable is set) will be fine.

Re: [Linux] Comply with the XDG directory standard

Posted: Wed Feb 28, 2018 2:52 pm
by quyxkh
It's easy enough to get close in an el-cheap-o frontend, I've got a ~/bin/Factorio that does various convenience things but I've never bothered breaking the engine's runtime directory's innards down that far. Factorio's runtime aka write-data directory isn't a good match for any of the XDG standards, it combines runtime, cache, config and data. For so long as its usage doesn't match any of the XDG standards, I think it shouldn't be moved to any of the XDG standard directories. I think splitting cache and runtime can't be done properly with the way they've got it organized now, config can be split with a symlink, and most of data with symlinks for saves, scenario and script-output, but achievements and blueprints are mixed in with the scratch and cache. So it seems to me any overworked sysadmin who's after a nice clean layout set up to ease his workload managing automated backup and garbage collection for dozens-and-up sites is going to be disappointed, this looks like a game built for single-user private home directories.

Why would any administration tool that sees a home-directory dot dir that isn't covered by XDG rules be assigning semantics to its contents anyway? Seems to me that's a tool problem.

Re: [Linux] Comply with the XDG directory standard

Posted: Sun Sep 16, 2018 5:56 pm
by Static_Rocket
I would love to see this game conform to XDG Base Directory specification, but, just to put the specifications perceived importance into perspective, KDE had their name attached to it when it was released in 2003 but five years later, when KDE4 was released, didn't conform itself. (Of course now it follows the spec, but it also keeps the old violating folders active for "compatibility reasons.") It is absolutely frustrating to have the user directory cluttered by endless .directories, but unfortunately I don't think it will get any better.

Re: [Linux] Comply with the XDG directory standard

Posted: Sat Jul 04, 2020 3:20 am
by tiritto
It's been around 4 years since this topic was created but ugly /.factorio still clutter our /home directories. This game already has amazing support for Linux and yet it's such a letdown on such simple matter as following XDG. Please, consider following the XDG standard.

Re: [Linux] Comply with the XDG directory standard

Posted: Mon Sep 14, 2020 8:03 pm
by zjeffer
+1

It's really ugly having that folder in ~/

Re: [Linux] Comply with the XDG directory standard

Posted: Mon Sep 14, 2020 8:49 pm
by valneq
Oh yea, +1 from me too, if it actually matters for the devs.

Re: [Linux] Comply with the XDG directory standard

Posted: Mon Sep 14, 2020 9:16 pm
by sparr
There's some partially outdated info on the wiki that might help with writing a launcher script and doing some directory rearrangement to come closer to compliance: https://wiki.factorio.com/Application_d ... _directory

What I think would be possible would be to move ~/.factorio to ~/.local/share/, use the -c parameter to tell factorio where the config.ini is located, then in config.ini set the path settings to look in that new location. Or something more complex that also includes a ~/.config/factorio and some symlinks.

Re: [Linux] Comply with the XDG directory standard

Posted: Sun May 16, 2021 7:09 pm
by tiritto
Almost an entire year has passed since my first message and almost 5 years since this thread has been created, and yet this is still an issue.
I would just like to note that this isn't exactly just a cosmetic change, as it would cause actual problems when someone's home directory is set to read-only.

Re: [Linux] Comply with the XDG directory standard

Posted: Sun May 16, 2021 7:19 pm
by ptx0
tiritto wrote: Sun May 16, 2021 7:09 pm Almost an entire year has passed since my first message and almost 5 years since this thread has been created, and yet this is still an issue.
I would just like to note that this isn't exactly just a cosmetic change, as it would cause actual problems when someone's home directory is set to read-only.
it's not an issue for anyone else. home directory being read only isn't a thing that should happen anyway. maybe you should just move on.

Re: [Linux] Comply with the XDG directory standard

Posted: Thu Sep 02, 2021 7:36 pm
by tiritto
ptx0 wrote: Sun May 16, 2021 7:19 pm
tiritto wrote: Sun May 16, 2021 7:09 pm Almost an entire year has passed since my first message and almost 5 years since this thread has been created, and yet this is still an issue.
I would just like to note that this isn't exactly just a cosmetic change, as it would cause actual problems when someone's home directory is set to read-only.
it's not an issue for anyone else. home directory being read only isn't a thing that should happen anyway. maybe you should just move on.
I've seen a few people (mostly ricers) actually going for that route. Going with the argument that it just "shouldn't happen", I think it's worth to note that doing so is NOT against the standard, whereas creating .factorio folder in $HOME directory is something that shouldn't happen even more since it actually do violate the XDG standard.

Re: [Linux] Comply with the XDG directory standard

Posted: Sun Sep 05, 2021 3:53 pm
by ptx0
tiritto wrote: Thu Sep 02, 2021 7:36 pm
ptx0 wrote: Sun May 16, 2021 7:19 pm
tiritto wrote: Sun May 16, 2021 7:09 pm Almost an entire year has passed since my first message and almost 5 years since this thread has been created, and yet this is still an issue.
I would just like to note that this isn't exactly just a cosmetic change, as it would cause actual problems when someone's home directory is set to read-only.
it's not an issue for anyone else. home directory being read only isn't a thing that should happen anyway. maybe you should just move on.
I've seen a few people (mostly ricers) actually going for that route. Going with the argument that it just "shouldn't happen", I think it's worth to note that doing so is NOT against the standard, whereas creating .factorio folder in $HOME directory is something that shouldn't happen even more since it actually do violate the XDG standard.
calling someone a ricer is a pretty fucked, racist slur, intended toward people who modify their vehicles.. we've all seen The Fast & The Furious.

and anyone who modifies their vehicle to put nitrous oxide is voiding their warranty.

similarly, anyone who makes their home directory read-only better know why they want that, and that the consequences include things like being unable to create directories in the home directory.

if they wanted a readonly home directory they can put another filesystem into fstab pointing at their /home/$USER/.factorio directory.

they can use bind mounts.

they can symlink it.

you can do whatever you want. these people aren't a concern for Wube.

it's annoying because you think your XDG standards are so important, but it'll make life harder for everyone as their stuff disappears on update. it's literally zero functional benefit.

Re: [Linux] Comply with the XDG directory standard

Posted: Wed Sep 21, 2022 8:37 pm
by SoYman
I would really like there to be an option to use the XDG directory standard. It's common for programs to migrate by supporting both XDG and the old way.
There is very often an environment variable like $FACTORIO_DATA_DIR or similar that can be configured to comply with XDG.
ptx0 wrote: Sun Sep 05, 2021 3:53 pm it's annoying because you think your XDG standards are so important, but it'll make life harder for everyone as their stuff disappears on update. it's literally zero functional benefit.
many people find it beneficial to have an uncluttered home directory while having dotfiles visible. Making it configurable wouldn't make life harder for anyone.

Re: [Linux] Comply with the XDG directory standard

Posted: Fri Sep 23, 2022 10:43 pm
by ptx0
SoYman wrote: Wed Sep 21, 2022 8:37 pm many people find it beneficial to have an uncluttered home directory while having dotfiles visible. Making it configurable wouldn't make life harder for anyone.
you could just run everything in a filesystem namespace if clutter is the reason for this. then you can do that on your own, without bothering the devs

Re: [Linux] Comply with the XDG directory standard

Posted: Fri Jun 09, 2023 4:04 pm
by lyghters
ptx0 wrote: Fri Sep 23, 2022 10:43 pm
SoYman wrote: Wed Sep 21, 2022 8:37 pm many people find it beneficial to have an uncluttered home directory while having dotfiles visible. Making it configurable wouldn't make life harder for anyone.
you could just run everything in a filesystem namespace if clutter is the reason for this. then you can do that on your own, without bothering the devs
You have to be kidding me. The responsibility of "dot files pollution" is on developers of any given software, not on it's users. Unless there is a way to set an environment variable or any other way to control the path to config directory (or even better - why not actually comply with the existing standard)? If namespaces are your answer to this problem, why not suggest having games in virtual machines? Or even set up another PC for Factorio exclusively? Implementing a way to control where to store config files is such a trivial matter (but not for the user, because it is hardcoded in this case), that I find it insulting to say that we're "bothering the devs"

Re: [Linux] Comply with the XDG directory standard

Posted: Mon Jun 12, 2023 3:44 am
by Rseding91
lyghters wrote: Fri Jun 09, 2023 4:04 pm … Unless there is a way to set an environment variable or any other way to control the path to config directory …
There is and it has already been mentioned in this thread.

Re: [Linux] Comply with the XDG directory standard

Posted: Fri Jun 23, 2023 2:12 am
by sparr
Following up to mention that the wiki docs at https://wiki.factorio.com/Application_directory are in pretty awful shape.