Updated 17-Oct-2013 : Getting extra keyboard keys working with DWM [ jump to this ]

Updated 19-Aug-2014 : Getting antialiased fonts [ jump to this ]

I decided to give dwm (another tiling window manager, from which xmonad is forked) a try, and man was I blown away by its super simple configuration and fast setup (since it is written in C, unlike Xmonad which is written in haskell). Since I am not a power user of Xmonad, dwm more than satisfied my requirements and actually made the things that I cared for much more simpler. No more downloading a haskell compiler. dwm’s download, build and install is terribly fast compared to xmonad. Simply loving it so far :) Many of the key-bindings are common between dwm and xmonad, so it’s very easy to make the switch from xmonad to dwm.


$ wget http://dl.suckless.org/dwm/dwm-6.0.tar.gz
$ tar xf dwm-6.0.tar.gz && cd dwm-6.0
$ make && sudo make install
$ sudo apt-get install acpi trayer gtk-chtheme gmrun terminator dmenu #optional


Create the file /usr/share/xsessions/dwm.desktop with the following contents (root required).

[Desktop Entry]
Comment=Lightweight tiling window manager

Give the above file proper permissions.

$ sudo chown root:root /usr/share/xsessions/dwm.desktop

The above file is required to give you the option to choose dwm as your window manager at the login prompt.

Next, create the file /usr/local/bin/dwm-personalized with the following contents (root required). Make the file executable with sudo chmod +x /usr/local/bin/dwm-personalized


mpd &>/dev/null &
dropbox start &>/dev/null &
redshift -l 12.9667:77.5667 -t 3700:3700 &>/dev/null &
trayer --edge bottom --align right --SetDockType true \
--SetPartialStrut true --expand true --widthtype percent \
--width 100 --height 25 &>/dev/null &
sudo nm-applet &>/dev/null &
while true
    DATE=$(date +"%Y-%m-%d %I:%M")
    BAT=$(acpi -b | awk '{ print $4 }' | tr -d ',')
    xsetroot -name "$BAT $DATE"
    sleep 1m
done &
exec dwm

The above file contains commands to autostart your favourite applications(redshift, dropbox, mpd(ncmpcpp) and the like) as well as get a system tray for some important applets(nm-applet, dropbox and the like) by using trayer (just like in the xmonad post) and display some useful info like battery percentage and date in the top bar of dwm instead of the obvious “dwm-6.0” string displayed by default.

Now, let us try our hand and configuring dwm itself to suit our tastes. Remember that we have already installed dwm with the default configurations above. To re-configure dwm, you will mostly have to modify config.h and/or dwm.c and recompile and re-install dwm as below.

$ cd dwm-6.0

Now make the necessary configuration changes in config.h and/or dwm.c . Here is my config.h. The helpful comments make it very easy to understand what each option is for. When you’re done, just recompile and re-install dwm as below

$ make && sudo make install

Finally the most imp thing – aesthetics. As with the basic xmonad setup, if you use dwm with just the above setup, you will find that gtk applications like Firefox look terribly ugly, but fixing this issue is simple. So, go ahead and do it before you start using dwm.

Launch gtk-chtheme and select your preferred gtk-2.0 theme and any font that catches your eye as well. Save your settings. You should now find the file ~/.gtkrc-2.0.

Now, let us fix some ugly gtk-3.0 apps as well. Create the file ~/.config/gtk-3.0/settings.ini with the following contents (choose your preferred themes and fonts).

gtk-theme-name = Lubuntu-default
gtk-icon-theme-name = Lubuntu
gtk-font-name = Ubuntu Medium 11

That’s it. Logout and log in selecting dwm as your session (instead of the default Lubuntu) at the login prompt. You are greeted with a plain screen. Press Win+Shift+Ret to launch the terminal or Win+p to launch your fav apps via gmrun. For more basic key-bindings and usage, checkout the man page of dwm.

UPDATE (17 OCT 2013)

Getting extra keyboard keys to work with DWM

Finally got some extra keyboard keys like audio volume control keys and audio mute key working with dwm. Here is how to do it for your keyboard.

First, get the hex value of keycode for the keys you are interested in. For example,

$ xmodmap -pk | grep -i audio

should give you the hex value of keycode for the audio control keys on your keyboard. For me, the values are as below.

0x1008ff12 (XF86AudioMute)
0x1008ff11 (XF86AudioLowerVolume)
0x1008ff13 (XF86AudioRaiseVolume)

Next, we need to modify config.h and specify what commands each of these keys will invoke when pressed. So, add the following lines to ~/dwm-6.0/config.h.

static const char *mutecmd[] = {"amixer","-q","sset","Master","toggle",NULL};
static const char *lowervolcmd[] = {"amixer","-q","sset","Master","1%-",NULL};
static const char *raisevolcmd[] = {"amixer","-q","sset","Master","1%+",NULL};

static Key keys[] = {
    { 0,              0x1008ff12,spawn,          {.v = mutecmd } },
    { 0,              0x1008ff11,spawn,          {.v = lowervolcmd } },
    { 0,              0x1008ff13,spawn,          {.v = raisevolcmd } },

Here is the new version of my entire config.h with the above changes.

Thats it !!!. Recompile and re-install dwm.

$ cd ~/dwm-6.0
$ make && sudo make install

To test your new settings, hit Win+Shift+q. Functionality for other keys can be added similarly.

UPDATE (19 AUG 2014)

Getting antialiased fonts in dwm

Somehow, dwm does not automatically get antialiased fonts like when you are running gnome, etc. The following is the config file to enable antialiased and hinted fonts in dwm. Put the following in ~/.fonts.conf.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    <!-- Enable antialiasing for all fonts -->
    <match target="font">
        <edit mode="assign" name="antialias"><bool>true</bool></edit>
    <!-- Enable hinting -->
    <match target="font">
        <edit name="hinting" mode="assign"><bool>true</bool></edit>
    <match target="font">
        <edit name="hintstyle" mode="assign"><const>hintslight</const></edit>
    <!-- subpixel rendering -->
    <match target="font">
        <edit name="rgba" mode="assign"><const>rgb</const></edit>