# Contributor: Matthew T Hoare <matthew.t.hoare@gmail.com>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Matthew T Hoare <matthew.t.hoare@gmail.com>
pkgname=nwg-launchers
pkgver=0.7.1.1
pkgrel=0
pkgdesc="GTK+ launchers for sway, i3 and some other window managers"
url="https://github.com/nwg-piotr/nwg-launchers"
arch="all"
license="GPL-3.0-or-later"
makedepends="
	cmake
	gtk-layer-shell-dev
	gtkmm3-dev
	meson
	nlohmann-json
	"
source="https://github.com/nwg-piotr/nwg-launchers/archive/v$pkgver/nwg-launchers-$pkgver.tar.gz"
options="!check"  # no tests provided
subpackages="$pkgname-data"

for _i in bar dmenu grid; do
	subpackages="$subpackages $pkgname-$_i:_subpackage"
	depends="$depends $pkgname-$_i=$pkgver-r$pkgrel"
done

build() {
	abuild-meson \
		-Dlayer-shell=enabled \
		. output
	meson compile -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

data() {
	amove usr/share/nwg-launchers/icon-missing.*
	depends=""
	arch="noarch"
}

_subpackage() {
	local name=${subpkgname#"$pkgname"-}
	case "$subpkgname" in
		bar) pkgdesc="GTK-based button bar for Sway and other window managers";;
		dmenu) pkgdesc="GTK-based dmenu for Sway and other window managers";;
		grid) pkgdesc="GTK-based GNOME-like application grid for Sway and other window managers";;
	esac
	depends="$pkgname-data"

	amove usr/bin/nwg$name
	if test "$subpkgname" = "$pkgname"-grid; then
		amove usr/bin/nwg"$name"-server
	fi
	amove usr/share/nwg-launchers/nwg$name
}

sha512sums="
c7048e815e447393493597a2c3699875b207a32d6f1d41e7816d787ef8605da581c3da5181be330542dcd7e63294289f14e275803e03779c3f96cbf8908cee80  nwg-launchers-0.7.1.1.tar.gz
"
