#Maintainer: Thorsten Muehlfelder <thenktor(at)gmx.de>

pkgname=openbox
pkgver=3.4.11.2
pkgrel=3tm
source=("http://icculus.org/openbox/releases/openbox-$pkgver.tar.gz")
docs=("readme" "install" "copying" "changelog" "authors" "news")
url=http://icculus.org/openbox
option=("noautodotnew")
dotnew=("etc/xdg/openbox/rc.xml" "etc/xdg/openbox/menu.xml")

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"Openbox (A lightweight Window Manager for the X11 window system)"
"Openbox is a minimalistic, highly configurable, next generation"
"window manager with extensive standards support."
)


build() {
	cd $startdir/src/$pkgname-$pkgver
	./configure --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX} --localstatedir=/var --sysconfdir=/etc
	make -j $numjobs || return 1
	make DESTDIR=$startdir/pkg install || return 1

	mkdir -p $startdir/pkg/etc/X11/xinit/
	cat << EOF > $startdir/pkg/etc/X11/xinit/xinitrc.openbox
#!/bin/sh

userresources=\$HOME/.Xresources
userdefaults=\$HOME/.Xdefaults
usermodmap=\$HOME/.Xmodmap
sysresources=/usr/lib/X11/xinit/.Xresources
sysmodmap=/usr/lib/X11/xinit/.Xmodmap
 
# merge in defaults and keymaps
[ -f \$sysresources ] && xrdb -merge \$sysresources
[ -f \$sysmodmap ] && xmodmap \$sysmodmap
[ -f \$userresources ] && xrdb -merge \$userresources
[ -f \$userdefaults ] && xrdb -merge \$userdefaults
[ -f \$usermodmap ] && xmodmap \$usermodmap

# Here comes some desktop pimpness
[ -e /usr/libexec/notification-daemon ] && /usr/libexec/notification-daemon &

#Force OpenOffice.org to use GTK theme
export OOO_FORCE_DESKTOP=gnome

# start the openbox session, if possible attached to consolekit
if [ -e /usr/bin/ck-launch-session ]; then
	exec /usr/bin/ck-launch-session /usr/bin/openbox-session
else
	exec /usr/bin/ck-launch-session
fi
EOF
	chmod 755 $startdir/pkg/etc/X11/xinit/xinitrc.openbox
	
	# fix doc location
	mkdir -p $startdir/pkg/usr/doc/$pkgname-$pkgver
	mv $startdir/pkg/usr/share/doc/$pkgname/* $startdir/pkg/usr/doc/$pkgname-$pkgver/ || return 1
	rm -r $startdir/pkg/usr/share/doc/
}