#!/bin/sh
#
# A simple script to reset a specific user's desktop settings
#

if [ ! "$1" ]
then
	echo
	echo "usage: $0 <username>"
	echo
	exit
fi

HOMEDIR=`eval "echo ~$1"`

cd $HOMEDIR || { 
	echo
	echo "Ack! the home directory of $1 was not found, aborting"
	echo
	exit
}

# out with the old
for dir in .kde .gnome_private .gconfd .gconf .nautilus .gnome-desktop .gtkrc \
           .sawfish .gnome
do
	if [ -d $HOMEDIR/$dir ]
	then
		rm -rf $HOMEDIR/$dir &> /dev/null
	fi
done
for file in .screenrc 
do
	if [ -f $HOMEDIR/$file ]
	then
		rm -rf $HOMEDIR/$file &> /dev/null
	fi
done

# in with the new
for new in .screenrc .gtkrc .kde .gnome-desktop
do
	cp -a /etc/skel/$new $HOMEDIR/ &> /dev/null
	chown -R --reference=$HOMEDIR $HOMEDIR/$new &> /dev/null
done
