# Contributor: Pedro Filipe <xpecex@outlook.com>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=numix-themes
_pkgname=numix-gtk-theme
pkgver=2.6.7
pkgrel=0
pkgdesc="A modern flat theme with a combination of light and dark elements, GTK 2 and 3"
url="https://numixproject.github.io/"
arch="noarch"
license="GPL-3.0"
subpackages="$pkgname-gtk2 $pkgname-gtk3 $pkgname-metacity $pkgname-xfwm4 $pkgname-xfce4-notifyd:_notify
		$pkgname-openbox:_openbox"
source="numix-$pkgver.tar.gz::https://github.com/numixproject/$_pkgname/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver/src"

build() {
	# Remove Unity theme
	rm -f gtk-3.0/apps/unity.css
	sed -i '/unity\.css/d' gtk-3.0/gtk.css
	rm -rf unity
}

package() {
	mkdir -p "$pkgdir"/usr/share/themes/Numix
	cp -pr ../* "$pkgdir"/usr/share/themes/Numix
	mv index.theme "$pkgdir"/usr/share/themes/Numix
	cd "$pkgdir"/usr/share/themes/Numix
	rm -rf src/assets scripts Makefile
}

_mv() {
	pkgdesc="$1"
	install_if="$pkgname=$pkgver-r$pkgrel $2";
	local _i
	shift; shift
	mkdir -p "$subpkgdir"/usr/share/themes/Numix
	for _i; do
		msg "moving $_i"
		mv "$pkgdir"/usr/share/themes/Numix/src/$_i  \
			"$subpkgdir"/usr/share/themes/Numix
	done
	# index.theme remains in src despite being moved in package().
	rm -f "$pkgdir"/usr/share/themes/Numix/src/index.theme 2>/dev/null || true
	# Remove the empty top level src directory after moving finishes.
	rmdir "$pkgdir"/usr/share/themes/Numix/src 2>/dev/null || true
}

gtk2() {
	_mv "Numix GTK2 themes" gtk2.0 gtk-2.0
	depends="gtk-murrine-engine"
}

gtk3() { _mv "Numix GTK3 themes" gtk3.0 gtk-3.*; }
metacity() { _mv "Numix Metacity themes" metacity metacity-1; }
xfwm4() { _mv "Numix Xfce4 themes" xfwm4 xfwm4; }
_notify() { _mv "Numix Xfce4-notifyd themes" xfce4-notifyd xfce-notify-4.0; }
_openbox() { _mv "Numix openbox themes" openbox openbox-3; }

sha512sums="a034644a08173e70de496b88b40c8749d3c3dc988da0c09a03eca77a5263704b001114678e0492988831b1664593d4054f2d7c0d90d95f5b05dcd05914577a03  numix-2.6.7.tar.gz"
