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

EAPI=8

inherit savedconfig toolchain-funcs

DESCRIPTION="A suckless-adjacent fetch program written in C"
HOMEPAGE="https://codeberg.org/theidioticdev/sfetch"
SRC_URI="https://codeberg.org/theidioticdev/sfetch/archive/${P}.tar.gz"

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

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="amd64"

src_prepare() {
	default
	restore_config src/main.c
}

src_compile() {
	$(tc-getCC) ${CFLAGS} ${LDFLAGS} src/main.c -o sfetch || die
}

src_install() {
	dobin sfetch
	save_config src/main.c
}

pkg_postinst() {
	if use savedconfig; then
		elog "Edit sfetch through /etc/portage/savedconfig/app-misc/sfetch-${PV}"
		elog "Requires re-emerging after change!"
	fi
}