# Depends on rxvt-unicode (used instead of uxterm)

# Exit on error:
set -e

wget http://dl.suckless.org/dwm/dwm-6.0.tar.gz
tar xf dwm-6.0.tar.gz
cd dwm-6.0

sed -i '/^PREFIX/s,/usr/local,,' config.mk

# Replace uxterm with urxvt
cp config.def.h config.h
sed -i 's/uxterm/urxvt/' config.h

# Use azerty keys
sed -i.orig \
    -e 's/XK_0/XK_agrave/' \
    -e 's/XK_period/XK_semicolon/' \
    -e 's/XK_1/XK_ampersand/' \
    -e 's/XK_2/XK_eacute/' \
    -e 's/XK_3/XK_quotedbl/' \
    -e 's/XK_4/XK_apostrophe/' \
    -e 's/XK_5/XK_parenleft/' \
    -e 's/XK_6/XK_minus/' \
    -e 's/XK_7/XK_egrave/' \
    -e 's/XK_8/XK_underscore/' \
    -e 's/XK_9/XK_ccedilla/' \
    config.h

make clean install
cd ..
rm -rf dwm-6.0
rm dwm-6.0.tar.gz

echo
echo You can add this line to .xinitrc in your home:
echo
echo 'exec dwm'
echo
echo You may also want to install dwmstatus

exit 0
