For example, the "Desktop" folder on a french Ubuntu Intrepid is "Bureau", but if I read the source code correctly "$HOME/Desktop" is hard-coded and used when under GNOME (did not try KDE).
Created attachment 21029 [details] [review] Proposed patch for xdg-desktop-icon, using user-dirs.dirs
Don't forget about (global): /etc/xdg/user-dirs.conf
Comment on attachment 21029 [details] [review] Proposed patch for xdg-desktop-icon, using user-dirs.dirs --- xdg-desktop-icon.bak Sun Jun 24 20:57:56 2007 +++ xdg-desktop-icon Thu Dec 11 22:51:11 2008 @@ -496,6 +496,15 @@ my_umask=077 desktop_dir="$HOME/Desktop" +# Is xdg-user-dirs present and enabled ? +if [ -e /etc/xdg/user-dirs.conf ] && cat /etc/xdg/user-dirs.conf | grep enabled=True > /dev/null; then + DESKTOP=Desktop + # Try to get global defaults + test -f /etc/xdg/user-dirs.defaults && source /etc/xdg/user-dirs.defaults + # Try to get user-defined settings + test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs + desktop_dir=${XDG_DESKTOP_DIR:-$HOME/$DESKTOP} +fi desktop_dir_kde=`kde-config --userpath desktop 2> /dev/null` if gconftool-2 -g /apps/nautilus/preferences/desktop_is_home_dir 2> /dev/null | grep true > /dev/null; then desktop_dir_gnome="$HOME"
Come to think of it, why not just use the output from: xdg-user-dir DESKTOP ? (if the tool exists, and returns non-empty of course).
Sounds reasonable. But after looking at the xdg-user-dir source, it seems it would return the desktop directory configured in user-dirs.dirs (if it contains any) or default to $HOME/Desktop, even when user-dirs.conf says enabled=False, and ignore user-dirs.defaults (if I'm not mistaken).
Comment on attachment 21029 [details] [review] Proposed patch for xdg-desktop-icon, using user-dirs.dirs I've updated the patch because there was still a problem on some systems (Error "source: not found"). Also, I've added support for kde4 and spaces in desktop directory and file names should now also work. I can confirm this patch is working on atleast three distributions (tested by another user on fedora 9 livecd with norwegian gnome and ubuntu 8.10 with norwegian gnome, and tested by me on german opensuse 11 with kde4 and gnome and desktop directory renamed to "Schreibtisch") --- xdg-desktop-icon.bak Sun Jun 24 20:57:56 2007 +++ xdg-desktop-icon Sat Dec 20 02:07:42 2008 @@ -495,50 +495,71 @@ esac my_umask=077 -desktop_dir="$HOME/Desktop" +# Is xdg-user-dirs present and enabled ? +if ( [ -e ${XDG_CONFIG_HOME:-~/.config}/user-dirs.conf ] && cat ${XDG_CONFIG_HOME:-~/.config}/user-dirs.conf || ( [ -e /etc/xdg/user-dirs.conf ] && cat /etc/xdg/user-dirs.conf ) ) | grep enabled=True > /dev/null; then + DESKTOP=Desktop + # Try to get global defaults + [ -f /etc/xdg/user-dirs.defaults ] && . /etc/xdg/user-dirs.defaults + # Try to get user-defined settings + [ -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs ] && . ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs + desktop_dir=${XDG_DESKTOP_DIR:-$HOME/$DESKTOP} +else + desktop_dir="$HOME/Desktop" +fi desktop_dir_kde=`kde-config --userpath desktop 2> /dev/null` +desktop_dir_kde4=`kde4-config --userpath desktop 2> /dev/null` if gconftool-2 -g /apps/nautilus/preferences/desktop_is_home_dir 2> /dev/null | grep true > /dev/null; then desktop_dir_gnome="$HOME" # Don't create $HOME/Desktop if it doesn't exist - [ -w $desktop_dir ] || desktop_dir= + [ -w "$desktop_dir" ] || desktop_dir= fi -if [ -n "$desktop_dir_kde" ]; then - if [ ! -d "$desktop_dir_kde" ]; then - save_umask=`umask` - umask $my_umask - mkdir -p $desktop_dir_kde - umask $save_umask - fi - # Is the KDE desktop dir != $HOME/Desktop ? - if [ x`readlink -f "$desktop_dir"` != x`readlink -f "$desktop_dir_kde"` ]; then - # If so, don't create $HOME/Desktop if it doesn't exist - [ -w $desktop_dir ] || desktop_dir= - else - desktop_dir_kde= +for x in "$desktop_dir_kde" "$desktop_dir_kde4" ; do + if [ -n "$x" ]; then + if [ ! -d "$x" ]; then + save_umask=`umask` + umask $my_umask + mkdir -p "$x" + umask $save_umask + fi + # Is the KDE desktop dir != $desktop_dir ? + if [ x"`readlink -f "$desktop_dir"`" != x"`readlink -f "$x"`" ]; then + # If so, don't create $desktop_dir if it doesn't exist + [ -w "$desktop_dir" ] || desktop_dir= + else + if [ "$x" = "$desktop_dir_kde" ]; then + desktop_dir_kde= + fi + if [ "$x" = "$desktop_dir_kde4" ]; then + desktop_dir_kde4= + fi + fi fi -fi -desktop_dir="$desktop_dir $desktop_dir_kde $desktop_dir_gnome" +done -basefile=`basename $desktop_file` +basefile=`basename "$desktop_file"` -DEBUG 1 "$action $desktop_file in $desktop_dir" +DEBUG 1 "$action $desktop_file in $desktop_dir $desktop_dir_kde $desktop_dir_kde4 $desktop_dir_gnome" case $action in install) save_umask=`umask` umask $my_umask - for x in $desktop_dir ; do - mkdir -p $x - eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output + for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_kde4" "$desktop_dir_gnome" ; do + if [ -n "$x" ]; then + mkdir -p "$x" + eval 'cp "$desktop_file" "$x/$basefile"'$xdg_redirect_output + fi done umask $save_umask ;; uninstall) - for x in $desktop_dir ; do - rm -f $x/$basefile + for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_kde4" "$desktop_dir_gnome" ; do + if [ -n "$x" ]; then + rm -f "$x/$basefile" + fi done ;;
Sorry for dropping the ball here, but later incarnations of the proposed patch are far from clear here. I'll try to do my best to integrate what I can, though I'll be honest up front and say I'm going with using the output of xdg-user-dir DESKTOP rather than manually parsing it's config files.
in cvs now.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.