[Linux] Comply with the XDG directory standard

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
Zok
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sun Jul 31, 2016 7:59 pm
Contact:

[Linux] Comply with the XDG directory standard

Post 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

golfmiketango
Filter Inserter
Filter Inserter
Posts: 549
Joined: Fri Jan 29, 2016 2:48 am
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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?

Zok
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sun Jul 31, 2016 7:59 pm
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

betrok
Fast Inserter
Fast Inserter
Posts: 101
Joined: Wed Feb 28, 2018 12:08 pm
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

quyxkh
Smart Inserter
Smart Inserter
Posts: 1027
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

Static_Rocket
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sun Sep 16, 2018 5:35 pm
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

User avatar
tiritto
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Jul 04, 2020 3:10 am
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

zjeffer
Manual Inserter
Manual Inserter
Posts: 1
Joined: Fri Jun 07, 2019 8:15 pm
Contact:

Re: [Linux] Comply with the XDG directory standard

Post by zjeffer »

+1

It's really ugly having that folder in ~/

User avatar
valneq
Smart Inserter
Smart Inserter
Posts: 1149
Joined: Fri Jul 12, 2019 7:43 am
Contact:

Re: [Linux] Comply with the XDG directory standard

Post by valneq »

Oh yea, +1 from me too, if it actually matters for the devs.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

User avatar
tiritto
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Jul 04, 2020 3:10 am
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

User avatar
tiritto
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Jul 04, 2020 3:10 am
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

SoYman
Manual Inserter
Manual Inserter
Posts: 1
Joined: Tue Aug 11, 2015 5:53 pm
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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

User avatar
lyghters
Manual Inserter
Manual Inserter
Posts: 1
Joined: Fri Jun 09, 2023 3:54 pm
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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"
Last edited by lyghters on Fri Jun 09, 2023 4:04 pm, edited 1 time in total.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Linux] Comply with the XDG directory standard

Post 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.
If you want to get ahold of me I'm almost always on Discord.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: [Linux] Comply with the XDG directory standard

Post by sparr »

Following up to mention that the wiki docs at https://wiki.factorio.com/Application_directory are in pretty awful shape.

Post Reply

Return to “Ideas and Suggestions”