dmenupatches - build.sh
#!/bin/sh
set -eu
DMENU_SRC="/tmp/dmenu"
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
printf '%s\n' "Removing existing dmenu source..."
rm -rf "$DMENU_SRC"
printf '%s\n' "Cloning dmenu..."
git clone https://git.suckless.org/dmenu "$DMENU_SRC"
cd "$DMENU_SRC"
printf '%s\n' "Checking out dmenu 5.3..."
git checkout 5.3
printf '%s\n' "Applying patches from: $SCRIPT_DIR"
found=0
for patch in "$SCRIPT_DIR"/*.diff; do
[ -f "$patch" ] || continue
found=1
printf 'Applying %s...\n' "$(basename "$patch")"
if ! patch -p1 < "$patch"; then
printf 'Error: failed to apply %s\n' "$(basename "$patch")" >&2
exit 1
fi
done
if [ "$found" -eq 0 ]; then
printf 'Error: no .diff files found in %s\n' "$SCRIPT_DIR" >&2
exit 1
fi
printf '%s\n' "Building dmenu..."
make clean
make
printf '%s\n' "Installing dmenu..."
sudo make install
printf '%s\n' "Done."