Home > Blog > The Ugly Duckling called $XDG_CONFIG_HOME

The Ugly Duckling called $XDG_CONFIG_HOME
1 star2 stars3 stars4 stars5 stars
(votes: 1, avg: 5.00)
Loading ... Loading ...

March 29th, 2009 Leave a comment Go to comments

Let’s take a look into my home directory:

[stick@spectra 0 ~] ls -F
Applications/  Documents/  google.txt    reverse-ssh*
Desktop/       Downloads/  public_html/  work/       

[stick@spectra 0 ~] ls -AF
.0verkill             google.txt              public_html/
.adobe/               .grails/                .pulse/
.android/             .gstreamer-0.10/        .pulse-cookie
Applications/         .gtk-bookmarks          .pyhistory
.AtomicWorm/          .gtkrc-2.0-kde4         .qt/
.bash_history         .gvfs/                  .rawstudio/
.bashrc               .hplip/                 .recently-used
.bouml                .htoprc                 .recently-used.xbel
.boumlrc              .hugin                  .repoconfig/
.bzr.log              .icedteaplugin/         reverse-ssh*
.cache/               .inkscape/              .rnd
.cddb/                .inputrc                .rpmpatch_macros
.cedega/              .IntelliJIdea80/        .rpmpatch_rpmrc
.civclientrc          .IntelliJIdea8x/        .scummvmrc
.civserver_history    .irssi/                 .signature-gk2
.config/              .java/                  .signature-gmail
.crack-attack/        .JxBrowser/             .signature-suse
.cxgames/             .kde/                   .skel/
.darkplaces/          .kde4/                  .Skype/
.dbus/                .kderc                  .smc/
.designer/            .kinorc                 .springrc
Desktop/              .ktorrent.lock          .sqlite_history
.directory            .lbrc.conf              .ssh/
.dmrc                 .lesshst                .strigi/
Documents/            .links/                 .subversion/
Downloads/            .liquidwarrc            .teeworlds/
.dvdcss/              .local/                 .thumbnails/
.eclipse/             .loki/                  .thunderbird/
.emacs                .macromedia/            .ufrawrc
.esd_auth             .mc/                    .ultramixer/
.fbhighlevelshistory  .mcop/                  .vendetta/
.fbhighscores         .miro/                  .viminfo
.fblevels/            .mixxxbpmscheme.xml     .vimrc
.fbrc                 .mixxx.cfg              .VirtualBox/
.fontconfig/          .mixxxmacros/           .vlc/
.fonts/               .MixxxMIDIBindings.xml  .vnc/
.fonts.conf           .mixxxtrack.xml         .w3m/
.gajim/               .mozilla/               .Wammu
.gconf/               .mplayer/               .wapi/
.gconfd/              .mysql_history          .windows-label
.gegl-0.0/            .mysticmine             .wine/
.gem/                 .netxrc                 .winetrickscache/
.gimp-2.6/            .nexuiz/                work/
.gitconfig            .ooo3/                  .Xauthority
.gnome/               .opera/                 .xim.template
.gnome2/              .osc_cookiejar          .xine/
.gnome2_private/      .oscrc                  .xsession-errors
.gnupg/               .profile                .y2usersettings
.google/              .psi/
.googleearth/         .psql_history

Out of 148 entries in my $HOME, there are only 12 of them I really want to see! How much nicer would it be, if it looked like this:

[stick@spectra 0 ~] ls -AF
Applications/  Documents/  public_html/    .signature-gmail
.config/       Downloads/  reverse-ssh*    .signature-suse
Desktop/       google.txt  .signature-gk2  work/

This is very simple to achieve, if only applications followed the XDG Base Directory Specification. Unfortunately, lots of them don’t. When you start using the following piece of code in your new awesome applications:

config = getenv("XDG_CONFIG_HOME")
if (!config) config = getenv("HOME") + "/.config"
config = config + "/my_awesome_app"

instead of the old-school one:

config = getenv("HOME") + "/.my_awesome_app"

users will gain two great advantages with nearly no extra effort:

  • trying application without overwriting the existing configuration
    XDG_CONFIG_HOME=/tmp/ my_awesome_app
  • maintaining multiple configurations of the same application
    XDG_CONFIG_HOME=~/.config/awesome3 my_awesome_app

So, please, don’t ignore the ugly duckling called $XDG_CONFIG_HOME, I’m sure it will mature into a beautiful swan. :)

  1. March 30th, 2009 at 16:05 | #1 | Firefox 3.0.8Ubuntu 8.10

    I think you got it wrong. Rename .signature-* to signature* and you are done.

    http://www.faqs.org/rfcs/rfc1925.html says:
    (6) It is easier to move a problem around (for example, by moving
    the problem to a different part of the overall network
    architecture) than it is to solve it.

    (6a) (corollary). It is always possible to add another level of
    indirection.

  2. March 30th, 2009 at 16:15 | #2 | Firefox 3.0.7openSUSE

    @Martin Vidner
    It’s not about the .signature* files. I just don’t want to have bloated $HOME with lots of hidden files I didn’t create. It is also convenient to backup ~/.config to your USB drive (other location) without checking out which hidden directory/file is needed and which isn’t. The two tricks I mentioned at the end of article are quite useful too.

  3. October 7th, 2009 at 05:36 | #3 | Google Chrome 4.0.213.1GNU/Linux x64

    First off, I’m a big fan of XDG_CONFIG_HOME. I found out about it thanks to awesomewm.

    I am a tiny bit confused. Are the two tricks you mention for use in application development (in general or specific to awesomewm?), or configuring your /etc/profile, .bashrc or something similar?

  4. October 7th, 2009 at 10:52 | #4 | Opera 10.00GNU/Linux

    @Albert
    The tricks are for applications in general (nothing specific to awesomewm, I just used awesome as an adjective, because your applications are awesome for sure :-) )

  1. No trackbacks yet.
or