8 ms·
Instead of putting a dotfile or dotdir in the user's home directory, do follow the XDG Base Directory specification: http://standards.freedesktop.org/basedir-sp
by keyist 14y ago
Instead of putting a dotfile or dotdir in the user's home directory, do follow the XDG Base Directory specification: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html http://standards.freedesktop.org/basedir-spec/basedir-spec-l... .
It's easy to understand and requires only a marginal increase in effort/code.
- oofabz 14y agoI am always pleasantly surprised when programs follow XDG. One notable example is the fish shell. Most shells put dotfiles in $HOME, like .bash_profile or .zshrc. Fish puts everything in .config/fish/.
- moe 14y agoI see no benefit. It's not at all easy to understand, nor easy to implement, nor does it have any tangible advantages. It's one of these superfluous pseudo-standards that do nothing but add needless clutter. But gladly nobody seems to be using it anyway, I see only one directory in my ~/.local: vlc.
- subway 14y agoCheck out your .config and .cache directories.
- keyist 14y agoI consider it good practice to allow users to customize where your program creates files. I don't like $HOME to be the default dumping ground for anything I run. A standard that uses environment variables means programs don't have to provide extra options for this customization (I've seen -f,--file , -c,--config and other variants). It allows for common code (libraries that implement the spec). If you poke around for feature requests for various open source programs, you'll find XDG basedir compliance come up occasionally (moreso for CLI utils). I wouldn't say "nobody seems to be using it"; quick scan of my folders includes Chromium, uzbl, htop. Git's next release will be compliant too.
- tedunangst 14y agoI don't particularly like dumping everything in home, but XDG is worse. Now, if I want to start over with a clean profile, there's a whole list of locations I have to zap. Spraying shit in three directories is worse than one.
- johnny22 14y agomy problem with that "one" directory is that i have to take care specifically to back it up. applications that at least use ~/.cache means i don't have to worry about backing up a bunch of useless stuff.
- yaix 14y agoIsn't that what /tmp is for? Why not put cache files into /tmp/<username> with 0700 permission?
- daxelrod 14y agoNo, that's not necessarily what /tmp is for. Consider a browser cache. /tmp is not guaranteed to be preserved between program invocations[1]. /var/tmp [2] might be a better place. /var/cache [3] is intended for exactly this kind of thing. Unfortunately, it can be far more useful for an administrator in a multi-user setup to want user-specific caches in home directories. That way, you get all of the infrastructure for managing user data for free, like quotas. Also note: if you're considering putting data into /tmp or /var/tmp, please honor the TMPDIR environment variable, if it is set[4]. [1]: http://www.pathname.com/fhs/pub/fhs-2.3.html#TMPTEMPORARYFILES http://www.pathname.com/fhs/pub/fhs-2.3.html#TMPTEMPORARYFIL... [2]: http://www.pathname.com/fhs/pub/fhs-2.3.html#VARTMPTEMPORARYFILESPRESERVEDBETWEE http://www.pathname.com/fhs/pub/fhs-2.3.html#VARTMPTEMPORARY... [3]: http://www.pathname.com/fhs/pub/fhs-2.3.html#VARCACHEAPPLICATIONCACHEDATA http://www.pathname.com/fhs/pub/fhs-2.3.html#VARCACHEAPPLICA... [4]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03 http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_...
- anamax 14y ago
- sciurus 14y ago~/.local isn't primarily where you should look; check ~/.config
- darkarmani 14y agoIt's only used by those few users that use SSH.
- tedunangst 14y ago? ssh keeps its files in ~/.ssh.
- jlgreco 14y ago[jlgreco@local] ~ % find ~/.config ~/.local | grep ssh | wc -l 0 So.. no.
- aroman 14y agoActually, it is in considerably wide use for desktop linux applications. It definitely has tangible benefits as well -- it promotes the clear separation of app data and user configuration, and unclutters the home folder. And as pointed out by other replies, ~/.local is not the only XDG data dir. I'm curious, how do you find it not easy to implement?
- davvid 14y agoI see no benefit. How about consistency?
- lmm 14y agoWhen there are forty years of existing applications using ~/.appname?
- dfc 14y agoYou are running a modern linux distro with only one file/dir in .local?
- tammer 14y ago% cd ~/.local cd: no such file or directory: /home/tammer/.local % uname -s -r Linux 3.4.7-1-ARCH
- nucleardog 14y agoFreeBSD 7.1-RELEASE - No ~/.local, ~/.config FreeBSD 9.0-RELEASE - No ~/.local, ~/.config Linux 3.2.0-23 - No ~/.local, ~/.config Linux 3.0.0-16 - No ~/.local, ~/.config Linux 3.0.0-12 - No ~/.local, ~/.config Honestly, I'd never even heard of this scheme before today.
- dfc 14y agoI guess I should have said "a modern linux desktop environment." Are these shell boxes or desktops? In my experience the majority of propgrams that use this spec are gtk/qt programs. PS Listing a kernel version does not really provide any information about your modern linux distro.
- darkestkhan 14y agoInteresting... I have ~/.cache, ~/.local and ~/.config and all 3 of them have quite a lot of subdirs and dotfiles inside.
- gioele 14y ago> I see no benefit. The first benefit is that it removes clutters from your $HOME. The second benefit is that you can now manage and backup your settings in a sane way. * ~/.config contains config files (should not be lost, but if lost you can recreate them); * ~/.local contains user data files (save them often, never lose them for they are not replaceable); * ~/.cache contains cached information (can be tmpfs mounted, you can delete it any time you want, no loss in functionality, you just lose some optimization); * ~/.run is for temporary system files (must be tmpfs mounted or it must be cleaned during at shutdown or power on). Luckily most of the apps used on Linux systems now use it, you are probably using Mac OS X.
- onli 14y ago> The first benefit is that it removes clutters from your $HOME. Invisible clutter? That's a strange concept. But the rest of your point indeed makes sense. It still is easier and probably comment to backup the whole $HOME. But those points you can see as a benefit, though not obvious.
- deleted 14y ago[deleted]
- lubutu 14y agoAs Rob mentions in his post, the more dotfiles there are in $HOME the slower path resolution for any subfiles becomes. How do we navigate to ./src? We open the directory and read all the entries until we find the one called "src". What happens if we encounter a morass of dotfiles beforehand? src takes a while to find. The clutter may be invisible to you, but it does gum up the works.
- duaneb 14y agoUnless you have many thousands of files, I can't imagine you would ever notice a slowdown.
- kbolino 14y agoFor what it's worth, most modern file systems (JFS, XFS, ext4, reiserfs, btrfs, ...) have logarithmic (or better) directory lookup times. This is achieved using hashes and b-trees (or even hash tables).
- vrotaru 14y agofind .local/ | wc -l 618 So I guess it depends on your Linux flavor. Mine is Ubuntu 12.04.
- malkia 14y agoSomehow .dotfiles work just fine under Windows :). As such they are somehow more "portable" Emacs saves them under %USERPROFILE% - I have in there - .alice, .android, .easyhg, .eclipse, .gstreamer-0.10, .lighttable, .m2, .matplotlib, .... .VirtualBox, .zenmap Also in "Application Data" - .emacs.d, .mc, .subversion My point is - this system works somehow even under non-unixy systems. Because it's simple.
- Dylan16807 14y ago%APPDATA% is as simple as home but much better on the clutter front.
- DeepDuh 14y agoTrue. I actually kinda like the Windows directory structure since Vista. If only the application devs would also follow the standard (hence the whole My Documents mess).
- strictfp 14y agoIt didn't use to work. I think it was added for XP SP2 or so, probably due to the popularity of manu *nix ports like Emacs.
- pjmlp 14y agoIt always did, at least in NTFS. What did not, and still does not, is to create them via Windows Explorer. You can create them just fine from the command line, or via Windows APIs.
- joe_the_user 14y agoI notice the $XDG_DATA_HOME environment variable isn't set in my Intrepid install. Maybe its set in later Ubuntu version. But the value not being set for me means implies to me that it not being set is pretty common. Thus it seems like supporting this standard is going to involve supporting a fall-back of whatever you would do otherwise. So I don't see "easy" at all but rather extra BS. Sorry.
- angusgr 14y agoFrom the spec: If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used. Similarly there's a default (.config/) defined for XDG_CONFIG_HOME. So the fallback is well-defined rather than "whatever you would do otherwise". Also, for my 2c, you should consider updating your Intrepid install if you at all can. It hasn't been supported for over two years, so it hasn't seen any security updates in that time. The Ubuntu do-release-upgrade system is pretty easy and reliable.
- ricardobeat 14y ago$HOME/.local/share doesn't exist on OSX either.
- masklinn 14y agoIf it does not exist, you've not used a soft using it. I have one.
- ricardobeat 14y agoNot much of a standard then - I have done hundreds of installs.
- bkor 14y agoXDG is a freedesktop standard. Meaning: checking that standard on OS X is a bit strange.
- jeltz 14y agoI would have preferred if it did not rely on environment variables since almost nobody sets them which means there will be untested code in applications implementing the specification.
- takluyver 14y agoWhere possible, applications should rely on tested libraries to implement the specification, like PyXDG.
- yaix 14y agoOn my system (Xubuntu), these environment variables are empty. Seems not to be much of a standard.
- saljam 14y agoTo be fair, that's how it works. They have default values when they're not set. These are for when you want to override them, e.g. to keep cache files local instead of over your net mounted home directory.