Live data from Hacker News

Use the XDG Base Directory Specification

xdgbasedirectoryspecification.com

101–110 of 214 posts

Re: Use the XDG Base Directory Specification

#101
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.

Exactly! Fixing /home/ is a lost cause. You can't get thousands of applications to follow a common sense standard. It's more pragmatic to not store the files you care about in the dumping ground that's /home/ .

Re: Use the XDG Base Directory Specification

#102
post #28

The second example is a nice start, but I'd really like to see invisible files/folders in ~/ done away with altogether. So starting with that example, I might add a visible ~/Library/ folder, then move ~/.config/ and ~/.local/ in there as ~/Library/Config/ and ~/Library/Local/ as normal visible folders. Same for .bashrc, .profile, etc; put them in ~/Library/Config/ without the dots.

What does Library actually mean though? ;)

Apple macOS. Don't ask…

Re: Use the XDG Base Directory Specification

#103
post #96

Earlier quoted context omitted.

.gitignore in $HOME/.config: ``` * !nvim/ !dunst/ !i3/ ``` Then you have a whitelist which is clearly not that hard to maintain For the cache, the opposite argument is just as true: If I want to clear cache from everything to save space, I can just `rm -rf ~/.cache` instead. And this case is a lot more common than wanting to "start from a clean profile" :/

> I can just `rm -rf ~/.cache But can you? Did you really close all the apps using ~/.cache? What if some app is just doing some cleanup operation, moves a bunch of stuff to cache, and the files are missing now? Did you just delete android studio cache in the middle of a compile? You can also make a script like your .config, but it's called "clear_cache.sh", where you hardcore a few paths you usually clean manually.

That was a bit exaggerated I never clean fully the cache, mostly just specific apps but as long as I have everything closed (GUI and CLI apps), I don't really care what background services are doing and if they get upset because of this. I'm not on a server, that's my laptop so there is no critical stuff going on and once the app I use are closed that's good enough

Re: Use the XDG Base Directory Specification

#104

Somebody should tell that to the Rust people. They have a .cargo and a .rustup folder in ~, plus an extra heavy target folder for every project. Would be much nicer if they put the cache one .cache But they don't seem to care https://github.com/rust-lang/cargo/issues/1734 https://github.com/rust-lang/rfcs/pull/1615 https://github.com/rust-lang/cargo/pull/9178

At least for rust applications of your own, you can use the library https://github.com/dirs-dev/directories-rs to follow XDG on Linux as well as platform conventions on Mac and Windows.

Re: Use the XDG Base Directory Specification

#105
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!)

Thanks for this tips! Didn't knew it either

Re: Use the XDG Base Directory Specification

#106
Yeah, we have a straightforward and widely established standard. Just put the related files in .programname .

Now let's bikeshed and scatter them randomly across several places. To make it more fun let's make those locations programmable with environment variables so you won't even know where to start looking for a particular related file. Add lots of categories to create ambiguity. Make some of the default locations single level and others multiple level directories for no apparent reason for extra fun.

Re: Use the XDG Base Directory Specification

#108

I have a very dumb question: why does the article use `find` with `printf` and depth specification, as opposed to the simpler `ls -a`? I'm assuming it has something to do with portability, but `ls -a` is already in POSIX. I'm a bit confused.

Hmm. I think it's because `ls -a` will not visually differentiate between files and folders and will also show `.`and `..`. and will span contents over columns while find will return a line by found items. Or they are a show-off.

They could have used

  ls -A -1 -p
which should result in the same output.

-A is like -a but will not print . and .. directories.

-1 prints one file per line.

-p appends / to directories.

There's a lot more flags in the man page: https://man7.org/linux/man-pages/man1/ls.1.html

Re: Use the XDG Base Directory Specification

#109

In what world is simply dumping config items for your app in the user's home directory sensible? Why stop at config items? Do cache or temp crap too. The thought process of persisting with this baffles me. Microsoft would be absolutely ridiculed if one day your msword preferences appeared on your desktop as an XML file, and no matter what, it kept reappearing.

  desktop.ini

Re: Use the XDG Base Directory Specification

#110
post #98

Earlier quoted context omitted.

export GOPATH=~/Projects/go Has been like this since forever.

Being like that for a long time is not a justification for terrible defaults.

That is a better default than a hidden directory. It is obvious and so you can set GOPATH

Also works better on Windows where .path is not hidden

Also it seems Rob Pike one of the creators of Go and involved with early UNIX thinks that . making hidden files was a mistake. Quote via XahLee http://xahlee.info/UnixResource_dir/writ/unix_origin_of_dot_... - original was Google+ so not existing now.

Post reply on HN