Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 12. Follow XDG-spec

I'm so glad to see this included. I don't like $HOME being cluttered with .<app> config directories, but worse than that, far too many when releasing on macOS say Oh Library/Application\ Support/<app>/vom/something is the standard config location on Mac, so I'll respect XDG on Linux but on Mac it should go there. No! Such an unfriendly location for editable config files.



Erroneously naming it "XDG-spec" is not very good, though. It is the "XDG Base Directory Specification", just one of several XDG specs.

* https://freedesktop.org/wiki/Specifications/

* https://standards.freedesktop.org/


I agree that seeing a bunch of ~/.<app> directories is annoying, but at the same time I do think that it makes sense for each application to manage its own hierarchy, rooted under e.g. ~/.apps/<app> instead of splitting it into ~/.config/<app>, ~/.local/share/<app>, etc.

Regardless, I think it probably makes sense to have a uniform interface for getting said directories, so that however the OS decides things should be laid out, the developer just needs to `local_config_dir(app_name)`. If the user (or at least administrator) can decide between <app>/<function> and <function>/<app>, all the better.


The reason ~/.config/app is superior, is that then you can e.g. backup all your configs, or remove your cache, or store ~/.local and ~/.cache on a local fs and the rest of ~ on NFS.

Do you have to use ~/.config/app/ or could you just use ~/.config/app.conf?


I am having an impossible time verifying this, but I recall reading that MacOS deletes unaccessed files eventually from `~/Library/Caches/*`. Which would be a compelling reason to use that for cache. (Not being able to verify this I didn't add it to the article)

If anyone can verify that I'm either right or wrong here that would be helpful.


OSX does not automatically delete from that directory. See: https://developer.apple.com/library/archive/documentation/Ge...

> Your app is responsible for cleaning out cache data files when they are no longer needed. The system does not delete files from this directory.

However, many third-party tools delete from that directory with minimal caution if any, so it's a good idea to consider it ephemeral.


appreciate the clarification!


Regrettably, OSX recommends the use of the Library/Application Support directory, and provides several utility APIs for getting config/cache/data locations which point there as well: https://developer.apple.com/library/archive/documentation/Ge...

In general, if I'm targeting OSX, I use those locations as recommended, but make symlinks to relevant config/etc. from there to the XDG-suggested locations.


Yes, also it should be in the top half, #12 makes it sound not very important. Certainly before "be fancy."




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: