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

EAPI=8

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

inherit python-single-r1 xdg

DESCRIPTION="Desktop application for managing systemd services"
HOMEPAGE="https://github.com/mfat/systemd-pilot"
SRC_URI="https://github.com/mfat/systemd-pilot/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~arm64 ~x86"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"

RDEPEND="
	${PYTHON_DEPS}
	$(python_gen_cond_dep '
		dev-python/keyring[${PYTHON_USEDEP}]
		dev-python/paramiko[${PYTHON_USEDEP}]
		dev-python/pygobject:3[${PYTHON_USEDEP}]
	')
	sys-apps/systemd
	sys-auth/polkit
	x11-libs/gtk+:3[introspection]
	x11-libs/gtksourceview:4[introspection]
"
BDEPEND="${PYTHON_DEPS}"

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

PATCHES=( "${FILESDIR}/${P}-remove-rich.patch" )

src_install() {
	python_fix_shebang src/main.py
	newbin src/main.py systemd-pilot

	insinto /usr/share/applications
	doins data/io.github.mfat.systemdpilot.desktop

	insinto /usr/share/metainfo
	doins data/io.github.mfat.systemdpilot.appdata.xml

	insinto /usr/share/icons/hicolor/scalable/apps
	doins io.github.mfat.systemdpilot.svg
}