# Contributor: Jean-Louis Fuchs <safe.pen2857@rhizoome.ch>
# Maintainer: Jean-Louis Fuchs <safe.pen2857@rhizoome.ch>
pkgname=hyprland-plugins
pkgver=0.49.0
pkgrel=0
_pkgdesc="Official plugins for Hyprland"
pkgdesc="$_pkgdesc (all plugins)"
_hyprlandver="~0.49"
url="https://github.com/hyprwm/hyprland-plugins"
arch="all"
license="BSD-3-Clause"
makedepends="
	aquamarine-dev
	cmake
	samurai
	hyprgraphics-dev
	hyprlang-dev
	hyprland-dev
	hyprutils-dev
	libdrm-dev
	libinput-dev
	libxkbcommon-dev
	xcb-util-wm-dev
	mesa-dev
	pango-dev
	pixman-dev
	wayland-dev
"
subpackages="$pkgname-doc"
options="!check" # currently there are no tests
source="
	https://github.com/hyprwm/hyprland-plugins/archive/v$pkgver/hyprland-plugins-v$pkgver.tar.gz
	sshader.patch
	"
_plugins="hyprexpo hyprbars hyprtrails hyprwinwrap xtra-dispatchers csgo-vulkan-fix borders-plus-plus"
depends="hyprland$_hyprlandver"

for plugin in $_plugins; do
	subpackages="$subpackages $pkgname-$plugin:_subpkg_func"
	depends="$depends $pkgname-$plugin"
done

build() {
	for plugin in $_plugins; do
		cd "$builddir/$plugin"
		cmake -B build -G Ninja \
			-DCMAKE_INSTALL_PREFIX=/usr \
			-DCMAKE_INSTALL_LIBDIR=lib \
			-DCMAKE_BUILD_TYPE=None
		cmake --build build
	done
}

package() {
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE
}

# Generic subpkg handler
_subpkg_func() {
	local plugin="${subpkgname#"$pkgname-"}"
	pkgdesc="Official plugins for Hyprland ($plugin)"
	depends="hyprland$_hyprlandver"

	cd "$builddir/$plugin"
	DESTDIR="$subpkgdir" cmake --install build
	install -Dm0644 -t "$pkgdir-doc/usr/share/doc/$subpkgname/" README.md
}

sha512sums="
8e6ec399b832f5b866ff74170bff60f098ba10a7d37173ebbb1c61e3a2d08fcc790246a879b704f9b5c49c020b55d3186482721667329d620c05177bd6755206  hyprland-plugins-v0.49.0.tar.gz
b184693b810df46c4f75324e18b1db6593077e3cd975af6657c6e6bf30470f1dd21be74bf683bd864bdabc9a6edb3db5ed6e75b057b0ce69d56b438f915b81dc  sshader.patch
"
