# dwm - the suckless dynamic window manager, on X11.
#
# dwm is configured by editing config.h and recompiling. Upstream ships
# config.def.h and copies it to config.h on first build; this recipe starts
# from that and changes only the font, the terminal and the accent colour, so
# a new dwm release stays a version bump rather than a merge of someone
# else's whole config.
name=dwm
version=6.6
release=4
desc="Dynamic window manager for X"
url="https://dwm.suckless.org/"
license="MIT"
depend="glibc libx11 libxinerama libxft fontconfig"
recommend="x11-base st dmenu"
makedepend="bmake clang lld"
source="https://dl.suckless.org/dwm/dwm-$version.tar.gz"
sha256="SKIP"

build() {
	cd "dwm-$version"
	cp config.def.h config.h
	# JetBrains Mono is what the rest of ScrapLinux's desktop uses, st is the
	# terminal the apiwow-dwm profile installs, and the accent is the same
	# neutral grey rather than dwm's default cyan.
	sed -i \
		-e 's|"monospace:size=10"|"JetBrainsMono Nerd Font:size=11"|' \
		-e 's|"monospace"|"JetBrainsMono Nerd Font"|' \
		-e 's|col_cyan\[\]       = "#005577"|col_cyan[]       = "#4c566a"|' \
		-e 's|"st", NULL|"st", NULL|' \
		config.h
	make -j"$JOBS" PREFIX=/usr FREETYPEINC=/usr/include/freetype2
}

package() {
	cd "dwm-$version"
	make PREFIX=/usr DESTDIR="$pkgdir" install
	install -Dm644 config.h "$pkgdir/usr/share/dwm/config.h"
	mkdir -p "$(dirname $pkgdir/usr/share/xsessions/dwm.desktop)"
cat >"$pkgdir/usr/share/xsessions/dwm.desktop" <<-'DESK'
		[Desktop Entry]
		Name=dwm
		Comment=Dynamic window manager
		Exec=dwm
		Type=XSession
DESK
chmod 644 "$pkgdir/usr/share/xsessions/dwm.desktop"
}
