### this file is sourced not run
# Note: Original name was compton-yshui up to version 7.4
PKGBUILD=1
PKGARCH=x86_64

# source: james
# release tarball
PKGVER=10.2
TARBALL=picom-$PKGVER.tar.gz
MD5SUM=cd750778ab98f8167a62da8d79be7e54
SRC_URL=https://github.com/yshui/picom/archive/v${PKGVER}.tar.gz
BUNDLE=

# git-master tarball
#PKGVER=8.2.2021.11.25
#MD5SUM=39698686371dcee261d617437606c533
#hash=31e58712ec11b198340ae217d33a73d8ac73b7fe
#hash7=${hash#???????}; hash7=${hash%$hash7}
#TARBALL=picom-$PKGVER-$hash7.tar.gz
#SRC_URL=https://github.com/yshui/picom/archive/$hash.tar.gz


SLACKREQ='mesa libdrm libpcre libev libconfig' # asciidoc build-time only
SLACKDESC="picom: picom $PKGVER (X lightweight compositor)
picom: 
picom: picom a.k.a. compton-yshui is a lightweight compositor, forked from the
picom: original compton.
picom:
picom: This package can be installed side-by-side with compton, but
picom: only one of them can be run at the same time. 
picom: 
picom: https://github.com/yshui/picom
picom: 
picom: 
"

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	cd /tmp/picom* &&

	# patch to disable loading compton config, so we can truly live side by side
	# with the original compton
	sed -i -e '\_/picom.conf_ s|$|};|' \
		-e '\_/compton.conf_ s|^|//|' \
		-e '/config_filename_legacy/ s|compton|picom|' src/config_libconfig.c &&
	
	cp /tmp/pkg/uthash.h /usr/include &&
	meson --prefix=/usr --buildtype=release . build \
		-Ddbus=false -Dvsync_drm=true -Dwith_docs=true
	##meson configure -Dprefix=/usr build &&
	ninja -C build &&
	ninja -C build install &&
	
	install -dm755 /etc/xdg &&
	install -m644 picom.sample.conf /etc/xdg &&

	pkg_build_slackdesc &&
	rm -f /usr/include/uthash.h &&
	
	# don't display it on the menu
	echo "NoDisplay=true" >> /usr/share/applications/picom.desktop &&

	# remove compat symlink
	rm -f /usr/bin/compton{,-trans} /usr/share/applications/compton.desktop &&
	mv /usr/share/icons/hicolor/48x48/apps/{compton,picom}.png &&
	mv /usr/share/icons/hicolor/scalable/apps/{compton,picom}.svg &&

	# copy examples & asciidoc source files
	mkdir -p /usr/share/doc/picom-$PKGVER &&
	install -m644 man/*.asciidoc /usr/share/doc/picom-$PKGVER &&
	install -m644 *.glsl /usr/share/doc/picom-$PKGVER &&

	# finish
	true
}
