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

pkgname=mate-desktop
pkgver=1.2.0
pkgrel=2gv
source=("http://pub.mate-desktop.org/releases/1.2/mate-desktop-1.2.0.tar.xz")
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo")
options=('noautodotnew')

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------------------------------------------------------|
"mate-desktop (The MATE Desktop environment)"
"The mate-desktop package includes common files needed for MATE"
"desktop apps (Pixmaps, .desktop files and internationalization files)."
)


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

	./autogen.sh --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX} --localstatedir=/var --sysconfdir=/etc --build=$arch-slackware-linux --disable-static --disable-scrollkeeper
	make -j $numjobs || return 1
	make install DESTDIR=$startdir/pkg

	mkdir -p $startdir/pkg/etc/mateconf/mateconf.xml.defaults
	mkdir -p $startdir/pkg/etc/mateconf/mateconf.xml.mandatory

	# wallpaper settings
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/background/primary_color "#8686acaccaca"
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/background/secondary_color "#7f7f7f7f7f7f"
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/background/color_shading_type solid
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type bool --set /desktop/mate/background/draw_background true
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/background/picture_options stretched
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/background/picture_filename /usr/share/xfce4/backdrops/StairWay.png
	# gtk theme and iconset
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/interface/gtk_theme Clearlooks
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/interface/icon_theme mate-brave
	# default apps
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/applications/browser/exec firefox
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type bool --set /desktop/mate/applications/browser/nremote false
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/applications/file/exec "caja %s"
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/applications/image/exec "viewnior %s"
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/applications/media/exec "whaawmp %s"
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/applications/video/exec "whaawmp %s"
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/applications/terminal/exec mate-terminal
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/applications/text/exec "leafpad %s"
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /desktop/mate/url-handlers/mailto/command "claws-mail --compose %s"
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type bool --set /desktop/mate/url-handlers/mailto/enabled true

	# remove unnecessary help files
	for i in fdl gpl lgpl; do
		find $startdir/pkg/usr/share/mate/help/$i/* -maxdepth 0 -type d ! -name C -exec rm -rf {} \;
	done
}