384 points · by notamy · 3y ago · 239 comments
My current dotfiles [1] already have a lot of these and they mostly just work. Once in a while an application won't respect it completely, and so instead of having a mess with xdg + whatever the dev though was cooler I just let the application do it's thing so at least is somewhat predictable.
[0]: https://github.com/b3nj5m1n/xdg-ninja
[1]: https://github.com/DoodlesEpic/Dotfiles/blob/main/.profile
Was thinking this would be a useful tool, same as a tool that would show you where environment variables are being set, and which ones override what.
[0]: https://github.com/evanpurkhiser/dots-personal/blob/main/bas...
there's a non-exhaustive list of applications on the archwiki [0] that put their config/data in dotfiles in the home directory. surprisingly, there's also lots of pushback from maintainers of projects who don't want to change this, for whatever excuse they can produce. a Reddit thread has some list of issues where the change is brought up [1].
Anyway, I'll look forward to testing this out.
[0] https://wiki.archlinux.org/title/XDG_Base_Directory
[1] https://www.reddit.com/r/linux/comments/971m0z/im_tired_of_f...
On one hand, it's great to have all the stuff in the same place, on the other hand, we used to have this, before the ~/.config folder too.
Also, it's not just in one place anymore, but in many places -- so to completely remove a programX, it's not enough to just remove ~/.programX, but you need to remove a folder from ~/.config/, and another one from ~/.local/something, and another form ~/.cache,...
So yeah, i understand 'the old guys' too... maybe because i'm not 20-something anymore.
https://web.archive.org/web/20180827160401/https://plus.goog...
Obviously, we are now stuck with dotfiles as a "feature", but that doesn't mean we need to have more of them than necessary. Cluttering the home folder with a disorganized mess of files with different modalities next to eachother is ridiculous, pointless, and a collective waste of time.
Almost all of the apps people are complaining about not following XDG were created long after the XDG base directory specification existed. It's time to move on.
P.S.: it'd be preferable also if it wasn't simply implied that everyone who's been around Linux/UNIX for a couple decades hates change. Churn for the sake of churn is bad, but churn is not all wasted. Standardizing once-disorganized directory hierarchy is certainly not a waste of time.
Look at ~/.wine for example... config files, whole C drive, everything in one simple folder. Want to upgrade to an alpha version to test something, but don't want to break anything that's now working? Just backup that one single folder. Restore or migrate configuration to another computer? One single folder. Remove any trace of that app? Again, one simple folder.
Want to do the same with google chrome? .config/google-chrome... oh wait, what if there's something in .local too? Still doesn't work? Oh wait, you forgot the .cache directory, and have been loading an old version of something.
vault
flyctl
yarn
npm
vscode
terraform
rustup
kubernetes
fzf
eclipse
docker
cargo
aws (cli)
There's no excuses for these programs not respecting standards that are 1. Well established by the time the software was written and 2. short (seriously, the standard's contents fit entirely on three A4 pieces of paper)[0] - https://specifications.freedesktop.org/basedir-spec/basedir-...
This isn't a standard, it's a convention at best. A freedesktop.org specification. Basically a scheme Red Hat people thought up and implemented widely in the open source software projects they control. It may be a useful abstraction but there's absolutely no obligation to conform to it. There doesn't have to be an "excuse" or any form of justification at all. "I just don't like it" is enough. I don't like those unsightly XDG variables either and it's entirely within my power as a software developer to trash the entire concept of XDG and do things in any way I see fit.
https://www.freedesktop.org/wiki/Specifications/
> freedesktop.org produces specifications for interoperability, but we are not an official standards body.
> There is no requirement for projects to implement all of these specifications, nor certification.
But take a step further back: why should anyone care about what the XDG says in first place? This isn't a dictatorship, and things were doing just fine long before a handful of people who wrote the XDG thought their ideas were the best approach.
It's been my observation that good standards can be adopted broadly and quickly with little controversy or need for advocacy. The fact that the XDG file layout still isn't universally used suggests it doesn't have as much value as its proponents think.
If i want to completely remove wine from my profile, how many folders do I have to delete doing it the old way? One - ~/.wine. How many using the new? One in .config, then .local/share, probably one in .cache... oh wait, .local/state too.. Probably.. well, maybe, I'd have to check manually. Same for other software. One folder to remove, one folder to backup, one folder to restore.
There is a single base directory relative to which user-specific data files should be written. This directory is defined by the environment variable $XDG_DATA_HOME.
There is a single base directory relative to which user-specific configuration files should be written. This directory is defined by the environment variable $XDG_CONFIG_HOME.
Neither of those environment variables is defined on a stock Ubuntu 22.04.1 LTS.
> most all of the Linux software dumping dotfiles in my homedir
then is it really true, that the standard is in fact "well established"?
Do people seriously resist such non-destructive improvements just because they think it's offensive when younger programmers have opinions on legacy software?
OTOH if you want to completely remove your cache, or completely backup your config...
I realize that you wrote "new kids" in quotes, but these "new kids" might have grandchildren at this point given that the initial draft of the XDG Base Directory Specification was published in 2002.
My sympathy is lacking, as is my respect for those running projects that hardcode paths. Stop hardcoding paths and the world will be a better place.
Having a couple of directories to clean up is a bit annoying, but they used to stick the config file in your home and then make an application directory so we were already having to deal with multiple locations.
The software can look at $XDG_WHATEVER/tool/config first and ~/.toolrc second. Everyone who wants the clutter can keep using that.
(I'm looking at you, Slack!)
How awesome would it be to be able to back up my custom app configs just by copying around one tiny folder? Or throwing it in a git repo and knowing what config changed when? :\
$ du -sch ~/.config/Slack
846M $HOME/.config/Slack
846M total
... this is on a two day old machine. WTF, Slack? Junk cached data belongs in ~/.local/share ($XDG_DATA_HOME), not ~/.config.On Linux that excuse is gone, so it's just either 'oops yes will fix' or 'agh, sorry, legacy'. Nobody (that I've ever seen) tries to claim something else is fine or better.
I opened your links. There's no easy way to judge the traction or popularity of this. Why do you think maintainers should just apply another standard that's thrown at them?
I don't mean to be dismissive nor criticize the standard itself. I'm trying to give you a glimpse of what a person that hasn't heard about XDG before sees, when they open your links.
Those 2 aren't standards and aren't helpful.
There doesn't need to be an "excuse" though. "I don't like it" or "I don't want to do it" is more than enough. They're the ones maintaining the damn things, the least we can do is respect them. They don't really need to justify anything, acting as if they had to is how you get pushback. They probably deny you just to prove that you have no power over them, because you insinuated otherwise with words like "excuse".
we don't respect maintainers who leave in buffer overruns or x-site scripting, why should we respect maintainers who don't respect users? yes, they're writing and maintaining, but undoubtedly also using tons of respectful opensource that other maintainers take care of.
it's like driving a car ("everybody faster than me is a maniac, everybody slower than me is a moron") and cursing cyclists, then jumping on your bike and running red lights, stop signs, crosswalks, sidewalks, you name it. To have a civilized society we all have to go out of our way a little bit for other people, throw away some trash that's not yours.
like forum/reddit moderator phenomenon, there is something about the power (and most definitely the nagging they get from impolite users) that makes the developers act like douches when they probably aren't the rest of the time.
but that's not an excuse for crapping all over my dotfiles and home directory tree.
Saying that using dotfiles instead of ~/.config means they "don't respect users" is a little dramatic, don't you think? Like it or not, unix has historically treated dotfiles as "hidden" and nobody expects you to get upset that they created a hidden file in your home directory without your consent. It's not really about respect, it's just convention you apparently don't like.
I currently have 60 dotfiles in my home directory and probably deliberately created less than 10 of those. The fact that anyone would be upset by this is news to me and most likely is news to a lot of the developers that created these things: cargo, dbus, docker, gem, gnome, gnupg, gphoto, java, kde, maven, mozilla, osquery, rpm, rustup, ssh, vagrant, vim, vscode, wget, yarn, zoom. Not that "this bad behavior is widespread" is a good excuse, but the point is that I don't think the world is at all in agreement that this is "bad behavior."
Because they're the ones putting in the work. I could patch all the programs to use whatever paths I liked best if I really cared but the truth is I don't want to put in that much effort. So I just work with what I'm given instead.
Besides, dotfiles conventions are not even in the same category of technical decision as literal vulnerabilities. One puts people at actual risk, the other is just opinion on file system taxonomy.
I mean, I have opinions on proper file system organization too and they certainly don't match Unix "tradition" but I don't go to other people's issue trackers and shame other developers when they make "excuses" for not following whatever scheme I thought up. I have reasons and I can certainly try to convince others that I'm right but it's simply offensive to show up out of nowhere with an indignant tone demanding that others make changes of a subjective and frankly trivial nature and then criticizing them in other forums when they refuse.
I don't want all my pictures to go in Pictures, all my documents in Documents, etc. I want everything from each project to go in the directory for that project. I don't need it to read my mind, but when I save a document to a new directory and then I want to save a spreadsheet too... I want that new directory to be a top-line choice, but I want the old directory there too.
Doesn't everybody work like me? (asking seriously)
and hey, call me a freak, but I still get the odd sort of picture that I don't want showing up on the lock screen screensaver
Because the XDG Base Directory Specification does not dictate about how files should be saved - whether in Pictures/, Documents/, or anything else...
And macOS has Xxx.localized directories
Only XDG based systems use real /home/user/ドキュメント (in Japanese) directory . This is annoying. Please localize it well as Win/mac does.
The Desktop, Downloads, Pictures, etc. directories themselves are not from the XDG Basedir spec and not set by XDG_ environment variables but instead in the $XDG_CONFIG_HOME/user-dirs.dirs file. I also find these less useful than the more generel data/config/cache dirs and have most theme set to my home directory - perhaps that is affecting how Firefox works?
And I frequently jump from desktop to desktop for multiple projects, and my terminal on that desktop is likely to already be where I want to be. Do gui apps reliably reload xdg all the time, or only at startup?
anyway, keeping it in mind, it might just be worth the trouble to click a scripted icon on each desktop :)
https://tomwh.uk/blog/posts/2020/03/28/fake-home-prison/
https://tomwh.uk/git/fake-home.git/
It's a simple command that shadows the binary names you want with a wrapper in ~/.local/bin/ that calls the original binary after redefining $HOME to be somewhere else (by default inside ~/.local/share/fake-home/).
So if you have a program foo that dumps stuff in ~/.foo, then running `fakehome-banish foo` will create a symlink "foo" inside ~/.local/bin/evil-software (which is added to $PATH) that points to "fakehome".
"fakehome" is a simple wrapper script that, busybox-style, gets the binary name that it's being called as ("foo"), and then sets $HOME to be ~/.local/share/fakehome and calls the original foo binary.
You have no idea how much of a thing this was?
People either loved her or got irrationally angry if she was ever brought up to the point of committing federal crimes
You may also be able to tell I don't have a lot of AWS experience (:
Boxxy seems good enough for userspace.
Are you aware of any notable caveats to using Boxxy, given the mount-based implementation? E.g., will this continue to work if you sync ~/ with other machines (rsync, FTP, SyncThing)?
Thanks :D
> Are you aware of any notable caveats to using Boxxy, given the mount-based implementation?
System configuration to allow mount namespaces, tools might have to understand recursive paths, it's tested for my use-cases.
> E.g., will this continue to work if you sync ~/ with other machines (rsync, FTP, SyncThing)?
I haven't tried it! Would love to see what happens as that's unfortunately not a use-case I have.
Also note that any scripts with config stored in these mountpoints (which seems to be the point of the tool) will not be able to run until the mountpoints are up. That seems like an obvious observation, but it's easy to fall into a trap where one of your scripts installed with this tool is called in a setup script that runs on boot of your machine.
(earlier less-relevant comment was deleted)
_JAVA_OPTIONS="-Djava.util.prefs.userRoot=${XDG_CONFIG_HOME}/programName" programName
echo snap >> ~/.hidden
By the way, as for the original motivation:
> I recently had to use the AWS CLI. It wants to save data in ~/.aws, but I don't want it to just clutter up my $HOME however it wants. boxxy lets me force it to puts its data somewhere nice and proper.
- they could have used AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE.
> alias aws="boxxy aws" (repeat for other tools)
If you could find a way to somehow intercept without requiring aliasing, this would be amazing.
Also, as it is, isn't it problematic that programs might call others (outside of your shell, not respecting its aliasing).
A neat semi-solution (still worse than transparent interception if somehow possible) would be to have a boxxy-run script sym-linkable from ~/whatever/bin/aws (say) that basically just executes `boxxy "$(basename "$0")"`. So you could just symlink the same script with the name of whatever command you wanted to 'boxx'.
I figured out while testing that `boxxy sh` works as expected, so I would imagine you can wrap any shell in it since it’s just a mount namespace.
> Also, as it is, isn't it problematic that programs might call others (outside of your shell, not respecting its aliasing).
Nope! Any spawned processes live inside the same mount namespace and see the same pretend view of the world.
As the program intercepts file APIs for all processes launched under it, it should handle subprocesses just fine.
Now I need both boxxy foobar and boxxy aws configured for the same ~/.aws redirection.
Really interesting project for other use cases too btw.
I don't use macOS often-enough to know for sure, but a quick search suggests that bind-mounts (or similar) are more complicated on macOS. Not against the idea tho!
Edit:
> and would massively simplify how I build my dotfiles.
I guess I should tell r/unixporn at some point, huh? (:
So much for checking all of $HOME/.config into a Git repository.
Course, might not work so well with the way boxxy is run ... unless you chsh to boxxy bash or something.
What's so bad about symlinks though?
notably, at some point i decided to encrypt my valuables: password store, PII, etc, and have them unlocked on login via PAM. i also wanted these to be locked when i lock my session. if you have, say, a ~/private mountpoint with sensitive stuff, and then ~/.password-store (for your password manager) pointing somewhere into this store, 2 things can happen when you `umount ~/private`
1. if ~/.password-store was a bind mount over ~/private/, your decrypted passwords will still be accessible through ~/.password-store.
2. if ~/.password-store was a symlink into ~/private/, then your passwords aren’t accessible.
chances are you wanted (2), and it might be scary when you discover that’s not what you had, months after setting it up…
i’ve also had some nasty mount duplication, where some cron job bind-mounts the same thing every hour. turns out linux will happily let you create identical bind mounts as many times as you want, until `/proc/mounts` has 2000 entries and some O(n^2) behavior somewhere in systemd’s namespace setup makes `systemctl start foo` take 3 minutes before invoking any service code. that was a PITA to figure out. the worst thing that happens when you “mount” the same thing twice when using symlinks, on the other hand, is you get some very obvious nesting. so anyway, i’ve bit myself a few too many times. i’m very weary to reach for bind mounts anywhere symlinks can also do the job.
Could you please share a general outline for configuring something like this?
if you can make a /etc/fstab entry for your filesystem, then you can configure pam_mount using the same options as the fstab entry and it should work.
for the actual encrypted filestore, i’m using gocryptfs. it’s a more actively developed alternative to eCryptfs: mostly a drop-in replacement. there’s a lot of options here: dm-crypt over a dedicated partition is probably what a cryptographer would recommend, everything else is making tradeoffs (e.g. leaking metadata like file size/directory entry count) for better UX elsewhere. read the wiki to pick the best for your needs :)
on the off-chance you’re using NixOS, i configure these parts here:
- https://git.uninsane.org/colin/nix-files/src/commit/bcfd8e17... - https://git.uninsane.org/colin/nix-files/src/commit/bcfd8e17...
I am not smart and will regularly forget the syntax to ln(1)
`mklink [[/d] | [/h] | [/j]] <link> <target>` `ln [OPTION]... [-T] TARGET LINK_NAME`
uhmmm... uh....
TROOOLUH TROOOLUH
BEATLES
TROOOLUH TROOOLUG
he, like, remixed
buh buh buh BUUUUUHHHH
my favorite Boxxy autotune remix is this one https://www.youtube.com/watch?v=7Q7cqT3BiOI
It's us taking this ship to its end. o7
I would like to see the ages and sign up numbers over the years.