# Contributor: Zach DeCook <zachdecook@librem.one>
maintainer="Zach DeCook <zachdecook@librem.one>"
pkgname=hyprland
pkgver=0.45.0
pkgrel=0
_commit="a425fbebe4cf4238e48a42f724ef2208959d66cf"
pkgdesc="Independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks."
url="https://hyprland.org"
arch="all"
license="BSD-3-Clause"
source="
	https://github.com/hyprwm/Hyprland/archive/v$pkgver/Hyprland-v$pkgver.tar.gz
	"
builddir="$srcdir/Hyprland-$pkgver"
makedepends="
	aquamarine-dev>=0.4.2
	cairo-dev
	cmake
	elogind-dev
	hyprcursor-dev>=0.1.9
	hyprland-protocols>=0.4.0
	hyprlang>=0.3.2
	hyprutils-dev>=0.2.3
	hyprwayland-scanner>=0.3.10
	jq
	libdrm-dev
	libinput-dev
	libliftoff-dev
	libxcb-dev
	libxcursor-dev
	libxkbcommon-dev
	mesa-dev
	meson
	ninja
	pango-dev
	pixman-dev
	tomlplusplus-dev
	udis86-git-dev
	vulkan-loader-dev
	wayland-dev
	wayland-protocols
	xcb-util-errors-dev
	xcb-util-image-dev
	xcb-util-renderutil-dev
	xcb-util-wm-dev
	xkeyboard-config-dev
	xwayland-dev
	"
subpackages="
	$pkgname-doc
	$pkgname-dev
	$pkgname-wallpapers::noarch
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"

prepare() {
	default_prepare
	# Set some variables in version.h.in
	sed -i "s/@HASH@/$_commit/" "$builddir"/src/version.h.in
	sed -i "s/@BRANCH@/build-alpine/" "$builddir"/src/version.h.in
	_patches="$(printf %s "$source" | grep '.patch$' | tr '\n' ' ')"
	if test "$_patches"; then
		_message="with patches: $_patches"
	else
		_message="without patches"
	fi
	sed -i "s~@MESSAGE@~$_message~" "$builddir"/src/version.h.in
	sed -i "s/@TAG@/v$pkgver/" "$builddir"/src/version.h.in
}

build() {
	abuild-meson . output
	meson compile -C output
}

check() {
	meson test --no-rebuild -C output
}

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

wallpapers() {
	pkgdesc="Wallpapers for Hyprland"

	amove usr/share/hypr/wall*.png
}

sha512sums="
f3df59ff9698a91bdbbfe2dbdabfe15c3ea61026c0e487949441394513e6439676ff268c2fd73c436002aa13b9eca705ebda3507013262e63a882dac31bc1721  Hyprland-v0.45.0.tar.gz
"
