# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=greybird-themes
pkgver=1.6.2
pkgrel=1
pkgdesc="A clean minimalistic theme for Xfce, GTK+ 2 and 3"
url="http://shimmerproject.org/project/greybird/"
arch="noarch"
license="GPLv2+ or CC-BY-SA"
depends=""
depends_dev=""
makedepends="$depends_dev"
install=""
subpackages="$pkgname-gtk2 $pkgname-gtk3 $pkgname-metacity $pkgname-xfwm4
	$pkgname-xfce4-notifyd:_notify $pkgname-unity"
source="greybird-$pkgver.tar.gz::https://github.com/shimmerproject/Greybird/archive/v$pkgver.tar.gz
	gtk-3.14-fix.patch
	"

_builddir="$srcdir"/Greybird-$pkgver
prepare() {
	local i
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"
	# Cleanup
	# Remove Unity theme
	rm -f gtk-3.0/apps/unity.css
	rm -f gtk-3.0/apps/lightdm-unity-greeter.css

	sed -i '/unity\.css/d' gtk-3.0/gtk.css
	sed -i '/lightdm-unity-greeter\.css/d' gtk-3.0/gtk.css
	sed -i '/lightdm-gtk-greeter\.css/d' gtk-3.0/gtk.css
}

package() {
	cd "$_builddir"
	mkdir -p "$pkgdir"/usr/share/themes/Greybird
	cp -pr * "$pkgdir"/usr/share/themes/Greybird
}

_mv() {
	pkgdesc="$1"
	install_if="$pkgname=$pkgver-r$pkgrel $2";
	depends=
	local _i
	shift; shift
	mkdir -p "$subpkgdir"/usr/share/themes/Greybird
	for _i; do
		msg "moving $_i"
		mv "$pkgdir"/usr/share/themes/Greybird/$_i  \
			"$subpkgdir"/usr/share/themes/Greybird || return 1
	done
}


gtk2() {
	_mv "Greybird GTK+2 themes" gtk+2.0 gtk-2.0
	depends="gtk-murrine-engine"
}

gtk3() { _mv "Greybird GTK+3 themes" gtk+3.0 gtk-3.0; }
metacity() { _mv "Greybird Metacity themes" metacity metacity-1; }
xfwm4() { _mv "Greybird Xfce4 themes" xfwm4 xfwm4 'xfwm4-*'; }
_notify() { _mv "Greybird Xfce4-notifyd themes" xfce4-notifyd 'xfce-notify-*'; }
unity() { _mv "Greybird Unity themes" unity 'unity'; }

md5sums="542cfd641cd5ff723ee2fcdfdb1eabbd  greybird-1.6.2.tar.gz
ef3882cc1ea6c00fb1c372c911b563fe  gtk-3.14-fix.patch"
sha256sums="473a38b379381311b68dcc579005c0d5bbfbabefe1de7107d897c68b81e6b460  greybird-1.6.2.tar.gz
00d0c58a96c5c1090adcf8ec479d5d608e68d1141e79cebb1112f3430ae7a482  gtk-3.14-fix.patch"
sha512sums="eddd6b89880dbc034ee32cc17751b6ee1b18b55eef31d745c64f865b96d0fbf36fe6ab59dbe89dbdd032b3ed01395850f9597bdc1897e276b0433e93353d893f  greybird-1.6.2.tar.gz
6cb7912dda0b82065e58a51533ce0b7d6341af5e7e996dd2f2870c8e2db6c439e7c47f12e7bccb24c74021de6516ebbc9a0ac32c5323b048002b7abf87365722  gtk-3.14-fix.patch"