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

EAPI=8

MY_PN="indicator-sysmonitor"
PYTHON_COMPAT=( python3_{11..14} )

inherit meson python-any-r1

DESCRIPTION="Application Indicator showing cpu temperature, memory, network speed, cpu usage, public IP address and internet connection status for budgie-desktop."
HOMEPAGE="https://github.com/fossfreedom/${MY_PN}"
SRC_URI="https://github.com/fossfreedom/${MY_PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE=""
SLOT="0"
KEYWORDS="~amd64 ~x86 ~arm ~arm64"
IUSE="wayland"

DEPEND="
	>=budgie-base/budgie-desktop-10.10.1
	dev-libs/libayatana-appindicator
"
RDEPEND="
	${DEPEND}
	${PYTHON_DEPS}
	dev-python/psutil
	>=dev-python/pygobject-3.52.3:3
"
BDEPEND=""

PATCHES=(
	"${FILESDIR}/meson-budgie-10.10.patch"
)

pkg_setup() {
	python-any-r1_pkg_setup
}

src_unpack() {
	unpack ${P}.tar.gz
	mv ${WORKDIR}/${MY_PN}-${PV} ${WORKDIR}/${P}
}

src_configure() {
	local emesonargs=(
		$(meson_use wayland for-wayland)
		-Dbudgie=true
	)
	meson_src_configure
}

src_install() {
	meson_src_install
}

pkg_postinst() {
	elog "In order for the applet to appear after installation without relogging it is recommended to run the following  as your current logged in user:"
	elog "  nohup budgie-panel --replace > /dev/null 2>&1 &"
}

pkg_postrm() {
	elog "In order for the applet to be removed from the budgie-settings applets without relogging it is recommended to run the following as your current logged in user in budgie:"
	elog "  nohup budgie-panel --replace > /dev/null 2>&1 &"
}