### this file is sourced not run
pkgname=hardinfo2
PKGVER=2.3.1
PKGBUILD=1
PKGARCH=x86_64

# source: JakeSFR
TARBALL=${pkgname}-${PKGVER}.tar.gz
MD5SUM=f263ee043952a77905399a4d2a3c90c4
SRC_URL=https://github.com/hardinfo2/hardinfo2/archive/refs/tags/release-${PKGVER}.tar.gz
BUNDLE=

SLACKREQ='gtk3 qt5-common lm-sensors pci-database usb-database oui-database libjson-glib libbsd'

SLACKSUG='sysbench'

SLACKDESC="${pkgname}: ${pkgname} $PKGVER (System Information and Benchmark)
${pkgname}: 
${pkgname}: Hardinfo2 is based on hardinfo, which has not been released >10 years.
${pkgname}: Hardinfo2 offers System Information and Benchmark for Linux Systems.
${pkgname}: It is able to obtain information from both hardware and basic software.
${pkgname}: It can benchmark your system and compare to other machines online.
${pkgname}: 
${pkgname}: https://github.com/hardinfo2/hardinfo2
${pkgname}: 
${pkgname}: 
${pkgname}:
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/hardinfo* &&
	for p in ../pkg/0*; do
		patch -Np1 -i $p || return 1
	done &&
	
	# disable all themes, but the default one
	sed -i '/{"Theme[2-6]Action"/,/G_CALLBACK(cb_theme[2-6])}/d' shell/menu.c &&
	
	true
}
### default pkg_package
### build
pkg_build() {
	export PATH="$PATH:/opt/qt5/bin"
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/qt5/$LIBDIR"
	export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/opt/qt5/$LIBDIR/pkgconfig"
	export QT5_PATH="/opt/qt5/bin"
	export QT5_LD_LIBRARY_PATH="/opt/qt5/$LIBDIR"
	export QT5_PKG_CONFIG_PATH="/opt/qt5/$LIBDIR/pkgconfig"
	export QT5_CPLUS_INCLUDE_PATH="/opt/qt5/include" 
	
	CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_INSTALL_SERVICEDIR=/usr/lib64 -DHARDINFO2_VK_WAYLAND=0"
	pkg_build_cmake &&
	pkg_build_slackdesc &&

	# delete all distro logos
	rm /usr/share/hardinfo2/pixmaps/distros/* &&

	# and use Fatdog SVG icon from fatdog-drive-icon-roxlib.sh (slightly modified)
	cat > /usr/share/hardinfo2/pixmaps/distros/fatdog64.svg <<-EOF &&
	<svg x="0" y="0" width="96" height="80"><defs><linearGradient id="G"><stop offset="5%" stop-color="#CC8B35"/><stop offset="50%" stop-color="#E3AD2F"/><stop offset="95%" stop-color="#F0C727"/></linearGradient></defs><path transform="translate(0,-20)" fill="url(#G)" stroke="black" stroke-width="2" d="M18 37l6 1-7 2zm-7-1c7-3 14-3 21 0m3-1l4 4-7-3zm7 11c-17 18-40 1-20-8m-8 8c0 4-5 6-8 2m42-22c17 1 25 3 36 14 3-6 0-10-8-10 9-10 20 6 12 16 2 4 3 7 3 11 0 8-5 33-8 36-3 2-12 2-12-1 2-3 3-6 3-10-5 3-8 4-14 5 0 2 0 3-2 4-3 1-12 2-12-1v-2h-3c-1 3-1 4-3 5-4 2-12 2-12-1 1-2 2-4 2-7-3-1-3.596-.626-6-2 1 2 1 4 0 6-2 2-13 4-13 1 2-3 4-7-2-20-2-3-4-8-4-13 0-2 0-5 1-9-1-2-1-3-1-5 0-3 3-5 6-7l1-1s-3-1-3-3c0-4 5-7 8-7s6 3 6 3c4-1 6-1 7-1h5c4-1 7-1 13-1zm-9 2c6-5 16 0 16 4 0 2-5 4-7 4s-1-5-6-5m9 11c0 9-10 16-21 16-6 0-9 0-13-2m7 27c-2-1-4-2-6-4m28 9c5 0 8 0 14-1m14-5c3-2 5-4 7-7m7-29c-2-3-3-5-4-6m-72-5c3-3 6-5 11-7m0 26c-3 1-8 4-11 1-2-3 0-4 4-5M6 48c1 2 3 4 5 5m-1-1l5-4m5 7c8 0 15 0 22-9m1 33c1 4 1 5 0 9M28 77c2 3 2 5 2 8"/></svg>
	EOF

	# delete all background images, but the default one
	rm /usr/share/hardinfo2/pixmaps/bg{2..6}*.jpg &&
	
	# delete large data files we already have in the base
	rm /usr/share/hardinfo2/{usb.ids,pci.ids,ieee_oui.ids} &&

	# custom Fatdog desktop file
	echo "NoDisplay=true" >> /usr/share/applications/hardinfo2.desktop &&

	true
}
