{"id":334,"date":"2008-01-05T02:19:52","date_gmt":"2008-01-04T16:19:52","guid":{"rendered":"http:\/\/www.erisian.com.au\/wordpress\/?p=334"},"modified":"2008-01-05T02:19:52","modified_gmt":"2008-01-04T16:19:52","slug":"user-configuration","status":"publish","type":"post","link":"https:\/\/www.erisian.com.au\/wordpress\/2008\/01\/05\/user-configuration","title":{"rendered":"User configuration"},"content":{"rendered":"<p>Inspired mostly by <a href=\"http:\/\/kitenet.net\/~joey\/blog\/entry\/big_storm_coming\/\">Joey&#8217;s<\/a> nonchalant way of dealing with the death of his laptop&#8230;<\/p>\n<blockquote>\n<p>This seems less of a disaster than other times a laptop&#8217;s disk has died on me. When did it start to become routine? [&#8230;] My mr and etckeeper setup made it easy to check everything back out from revision control. [&#8230;]<\/p>\n<\/blockquote>\n<p>&#8230;I&#8217;ve been looking at getting all my stuff version controlled too. I&#8217;ve just gotten round to checking all my dotfiles into git, and it crossed my mind that it&#8217;d be nice if I could just set an environment variable to tell apps to create their random new dot-files directly in my &#8220;.etc-garbage&#8221; repo. I figured using &#8220;$USER_ETC\/foo&#8221; instead of &#8220;$HOME\/.foo&#8221; would be pretty easy, and might be a fun release goal that other Debian folks might be interested in, so I did a quick google to see if something similar had already been suggested.<\/p>\n<p>The first thing I stumbled upon was <a href=\"http:\/\/mail.gnome.org\/archives\/desktop-devel-list\/2004-November\/msg00250.html\">a mail from the PLD Linux folks<\/a> who apparently were using $HOME_ETC at one time which sounded pretty good, though it doesn&#8217;t seem to have gotten anywhere. That thread included a <a href=\"http:\/\/mail.gnome.org\/archives\/desktop-devel-list\/2004-November\/msg00268.html\">pointer<\/a> to the system that has gotten somewhere which is the <a href=\"http:\/\/standards.freedesktop.org\/basedir-spec\/basedir-spec-0.6.html\">XDG spec<\/a>.<\/p>\n<p>It&#8217;s actually pretty good, if you don&#8217;t mind it being ugly as all hell.<\/p>\n<p>They define three classes of directory &#8212; configuration stuff, non-essential\/cached data, and other data. That more or less matches the \/etc, \/var\/cache and \/var\/lib directories for the system-wide equivalents, though if the &#8220;other data&#8221; is stuff that can be distributed by the OS vendor it might go in \/usr\/lib or \/usr\/share (or the \/usr\/local\/ equivalents) too.<\/p>\n<p>Which is all well and good. Where it gets ugly is the naming.<\/p>\n<p>For the &#8220;\/etc&#8221; configuration stuff, we have the environment variable $XDG_CONFIG_HOME, which defaults to ~\/.config, and has a backup path defined by $XDG_CONFIG_DIRS, which defaults to \/etc\/xdg.<\/p>\n<p>For the &#8220;\/var\/lib&#8221; other data stuff, we have the environment variable $XDG_DATA_HOME, which defaults to ~\/.local\/share, and has a backup path defined by $XDG_DATA_DIRS, which defaults to \/usr\/local\/share:\/usr\/share. (Though if you&#8217;re using gdm, it&#8217;ll get set for you to also include \/usr\/share\/gdm)<\/p>\n<p>And for the &#8220;\/var\/cache&#8221; stuff, we have the environment variable $XDG_CACHE_HOME, which defaults to ~\/.cache.<\/p>\n<p>That seems to me like exactly the right idea, with way too much crap on it. If you simplify it obsessively &#8212; using existing names, dropping the desktop-centrism, you end up with:<\/p>\n<p>Put configuration files in $HOME_ETC\/foo or $HOME\/.foo. For shared\/fallback configuration, search $PATH_ETC if it&#8217;s set, or just \/etc if it&#8217;s not.<\/p>\n<p>Put data files in $HOME_LIB\/foo or $HOME\/.foo. For shared data, search $PATH_LIB if it&#8217;s set, or look through \/var\/lib, \/usr\/local\/{lib,share} and \/usr\/{lib,share} if it&#8217;s not.<\/p>\n<p>Put caches in $HOME_CACHE\/foo or $HOME\/.foo. For shared caches, search $PATH_CACHE if it&#8217;s set, or just look in \/var\/cache if it&#8217;s not.<\/p>\n<p>That seems much simpler to me to the point of being self-explanatory, and much more in keeping with traditional Unix style. It&#8217;s also backwards compatabile if you use both old and new versions of a program with the same home directory (or you happen to like dotfiles). And having the XDG variables set based on the above seems pretty easy too.<\/p>\n<p>I wonder what other people think &#8212; does {HOME,PATH}_{ETC,LIB,CACHE} seem sensible, or is XDG_{CONFIG,DATA,CACHE}_{HOME,DIRS} already entrenched enough that it&#8217;s best just to accept what&#8217;s fated?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Inspired mostly by Joey&#8217;s nonchalant way of dealing with the death of his laptop&#8230; This seems less of a disaster than other times a laptop&#8217;s disk has died on me. When did it start to become routine? [&#8230;] My mr and etckeeper setup made it easy to check everything back out from revision control. [&#8230;] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/posts\/334"}],"collection":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/comments?post=334"}],"version-history":[{"count":0,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/posts\/334\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/media?parent=334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/categories?post=334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/tags?post=334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}