#Packager: George Vlahavas <vlahavas~at~gmail.com>

pkgname=gdm
pkgver=2.20.11
pkgrel=4rl
source=("ftp://ftp.gnome.org/pub/gnome/sources/gdm/2.20/gdm-$pkgver.tar.bz2" "Shine.tar.gz" "StairWay.tar.gz" "SalixLila.tar.gz" "SalixBlue.tar.gz" "gdm-2.20.10-numlockx.patch")
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo" "maintainters")
dotnew=(/etc/gdm/custom.conf)
options=('noautodotnew' 'nosrcpack')

doinst() {
# Update the scrollkeeper database (Remove stale pieces)
if [ -x usr/bin/scrollkeeper-update ]; then
	usr/bin/scrollkeeper-update > /dev/null 2>&1
fi
}

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"gdm (the Gnome Display Manager)"
"GDM is the little program that runs in the background, runs your X"
"sessions, presents you with a login box and then tells you to bug off"
"because you forgot your password. It does pretty much everything that"
"you would want to use xdm for, but does not involve as much crack. It"
"does not use any code from xdm, and has a more paranoid and safer"
"design overall. It also includes many features over xdm, the biggest"
"one of which is that it is more user friendly, even if your X setup"
"is failing. The goal is that users should never, ever have to use the"
"command line to customize or troubleshoot GDM." 
)


build() {
	cd $startdir/src/$pkgname-$pkgver

	patch -p1 < $startdir/src/gdm-2.20.10-numlockx.patch || exit 1

	./configure --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX} --localstatedir=/var/state --sysconfdir=/etc --disable-static --disable-scrollkeeper --with-prefetch=no --build=$arch-slackware-linux
	make || return 1
	make install DESTDIR=$startdir/pkg
	
	# gnome should not be an option in the menu if it's not installed
	rm $startdir/pkg/usr/share/xsessions/gnome.desktop

	rm -rf $startdir/pkg/usr/share/omf
	rm -rf $startdir/pkg/usr/share/gnome

	cp -a $startdir/src/Shine/ $startdir/pkg/usr/share/gdm/themes/ || return 1
	cp -a $startdir/src/StairWay/ $startdir/pkg/usr/share/gdm/themes/ || return 1
	cp -a $startdir/src/SalixLila/ $startdir/pkg/usr/share/gdm/themes/ || return 1
	cp -a $startdir/src/SalixBlue/ $startdir/pkg/usr/share/gdm/themes/ || return 1
	chown -R root:root $startdir/pkg/usr/share/gdm/themes

	sed -i "s/^Exec=.*/Exec=gksu gdmsetup/" $startdir/pkg/usr/share/gdm/applications/gdmsetup.desktop
	sed -i "/^TryExec/d" $startdir/pkg/usr/share/gdm/applications/gdmsetup.desktop
	sed -i "s|^#Greeter=\(.*\)|Greeter=/usr/libexec/gdmgreeter|" $startdir/pkg/usr/share/gdm/defaults.conf
	sed -i "s/^#DefaultSession=\(.*\)/DefaultSession=xfce.desktop/" $startdir/pkg/usr/share/gdm/defaults.conf
	sed -i "s/^#GtkTheme=\(.*\)/GtkTheme=Clearlooks-Phenix/" $startdir/pkg/usr/share/gdm/defaults.conf
	sed -i "s/^#GraphicalTheme=\(.*\)/GraphicalTheme=Shine/" $startdir/pkg/usr/share/gdm/defaults.conf
	sed -i "s/^AllowRoot=\(.*\)/AllowRoot=false/" $startdir/pkg/usr/share/gdm/defaults.conf

	sed -i "s|exit 0|[ -x /etc/gdm/Init/custom ] \&\& /etc/gdm/Init/custom\n\nexit 0|" $startdir/pkg/etc/gdm/Init/Default
	sed -i "s|exit 0|[ -x /etc/gdm/PostSession/custom ] \&\& /etc/gdm/PostSession/custom\n\nexit 0|" $startdir/pkg/etc/gdm/PostSession/Default
	sed -i "s|exit 0|[ -x /etc/gdm/PreSession/custom ] \&\& /etc/gdm/PreSession/custom\n\nexit 0|" $startdir/pkg/etc/gdm/PreSession/Default
}