well-known user folders, a proposal

Alexander Larsson alexl at redhat.com
Thu Feb 22 07:28:21 PST 2007


On Thu, 2007-02-22 at 09:32 -0500, Dan Winship wrote:
> On Thu, 2007-02-22 at 12:11 +0100, Alexander Larsson wrote:
> > In order to make it really easy for scripts to use this we store the
> > user settings in a form that is compatible with /bin/sh. This means
> > you can use them as simple as:
> > source ~/.config/user-dirs.dirs
> > echo $XDG_DOWNLOAD_DIR
> 
> That works for scripts that are part of the distro, but apps that need
> to work on either pre- or post- xdg-user-dirs-compliant systems would
> need something like
> 
>         test -f ~/.config/user-dirs.dirs && source ~/.config/user-dirs.dirs
>         echo ${XDG_DOWNLOAD_DIR:-~}
> 
> (And shouldn't "~/.config" be "${XDG_CONFIG_HOME:-~/.config}"?)

Yeah, there are a few more details to get it really right. You must also
handle defaults if there is no file.

> Probably best to provide a simple shell function people can copy+paste
> into their script, and then just do
> 
>         echo `xdg-user-dir DOWNLOAD`
> 
> And also provide an installed version of that script, which could also
> be used by perl/python/ruby programmers who don't want to bother parsing
> user-dirs.dirs by hand.

Yeah, that makes sense. But it has to be something very simple with no
dependencies that people can cut and paste easily. A lot of apps
probably don't want a runtime dependency of the xdg-user-dir package.

> > One of the risks with localized filenames on disk is that people don't
> > use the right API to find the right place, but instead just hardcode
> > $HOME/Desktop. This is a common problem in windows where people
> > hardcode the path to "Programs Files", instead of using the right API
> > to find it, causing most users of non-english windows to have two such
> > dirs (one translated, one english).
> 
> I think this will be less of a problem for us because of the whole open
> source / release early, release often thing. People will get it wrong in
> version 0.1 of their app, but only 12 people will run it anyway, and one
> of them will report the bug, and then it will be fixed in 0.2.

Thats true for released apps, but I'm thinking also about the millions
of custom inhouse scripts that people tend to have. These don't have
public bugtrackers, etc.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl at redhat.com    alla at lysator.liu.se 
He's a genetically engineered guerilla photographer with a secret. She's a 
radical Buddhist mechanic from aristocratic European stock. They fight crime! 




More information about the xdg mailing list