#
# restore SuSE defaults
#
. /etc/sysconfig/windowmanager

if [ "$INSTALL_DESKTOP_EXTENSIONS" = "yes" ]; then
  if [ "$USER" != "root" ]; then
   
     kdesktopfile="$HOME/.kde/share/config/kdesktoprc"
     if [ ! -e "$HOME/.skel/kdebase3.wallpaper101" -a -e "$kdesktopfile" ]; then
	 if ! fgrep -q "[Desktop0]" "$kdesktopfile"; then
		WALLPAPER=$(/opt/kde3/bin/startkde.pick_wallpaper)
		echo "[Desktop0]" >> "$kdesktopfile"
		echo "Wallpaper=$WALLPAPER" >> "$kdesktopfile"
	 else
	        w=`sed -n -e '/^\[Desktop0\]/,/^\[/ s,^Wallpaper=\(.*\),\1,p' "$kdesktopfile"`
                # expand $HOME and other stuff
		eval "wallpaper=\"$w\""
	        if [ ! -e "$wallpaper" ]; then
		      WALLPAPER=$(/opt/kde3/bin/startkde.pick_wallpaper)
		      sed -e "/^\[Desktop0\]/,/^\[/ s,^Wallpaper=\(.*\),Wallpaper=$WALLPAPER," "$kdesktopfile" > "$kdesktopfile.new" && \
		         mv "$kdesktopfile.new" "$kdesktopfile"
	        fi
	 fi
	 mkdir -p "$HOME/.skel"
	 touch "$HOME/.skel/kdebase3.wallpaper101"
     fi
  fi
fi
