# Depends on fontconfig >= 2.11.91
# Depends on rxvt-unicode (used instead of uxterm)
# Depends on wqy-zenhei
# Depends on libxinerama
# Depends on libxft

# Exit on error:
set -e

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

# Install in /:
sed -i '/^PREFIX/s,/usr/local,,' config.mk

cp config.def.h config.h

# Replace st with uxterm:
sed -i '/termcmd/s/"st"/"uxterm"/' config.h

# Use azerty keys
sed -i.1.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

# Use 2 tags instead of 9:
sed -i.2.orig '/tags/s/"1".*"9"/"1", "2"/' config.h

# Make dwm display chinese characters properly:
sed -i.3.orig '/fonts/s/monospace/文泉驛點陣正黑/' config.h

# Make dmenu display chinese characters properly:
sed -i.4.orig '/dmenufont/s/monospace/文泉驛點陣正黑/' config.h

make clean install
cd ..
rm -rf dwm-6.3
rm dwm-6.3.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 dmenu and dwmstatus

exit 0
