Apocrypha

thumbfast-2025.02.04dwosky

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

EAPI=8

DESCRIPTION="High-performance on-the-fly thumbnailer script for mpv"
HOMEPAGE="https://github.com/po5/thumbfast"

COMMIT="9deb0733c4e36938cf90e42ddfb7a19a8b2f4641"

SRC_URI="https://github.com/po5/${PN}/archive/${COMMIT}.tar.gz -> ${P}.tar.gz"

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

LICENSE="MPL-2.0"
SLOT="0"
KEYWORDS="~amd64"
IUSE="+autoload"

RDEPEND=">=media-video/mpv-0.29.0"

RESTRICT="mirror"


src_install() {
	local mpv_datadir="/usr/share/mpv"

	# Install the single Lua script.
	insinto "${mpv_datadir}/scripts"
	doins thumbfast.lua

	# Ship the default config as documentation only
	dodoc thumbfast.conf README.md

	if use autoload; then
		dosym -r \
			"${mpv_datadir}/scripts/thumbfast.lua" \
			"/etc/mpv/scripts/thumbfast.lua"
	fi
}

pkg_postinst() {
	local mpv_datadir="/usr/share/mpv"

	if use autoload; then
		elog
		elog "thumbfast has been symlinked into /etc/mpv and will load"
		elog "automatically for all users on next mpv launch."
		elog
	else
		elog
		elog "thumbfast.lua is installed under ${mpv_datadir}/scripts but is"
		elog "NOT symlinked into /etc/mpv — mpv will not load it automatically."
		elog
		elog "To enable thumbfast system-wide, re-emerge with USE=autoload."
		elog
		elog "To enable it for your user only, run:"
		elog "  mkdir -p ~/.config/mpv/scripts"
		elog "  ln -s ${mpv_datadir}/scripts/thumbfast.lua ~/.config/mpv/scripts/thumbfast.lua"
		elog
	fi

	elog "A reference configuration file is available at:"
	elog "  /usr/share/doc/${PF}/thumbfast.conf"
	elog "Copy it to ~/.config/mpv/script-opts/thumbfast.conf to customise."
	elog
	elog "thumbfast does not display thumbnails on its own — it requires a"
	elog "compatible UI script such as mpv-plugin/uosc."
	elog
}