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

EAPI=8

DESCRIPTION="A Hyprland version of Grimshot"
HOMEPAGE="https://github.com/hyprwm/contrib"

COMMIT="541628cebe42792ddf5063c4abd6402c2f1bd68f"

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

	KEYWORDS="~amd64"
fi

LICENSE="MIT"
SLOT="0"

IUSE="+clipboard +freeze +notify"

RDEPEND="
	app-misc/jq
	gui-apps/grim
	gui-apps/slurp
	gui-wm/hyprland
	clipboard? ( gui-apps/wl-clipboard )
	notify? ( x11-libs/libnotify )
	freeze? ( gui-apps/hyprpicker )
"
DEPEND="${RDEPEND}"

src_install() {
	pushd ${PN} || die
	emake DESTDIR="${D}" PREFIX="${D}/usr" install
}

pkg_postinst() {
	elog "By default, 'edit' mode looks for GIMP. You can set GRIMBLAST_EDITOR"
	elog "in your environment to use a different image editor."
}