Live data from Hacker News

Use the XDG Base Directory Specification

xdgbasedirectoryspecification.com

131–140 of 214 posts

Re: Use the XDG Base Directory Specification

#132

Earlier quoted context omitted.

If everything honored this spec, including the part where it reads environment variables to see where the different directories are, you could do that by sticking the right variables in your environment. I think the one legitimate exception to the rule is profile, because you need that in order to set the variables in the first place. So that one would somehow have to be hard coded to at least have a wider search pat…

Honestly, when your xdg list gets huge, apps should just use xdg out of the box... my /etc/profile is 35 lines of just xdg junk.

What the heck are you talking about? The XDG basedir spec is three variables. The user dir spec is more but those are not environement variables.

Re: Use the XDG Base Directory Specification

#134
post #23

One of the things that changed my life recently, that I hadn't seen before: NeoVim has a NVIM_APPNAME variable that lets you change the app name. So when I wanted to try AstroVim, I just set NVIM_APPNAME=astrovim, and dropped the files in ~/.config/astrovim instead of blowing up my existing (shitty) ~/.config/nvim. I really wish the idea of configurable appnames was a part of the spec! (or a well-known extension!)

Historically a lot of programs would use argv[0] as their name. Vi-family editors do have an excuse not to do that, since vi uses its name for other purposes, e.g. `view` for readonly.

Re: Use the XDG Base Directory Specification

#135

Does it really help that much in practice? > Easier to share configuration settings I want to share my nvim config between both my home Linux machine and my Mac at work, but I don’t want to share my config for gnome and its apps. So now I’ve got to maintain a script to go one more subdirectory deep to pick which dotfiles to sync and which to ignore... > Easier to temporarily ignore the config > It is easiest to set X…

> Easier to create backups i want to mess up with wine, now I just backup ~/.wine, do whatever, restore. With split folders, i'd have to backup a bunch of folders (.config/wine, .local/share/wine, .local/lib/wine or wherever the files, registry, dosdevices and other stuff would be put).

  find ~ -type d -name "?wine" -exec cp -r "{}" /path/to/my/wine/backup/ \;

Re: Use the XDG Base Directory Specification

#136

It's important on any system, not just XDG. The OS will assume you do, and offer features based on it, such as cleaning cache dirs, emptying temp dirs, etc. It's not just about being tidy, although it's important. But remembering all that stuff is annoying. If you use Python, the wonderful "appdirs" package will make using the best dir for the job on Windows, Mac and Linux, easy and transparent: https://pypi.org/proj…

appdirs has officially been deprecated.

Its successor is https://pypi.org/project/platformdirs/

Re: Use the XDG Base Directory Specification

#137
post #131

Back in the old days I could delete `. ` and reset a program to its defaults. Now I have to navigate through `.config` and try to find where stuff is. How is this better?

No change, programs old and new should document where they litter their files. And if they do, you'll easily notice where in .config it will be.

Re: Use the XDG Base Directory Specification

#138
post #111
post #80

I actually just make my personal home directory in the root of the filesystem. So /me. If /root can have it, why can't I? It is my machine after all.

Beware that any directory other than one under /home might not enjoy the same protections by default by other programs, like systemd’s ProtectHome setting. You’ll also probably want to adjust some settings, like AppArmor’s @{HOMEDIRS} setting.

Does systemd really hardcode "/home" rather than use the user's actual home directory?

Re: Use the XDG Base Directory Specification

#139
post #86

Earlier quoted context omitted.

Do any of the Linux distros do this? Strikes me as the kind of thing Debian would do for everything in apt

Do you have any examples of Debian doing this?

Sure. In software of mine distributed by Debian, there's usually a "debian/patches" directory, that I didn't add, that's changes the Debian project wanted to make to the system. I'm sure there's a formal name for that system. Most Debian packages seem to have one.

Re: Use the XDG Base Directory Specification

#140

It's important on any system, not just XDG. The OS will assume you do, and offer features based on it, such as cleaning cache dirs, emptying temp dirs, etc. It's not just about being tidy, although it's important. But remembering all that stuff is annoying. If you use Python, the wonderful "appdirs" package will make using the best dir for the job on Windows, Mac and Linux, easy and transparent: https://pypi.org/proj…

Except neither appdirs or platformdirs obey xdg on Mac, without an option to override.

Which makes this less than ideal.

Post reply on HN