#!/bin/sh

cp config.mk patches.h dwm-flexipatch/
flexipatch-finalizer/flexipatch-finalizer.sh -r -d dwm-flexipatch -o dwm-final
git -C dwm-flexipatch reset --hard HEAD && git -C dwm-flexipatch clean -fd
for patch in patches/*.diff; do
    patch -d dwm-final <"$patch"
done
cp config.h dwm-final/
cd dwm-final || exit 1
if [ "$1" = "-i" ]; then
    sudo make install
else
    make
fi