#!/bin/sh
#
# A simple script to reset a specific user's desktop settings
#
  HOMEDIR=`grep ^"${1}:" /etc/passwd | cut -d":" -f6`
UIDNUMBER=`grep ^"${1}:" /etc/passwd | cut -d":" -f3`
GIDNUMBER=`grep ^"${1}:" /etc/passwd | cut -d":" -f4`

[ "$HOMEDIR" -a "$UIDNUMBER" -a "$GIDNUMBER" -a -d "$HOMEDIR" ] || {
	echo
	echo "usage: $0 <username>"
	echo
	exit
}

cd $HOMEDIR || { 
	echo
	echo "Ack! $HOMEDIR not found, aborting"
	echo
	exit
}

# out with the old
for d in .screenrc .kde .gnome_private .gconfd .gconf .nautilus \
         .gnome-desktop .gtkrc .sawfish .gnome
do
	rm -rf ./$d &> /dev/null
done

# in with the new
for d in .screenrc .gtkrc .kde .gnome-desktop
do
	cp -a /etc/skel/$d . &> /dev/null
	chown -R ${UIDNUMBER}.${GIDNUMBER} ./$d &> /dev/null
done
