# 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
	https://github.com/nuclear06/gentoo-deps/releases/download/${P}/${P}-crates.tar.xz -> ${P}-crates.tar.xz
	"
  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/swww
	usr/bin/swww-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)"/awww{,-daemon}
  dosym awww /usr/bin/swww
  dosym awww-daemon /usr/bin/swww-daemon

  doman doc/generated/*.1

  dodoc README.md CHANGELOG.md
  newbashcomp completions/awww.bash swww
  dofishcomp completions/awww.fish
  dozshcomp completions/_awww
}

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