Yes, you too can store and retrieve user specific and system wide application configuration and other support files in a clean, robust and standardized way.

What is this all about?

The XDG Base Directory Standard provides a common means for specifying one or more base directories relative to which support files can be located. Using the XDG standard, applications can find and store application specific support files (eg. config files, data caches, etc.) in a universal, clean and robust fashion. The advantages of this standard is that all such files will be found in central locations easily descernable by man and machine. And, if widely adopted, XDG can clear up our HOME directories of all those pesky hidden files!

See XDG Base Directory Standard Specification.

Who's using the XDG Standard?

Why should I use the XDG standard?

Because if you don't then... you suck! ;-)

No, seriously, if your program depends on user-relative or sytem-wide support files, it will be much improved by using the XDG Base Directory Standard. Not only does it provide a clean yet flexible standard, it also make your life easier. The find and select methods make it a snap to locate support files.

What can XDG standard ultimately do?

How about turning this:

    $ ls -a ~/

    .ICEauthority     .gconf                .qt                    
    .Xauthority       .gconfd               .rdoc                  Documents
    .Xsession         .gem                  .recently-used         Download
    .adobe            .gftp                 .recently-used.xbel    EMail
    .aptitude         .gimp-2.4             .ri                    Friends
    .aspell.en.prepl  .gitconfig            .ruby_inline           Jobs
    .aspell.en.pws    .gksu.lock            .rubyrc                Mail
    .bash_history     .gnome                .sane                  Manifest.txt
    .bash_logout      .gnome2               .shoes                 Media
    .bashrc           .gnome2_private       .ssh                   Memento
    .bogofilter       .gnupg                .subversion            Music
    .cache            .gstreamer-0.10       .themes                Notebook
    .camel_certs      .gtk-bookmarks        .thumbnails            Personal
    .compiz           .gtk-recordmydesktop  .tremulous             Photos
    .config           .gtkrc-1.2-gnome2     .update-manager-core   Pics
    .dbus             .gvfs                 .update-notifier       Pictures
    .dbus-keyrings    .icons                .vim                   PonyArchive
    .dia              .irb_history          .viminfo               Public
    .diakonos         .irbrc                .vimrc                 Sort
    .dmrc             .local                .vlc                   Templates
    .dvdcss           .macromedia           .w3m                   Videos
    .dvdrip           .metacity             .wapi                  current
    .dvdrip-master    .mozilla              .xine                  dvdrip-data
    .dvdriprc         .mplayer              .xinitrc               links.xml
    .eee              .mysql_history        .xsession-errors       programs
    .esd_auth         .nautilus             Archive                projects
    .etc              .openoffice.org2      Art                    ruby
    .evolution        .pgadmin3             Bookmarks              sandbox
    .fastri-index     .pgpass               Books                  tags
    .fehbg            .profile              Company                tigerops
    .fehrc            .pulse                Contacts
    .fontconfig       .pulse-cookie         Desktop
    .fr-KVIe0s        .purple               Diff.txt
    

Into this:

    $ ls -a ~/

    .cache            Diff.txt              Music                  Videos
    .config           Documents             Notebook               current
    .local            Download              Personal               dvdrip-data
    Archive           EMail                 Photos                 links.xml
    Art               Friends               Pics                   programs
    Bookmarks         Jobs                  Pictures               projects
    Books             Mail                  PonyArchive            ruby
    Company           Manifest.txt          Public                 sandbox
    Contacts          Media                 Sort                   tags
    Desktop           Memento               Templates              tigerops
    

How to Install the XDG Ruby Library

Using RubyGems

      $ sudo gem install xdg
      

Using RubyRolls

      $ sudo roll install xdg
      

Site Installation (Using the tarball)

Installing the tarball requires Ruby Setup (see http://setup.rubyforge.org).

      $ tar -xvzf xdg-0.4.0
      $ cd xdg-0.4.0
      $ sudo setup.rb all
      

Windows users will have to use 'ruby' in place of 'sudo'.

How to Use the XDG Ruby Library

It's really quite easy, since these are all the methods:

      XDG.config_home
      XDG.config_dirs
      XDG.config_find(pattern){ |path| ... }
      XDG.config_select(pattern){ |path| ... }

      XDG.data_home
      XDG.data_dirs
      XDG.data_find(pattern){ |path| ... }
      XDG.data_select(pattern){ |path| ... }

      XDG.cache_home
      XDG.cache_find(pattern){ |path| ... }
      XDG.cache_select(pattern){ |path| ... }

      XDG.config_work
      XDG.cache_work
      

You can also include XDG into a class and you will get all these methods as well.

      class X
        include XDG
      end
      x = X.new
      x.config_home
      

See the API documentation for more details.