# vim: set syn=sh:
# Packager: Phill Watkins <ubemail~at~ymail~dot~com>
# Former Packager(s): George Vlahavas (vlahavas~at~gmail~dot~com)

pkgname=wbar
pkgver=2.1.1
pkgrel=1pw
#arch=
source=("http://wbar.googlecode.com/files/wbar-$pkgver.tar.gz" "wbar.cfg.gz" "icons.tar.gz" "wbar-autostart.gz")
sourcetemplate=http://people.salixos.org/pwatk/packages/13.2/xap/$pkgname
#docs=()
url=http://code.google.com/p/wbar/
options=('nosrcpack' 'noautodotnew')

doinst() {
	if [ -x usr/bin/update-desktop-database ]; then
	  usr/bin/update-desktop-database > /dev/null 2>&1
	fi

	if [ -x usr/bin/gtk-update-icon-cache ]; then
	  usr/bin/gtk-update-icon-cache -f usr/share/icons/hicolor > /dev/null 2>&1
	fi
}

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"wbar (Quick launch bar)"
"wbar is a quick launch bar. Its fast, light and cool eye-candy."
"Its hacked in c++ trying to keep code as readable as possible"
"with out sacrificing speed. It works directly on top of X to avoid"
"going throug a lot of layers. Initially developed for Fluxbox, then"
"tested on WindowMaker, Xfce, Gnome, etc. Since version 1.0 can run"
"on top of desktops such as xfdesktop or nautilus with the"
"-above-desk switch."
)

build() {
	set -e
	
	cd $startdir/src/$pkgname-$pkgver
	# fix pidof path
	sed 's|pidof|/sbin/pidof|g' -i src/config/Run.cc
	./configure \
	  --prefix=/usr \
	  --exec-prefix=/usr \
	  --sysconfdir=/etc \
	  --localstatedir=/var \
	  --libdir=/usr/lib${LIBDIRSUFFIX} \
	  --mandir=/usr/man \
	  --infodir=/usr/info \
	  --docdir=/usr/doc/$pkgname-$pkgver \
	  --build=$arch-slackware-linux
	make -j $numjobs
	make install DESTDIR=$startdir/pkg

	cat $startdir/src/wbar.cfg > $startdir/pkg/etc/default/wbar/wbar.cfg
	install -d $startdir/pkg/usr/share/pixmaps/wbar/salix
	install -m 0644 $startdir/src/icons/* $startdir/pkg/usr/share/pixmaps/wbar/salix
	install -m 0755 $startdir/src/wbar-autostart $startdir/pkg/usr/bin/

	rm $startdir/pkg/usr/share/pixmaps/wbar.png
	install -Dm 0644 pixmaps/wbar.png $startdir/pkg/usr/share/icons/hicolor/128x128/apps/wbar.png
	for icon in 16 22 24 32 48 64 ;do
	  install -d $startdir/pkg/usr/share/icons/hicolor/${icon}x${icon}/apps
	  convert -resize ${icon}x${icon} -background none pixmaps/wbar.png \
	    $startdir/pkg/usr/share/icons/hicolor/${icon}x${icon}/apps/wbar.png
	done

	cat <<- EOF > $startdir/pkg/etc/xdg/autostart/wbar.desktop
	[Desktop Entry]
	Categories=Application
	Exec=wbar-autostart
	GenericName=wbar
	Icon=wbar
	Name=wbar
	Comment=Quick launch bar
	Terminal=false
	Type=Application
	Version=1.0
	X-GNOME-Autostart-enabled=true
	X-KDE-autostart-after=panel
	EOF
	
	install -d $startdir/pkg/usr/share/applications
	cat <<- EOF > $startdir/pkg/usr/share/applications/wbar.desktop
	[Desktop Entry]
	Name=Wbar Config
	GenericName=Wbar Configuration Tool
	Comment=Configure quick launch bar
	Exec=wbar-config
	Icon=wbar
	Type=Application
	StartupNotify=true
	Terminal=false
	Categories=Utility
	EOF
	chmod 644 $startdir/pkg/usr/share/applications/wbar.desktop

	set +e
}