homedir subdirectories, counter-proposal

Alexander Larsson alexl at redhat.com
Tue Feb 20 16:45:20 UTC 2007


On Sun, 2007-02-18 at 12:09 -0500, David Zeuthen wrote:
> Hi,
> 
> Given the F7 schedule was pushed back one month I thought perhaps we
> could spend this time on polishing stuff.
> 
> It looks like gnome-screensaver already drops a directory Pictures
> in /etc/skel/Pictures [1] to ensure that the user gets the directory
> ~/Pictures. Personally, I'm a big fan of having pre-made directories in
> a new users home directory. Mostly because it allows us to patch our
> applications so they open the file chooser in the right directory. 
> 
> I think we ought to do more of this. I also think we ought to formalize
> a bit. 

Ok. Here is a counter-proposal for translations-on-disk:
http://www.gnome.org/~alexl/xdg-user-dirs-0.0.1.tar.gz

Here is how it works:
Somewhere (early) in the login scripts we run xdg-user-dirs-update. It
reads a config file in /etc/xdg/user-dirs.conf, and a list of defaults
for user dirs in /etc/xdg/user-dirs.defaults (by default, it also
respects the xdg basedir spec if you want to tweak it). It also loads
the current user dir configuration in ~/.config/user-dirs.dirs, if it
exists.

For each default specified dir type (DESKTOP, TEMPLATES, etc) that is
not already in the user config the directory-name is decided based on
the default config and translations in gettext. This directory is
created and the user config is updated to point to it. 

Some old directories (like ~/Desktop) are special cased such that a
translated version of them are not created if the old one exists
already. This gives some backwards compatibility.

If a user-configured directory doesn't exist anymore (the user deleted
it) we don't recreate it, instead we change the settings to point it to
$HOME.

There is also a --force flag that ignores any existing settings and just
creates and sets up localized dirs.

The user config files for the dirs is in a form that allows shell
scripts to do:
source ~/.config/user-dirs.dirs
echo $XDG_DOWNLOAD_DIR

Included in the source is a ANSI-C version of xdg_user_dir_lookup() that
is just one function and calls only libc functions. Its easy to cut and
paste into any application if we need to patch them. For real desktop
integration the idea is that the desktops themselves would add support
for this in their platform libraries.


Here is how the current default config files look, as an example:
/etc/xdg/user-dirs.conf:
-----
enabled=True
----

/etc/xdg/user-dirs.defaults:
-----
# Default settings for user directories
#
# The values are relative pathnames from the home directory and
# will be translated on a per-path-element basis into the users locale
DESKTOP=Desktop
DOWNLOAD=Download
TEMPLATES=Templates
PUBLICSHARE=Public
DOCUMENTS=Documents
MUSIC=Music
PHOTOS=Photos
# Another alternative is:
#MUSIC=Documents/Music
#PHOTOS=Documents/Photos
-----

And here is a typical ~/.config/user-dirs.dir 
-----
# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line your interested in
# All local changes will be retained on the next run
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is shell-escaped. No other format supported.
# 
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Nerladdat"
XDG_TEMPLATES_DIR="$HOME/Templates"
XDG_PUBLICSHARE_DIR="$HOME/Public"
XDG_DOCUMENTS_DIR="$HOME/Dokument"
XDG_MUSIC_DIR="$HOME/Musik"
XDG_PHOTOS_DIR="$HOME/Foton"
-----

Opinons?

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl at redhat.com    alla at lysator.liu.se 
He's an ungodly pirate boxer looking for a cure to the poison coursing through 
his veins. She's a man-hating hypochondriac barmaid from a family of eight 
older brothers. They fight crime! 




More information about the Fedora-desktop-list mailing list