# Copyright 2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Autogenerated by pycargoebuild 0.15.0

EAPI=8

inherit cargo shell-completion

DESCRIPTION="Efficient animated wallpaper daemon for wayland, controlled at runtime"
HOMEPAGE="https://codeberg.org/LGFae/awww"
if [[ ${PV} == *9999* ]]; then
    inherit git-r3
    EGIT_REPO_URI="https://codeberg.org/LGFae/${PN}.git"
else
    SRC_URI="
	https://codeberg.org/LGFae/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}
	"
    KEYWORDS="~amd64"
fi

S="${WORKDIR}/${PN}"

LICENSE="GPL-3"
# Dependent crate licenses
LICENSE+="
	Apache-2.0-with-LLVM-exceptions BSD-2 BSD MIT MPL-2.0 Unicode-3.0
	ZLIB
"
SLOT="0"
RUST_MIN_VER="1.89.0"

DEPEND="
	app-arch/lz4:=
	x11-libs/libxkbcommon[wayland]
"
RDEPEND="${DEPEND}"
BDEPEND="
	app-text/scdoc
"

QA_FLAGS_IGNORED="
	usr/bin/${PN}
	usr/bin/${PN}-daemon
"

src_unpack() {
	if [[ "${PV}" == *9999* ]]; then
        git-r3_src_unpack
        cargo_live_src_unpack
    else
        cargo_src_unpack
    fi
}

src_compile() {
	cargo_src_compile
	./doc/gen.sh || die # generate man pages
}

src_install() {
	dobin "$(cargo_target_dir)"/${PN}{,-daemon}
	dosym ${PN} /usr/bin/swww
	dosym ${PN}-daemon /usr/bin/swww-daemon
	doman doc/generated/*.1

	dodoc README.md CHANGELOG.md
	newbashcomp completions/${PN}.bash ${PN}
	dofishcomp completions/${PN}.fish
	dozshcomp completions/_${PN}
}

pkg_postinst() {
	ewarn "The project has been renamed from swww to awww"
	ewarn "This ebuild installs symlinks to ease the transition"
}