# SliTaz package receipt.

PACKAGE="dwm"
VERSION="5.6.1"
CATEGORY="x-window"
SHORT_DESC="Very light dynamic window manager for X."
MAINTAINER="pankso@slitaz.org"
TARBALL="$PACKAGE-$VERSION.tar.gz"
WEB_SITE="http://www.suckless.org/dwm/"
WGET_URL="http://dl.suckless.org/dwm/$TARBALL"
TAGS="wm window-manager"

DEPENDS="xorg-libX11 xorg-xsetroot"
BUILD_DEPENDS="xorg-libX11-dev xorg-xproto xorg-xineramaproto \
xorg-libXinerama-dev"

# Rules to configure and make the package.
compile_rules()
{
	cd $src
	# From blue to brown and have lighter grey
	sed -i s/'#0066ff'/'#754800'/g config.def.h
	sed -i s/'#cccccc'/'#f1efeb'/g config.def.h
	# 6 tag-mask
	sed -i s/', "7", "8", "9"'// config.def.h
	# Firefox on current tag-mask
	sed -i s/'1 << 8,'/'0,     '/ config.def.h
	# [Shift]+[Alt]+[Enter]
	sed -i s/uxterm/xterm/ config.def.h
	make
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr/bin
	cp -a $src/dwm $fs/usr/bin
	cp -a $stuff/dwm-session $fs/usr/bin
	cp -a $stuff/dwmbox $fs/usr/bin
	chown 0.0 $fs/usr/bin/*
}

post_install()
{
	res=`cat $1/etc/slim.conf | grep ^session | sed s/"sessions. *"//`
	# Adding WM to SLIM available sessions.
	if ! echo "$res" | grep -q $PACKAGE; then
		echo -n "Adding $PACKAGE to /etc/slim.conf..."
		sed -i "s/^sessions.*/sessions            ${res},dwm/" /etc/slim.conf
		status
	fi
}

post_remove()
{
	# Remove karmen from SLIM available sessions.
	if grep -q dwm $1/etc/slim.conf; then
		sed -i s/,dwm// $1/etc/slim.conf
	fi
}