# Contributer: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=slim
pkgver=1.3.6
pkgrel=8
pkgdesc="Desktop-independent graphical login manager for X11"
url="https://sourceforge.net/projects/slim.berlios/files/"
arch="all"
license="GPL-2.0"
options="!check"
subpackages="$pkgname-doc"
makedepends="libxmu-dev libpng-dev libjpeg-turbo-dev libxft-dev
	cmake libxrandr-dev consolekit2-dev"
depends="dbus"
install=
source="http://downloads.sourceforge.net/project/slim.berlios/${pkgname}-${pkgver}.tar.gz
	https://dev.alpinelinux.org/~clandmeter/sources/slim-alpinelinux-0.2.0.tar.gz
	no-slimlock.patch
	libslim-underlinking.patch
	slim-freetype-dirs.patch
	snprintf.patch
	musl-includes.patch
	$pkgname.logrotate
	$pkgname.initd
	"

prepare() {
	default_prepare
	sed -i -e 's|#xserver_arguments.*|xserver_arguments   -nolisten tcp vt07|'\
		-e 's|/var/run/slim.lock|/var/lock/slim.lock|' \
		-e 's|halt_cmd.*|halt_cmd            /sbin/poweroff|'\
		-e 's|reboot_cmd.*|reboot_cmd          /sbin/reboot|'\
		-e 's|console_cmd.*|console_cmd         /usr/bin/terminal|'\
		-e 's|login_cmd.*|login_cmd           exec /bin/sh -l /etc/X11/xinit/xinitrc|' \
		-e 's|screenshot_cmd.*|screenshot_cmd      scrot /slim.png|' \
		-e 's|imagemagick|scrot|' \
		-e 's|current_theme.*|current_theme       alpinelinux|' \
		slim.conf
}

build() {
	cd "$srcdir/slim-$pkgver"
	cmake . \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_SKIP_RPATH=ON \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DUSE_PAM=no \
		-DUSE_CONSOLEKIT=yes 


	make CXX="${CXX:-g++}" CC="${CC:-gcc}"
}

package() {
	cd "$srcdir/slim-$pkgver"
	make DESTDIR="$pkgdir" MANDIR=/usr/share/man install

	install -D -m755 ../slim.initd "$pkgdir"/etc/init.d/slim
	install -D -m644 ../slim.logrotate "$pkgdir"/etc/logrotate.d/slim

	# remove unused systemd service
	rm -f "$pkgdir"/usr/lib/systemd

	# install our default theme
	cd "$srcdir"/slim-alpinelinux
	install -d "$pkgdir"/usr/share/slim/themes/alpinelinux
	cp background.png panel.png slim.theme \
		"$pkgdir"/usr/share/slim/themes/alpinelinux/
	rm -rf "$pkgdir"/usr/share/slim/themes/default
}

sha512sums="345b1dee5d6f0c3716dfa7c5c16274adbf18586bdaaa6af4f310e24c5a61f79a297ffac921a5ba545523317e9fe120916df226c36b9c9b49c2ac9c1ca21dee0c  slim-1.3.6.tar.gz
3cd3de67e5b1e122da05e02e0e6e8fe2c5a1ae07487e51068aa56ddf05d17854562350ef47c914a2c9fb2534b8f757a326cfed64f4b5ddbbeb18e48af43b46c6  slim-alpinelinux-0.2.0.tar.gz
3df74cf3c8b2e313b7f394a624c094ec144844003cdd264867a7bd9f46d6a10d9f5e818078340eef76cd52c38bc9ec11989f9dac2f5c693b674c2ec627f447a2  no-slimlock.patch
c66c3908147ec28b68577958bdd7bd4bc7c42b00fc4a7ce30162202a4d0ae18ef7c0c81ca60c661609e479b370ad30261494fe84bb4ffad48232536aec483729  libslim-underlinking.patch
1f957eadb586b8f0523a2cf6ea550280a542500de925383a06d658424c524a4ef5b148aa9150a9f045529c896fe69c013417b9883583acc12a7a656b7202eded  slim-freetype-dirs.patch
22fcbdc54b1a5dc0d3501649addb8e290c63ea4a6f9d0bdbdbe9bdea1c9df785f6763f2cee2ff33e6ca2dd49c1c65fd9d036fd9527f298a7ca9e0c5acc48e854  snprintf.patch
bf1f44814dcf220b91eef8cd766c7eb3b2c2667a211d1206f3e57b88e5e7fbe17ea1e7b3c7c231cb52356b6c7df650af94759b1c154a8dd7d95dc45a9aec0e86  musl-includes.patch
e5f398ea58adbedea7ae40c7a907d2f926148ee6f3c51fc5761b84d1d119c091fa0cf34f908cd49300fcddea71c5c9b6f2ac21731808ce5d73ea65a65b19a55b  slim.logrotate
042803894dbc34351f2efd436b1e07610f63feb12f31d5d0cc1dc26e758d208790ff79ef678854d3ffd781776bc84033d9b752757944474e721e679d3cbcfbce  slim.initd"
