# Copyright 2023-2026 Gentoo Authors
# Distributed under the terms of the MIT License

EAPI=8

DESCRIPTION="Invoke shell functions in response to Hyprland socket2 events"
HOMEPAGE="https://github.com/vilari-mickopf/hyprevents"

COMMIT="d4397df0f04da244f58fc7f6e4d8a01ec9200cc0"

if [[ "${PV}" = *9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/vilari-mickopf/${PN^}.git"
else
	SRC_URI="https://github.com/vilari-mickopf/${PN^}/archive/${COMMIT}.tar.gz -> ${P}.tar.gz"
	S="${WORKDIR}/${PN}-${COMMIT}"

	KEYWORDS="~amd64"
fi

LICENSE="MIT"
SLOT="0"

RDEPEND="
	gui-wm/hyprland
	net-misc/socat
"
DEPEND="${RDEPEND}"

src_prepare() {
	default

	# The makefile replaces the dirname of certain scripts to hardcode the
	# share directory. It does not work with emake, therefore replaces it by
	# the real path name.
	sed -i '/@sed/s|$(SHAREDIR)|/usr/share/hyprevents|' Makefile || die
}

src_compile() {
	:
}

src_install() {
	emake PREFIX="${D}/usr" install
}