# Contributor: Marvin Preuss <marvin@xsteadfastx.org>
# Maintainer: Marvin Preuss <marvin@xsteadfastx.org>
pkgname=rofi
pkgver=1.7.5
pkgrel=1
_libnkutils=d08fa898d71da4c11653284968ec14384dd70b6a
_libgwater=555fa6df92434c1c3c7548b5a583b1d8ec3fabb3
pkgdesc="Window switcher, application launcher and dmenu replacement"
url="https://github.com/davatorium/rofi"
arch="all"
license="MIT"
depends="$pkgname-themes>=$pkgver"
makedepends="
	meson
	glib-dev
	cairo-dev
	pango-dev
	libxkbcommon-dev
	libxcb-dev
	gdk-pixbuf-dev
	xcb-util-dev
	xcb-util-wm-dev
	xcb-util-xrm-dev
	xcb-util-cursor-dev
	startup-notification-dev
	flex
	bison
	ronn
	"
checkdepends="cppcheck check-dev xkeyboard-config-dev"
provider_priority=100  # highest (other provider is rofi-wayland aport)
subpackages="$pkgname-dev $pkgname-doc $pkgname-themes::noarch"
source="https://github.com/davatorium/rofi/releases/download/$pkgver/rofi-$pkgver.tar.gz
	libnkutils-$_libnkutils.tar.gz::https://github.com/sardemff7/libnkutils/archive/$_libnkutils.tar.gz
	libgwater-$_libgwater.tar.gz::https://github.com/sardemff7/libgwater/archive/$_libgwater.tar.gz
	scrollbar-test.patch
	rofi-sensible-terminal-use-sh.patch
	0001-format-string-test-Fix-for-GLib-2.73.1-e-time-format.patch_libnkutils
	"

prepare() {
	default_prepare

	rm -rf subprojects/libnkutils subprojects/libgwater
	mv "$srcdir"/libnkutils-$_libnkutils subprojects/libnkutils
	mv "$srcdir"/libgwater-$_libgwater subprojects/libgwater

	cd subprojects/libnkutils
	patch -Np1 -i "$srcdir"/0001-format-string-test-Fix-for-GLib-2.73.1-e-time-format.patch_libnkutils
	cd ../..
}

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

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

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

	# This image makes 2/3 of the size of the themes directory.
	# It's not the default theme, so get rid of it.
	rm -rf "$pkgdir"/usr/share/rofi/themes/iggy.jpg
}

themes() {
	pkgdesc="$pkgdesc (themes)"
	depends=""
	replaces="$pkgname rofi-wayland"  # for backward compatibility

	amove usr/share/rofi/themes
}

sha512sums="
00fed7032eb257d7659ee7cfde24875aec1d85a972d1e6dfc2cff3f2495b1316ea92cb4af3c00ddb0748a4e404fc9151232abf3866b8d017826e0f3a8a916d85  rofi-1.7.5.tar.gz
ed5fca928929e9af09bf1889f8012b6c31d7a3fc780680e15c577152c79ec8df395a798b33816c07f6ccd5ea6938b88a69f8357612de944c1ff2a4f50b98f34d  libnkutils-d08fa898d71da4c11653284968ec14384dd70b6a.tar.gz
1d9307167fa18c2d7249ae1df33286f646ade3d28c0aa22307d0d7d379c281a7e866a3e7f23da039bfccbe01e13e4d8f49929cac6a9e5df51d368ae3f9088588  libgwater-555fa6df92434c1c3c7548b5a583b1d8ec3fabb3.tar.gz
dd01b088bdce17f0b2ff0a99a589b3fa50f954d00b6410d64f7fee48e81f9f019cdd0250fdbc6c58f531ac4f9ee59e29c28cf8aa37853e9253943f3db41b5d2c  scrollbar-test.patch
c25940edf74a02c674da65d16c4fdbcc3bf6700c3b5f5e61d468851d5655490e3683b330dce0a15ea3ac4c3d440c63a69d48f3cea99cf7fd529b9de0fbfc9eae  rofi-sensible-terminal-use-sh.patch
dc1eb60339e9edd1a1ed7f6e28ea527a4fe5f7a6f5e9363aec6164a99fa6dbf79d12778d3395f979623e607d3e1431c55398d2b6ac0004b6aa60e4156f7a1b12  0001-format-string-test-Fix-for-GLib-2.73.1-e-time-format.patch_libnkutils
"
