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

EAPI=8

PYTHON_COMPAT=( python3_{11,12,13,14} )

inherit optfeature python-single-r1 xdg

DESCRIPTION="Desktop tool (GTK3 or Qt6) that scans your system for gaming performance pitfalls"
HOMEPAGE="https://codeberg.org/MocaccinoOS/mocaccino-gaming-advisor"
SRC_URI="https://codeberg.org/MocaccinoOS/mocaccino-gaming-advisor/archive/v${PV}.tar.gz -> ${P}.tar.gz"
S="${WORKDIR}/mocaccino-gaming-advisor"

LICENSE="GPL-3+"
SLOT="0"
KEYWORDS="~amd64"
# GTK3 frontend by default; USE=qt installs the Qt6 frontend instead (never both)
IUSE="qt"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"

RDEPEND="
	${PYTHON_DEPS}
	sys-auth/polkit
	qt? (
		$(python_gen_cond_dep '
			dev-python/pyqt6[gui,widgets,${PYTHON_USEDEP}]
		')
	)
	!qt? (
		$(python_gen_cond_dep '
			dev-python/pygobject:3[${PYTHON_USEDEP}]
		')
		x11-libs/gtk+:3[introspection]
	)
"
BDEPEND="${PYTHON_DEPS}"

src_install() {
	emake install \
		DESTDIR="${D}" \
		PREFIX="${EPREFIX}/usr" \
		UI="$(usex qt qt gtk)"

	python_fix_shebang "${ED}"/usr/bin
	dodoc README.md
}

pkg_postinst() {
	xdg_pkg_postinst

	optfeature_header "Optional packages for extended checks and features:"
	optfeature "CPU frequency and governor control" sys-power/cpupower
	optfeature "ZRAM status queries" sys-apps/util-linux
	optfeature "Vulkan capability diagnostics" dev-util/vulkan-tools
	optfeature "Headset mic mute detection" media-video/pipewire media-sound/pulseaudio
	optfeature "Bluetooth controller and headset battery monitoring" net-wireless/bluez
	optfeature "GameMode status check and service management" games-util/gamemode
	optfeature "MangoHud overlay detection" games-util/mangohud
	optfeature "Sched_ext eBPF schedulers (SCX scheduler picker)" sys-kernel/scx
}