# Template file for 'darkman'
pkgname=darkman
version=2.0.1
revision=2
build_style=go
build_helper=qemu
go_import_path="gitlab.com/WhyNotHugo/darkman"
go_package="${go_import_path}/cmd/darkman"
go_ldflags="-X main.Version=${version}"
hostmakedepends="scdoc"
depends="dbus"
short_desc="Daemon for dark-mode and light-mode transitions on Linux desktop"
maintainer="André Cerqueira <acerqueira021@gmail.com>"
license="ISC"
homepage="https://darkman.whynothugo.nl/"
changelog="https://gitlab.com/WhyNotHugo/darkman/-/raw/main/CHANGELOG.md"
distfiles="https://gitlab.com/WhyNotHugo/darkman/-/archive/v${version}/darkman-v${version}.tar"
checksum=8bfcf0884c8a71b523d675f47037c5e4f51dcb52ef59a3b7d538a82c3cf41fbe
_completions="zsh bash fish"

post_build() {
	local _bin="$(find ${GOPATH}/bin -name darkman)"
	for _shell in ${_completions}; do
		vtargetrun "${_bin}" completion ${_shell} > darkman.${_shell}
	done
}

post_install() {
	vmkdir usr/share/dbus-1/services
	vinstall contrib/dbus/org.freedesktop.impl.portal.desktop.darkman.service 644 usr/share/dbus-1/services
	vinstall contrib/dbus/nl.whynothugo.darkman.service 644 usr/share/dbus-1/services

	vmkdir usr/share/xdg-desktop-portal/portals
	vinstall contrib/portal/darkman.portal 644 usr/share/xdg-desktop-portal/portals

	scdoc < darkman.1.scd > darkman.1
	vman darkman.1

	vlicense LICENCE

	for _shell in ${_completions}; do
		vcompletion darkman.${_shell} ${_shell}
	done
}
