MOVING TO DWM

Introduction

Dwn is the tiling window manager from which many others, such as spectrwm and xmonad, have forked. Personally, I prefer spectrwm. but if it wasn't available I'd use dwm. Here are some notes about configuring it.

Configuration

You can probably download a packaged version of dwm for your distribution that will work 'as is'. If you want to do any configuration, including changing the Mod key, you will have to edit a file called config.h, which is available if you get the tarball from suckless.org.

Having unpacked the tarball somewhere in your home directory, you run 'make' to produce config.h. Edit this as required and run 'make install' to compile dwm and install an executable file in /usr/local/bin. Edit .xinitrc or whatever you use to start X to reflect the change, and restart X. You should now be running dwm with your modifications. Any errors will be reported on-screen. (See below for other changes that may be needed for .xinitrc.)

All the dwm source files, including config.h, are written in C. This is fine if you know C, but even if you don't and are not a programmer (I'm not), it isn't difficult to modify it. If you look through the lines of code it's mostly pretty obvious what they do, and you can make your own changes using what you find as a model. For example, I added new commands to run my browser (firefox) and my mail reader (mutt). I also made Mod-Tab and Mod-Shift-Tab work the same way as they do in xmonad.

If anything isn't clear, have a look at the suckless.org site, which provides examples of configuration. You can also join the mailing list and ask questions there.

Changing the Mod key

The most important modification you may need to make is to assign the Mod key to a different key instead of Alt. The Windows key is often used for this. See this page for an explanation of how to do this if it isn't obvious.

What if you don't have a Windows key?

I don't have this key on my Thinkpad T41 and I thought I was going to have a problem, but there is a simple solution. The Windows key actually generates Super_L, so this is what you use. Choose another key and redefine it to be Super_L, using xmodmap:

xmodmap -e "keycode xxx = Super_L"

To find out what is the key code for your chosen key, use xev.

Having got this working, you can put the above xmodmap command in your ~/.xinitrc file so that it is run automatically when you start X. Of course, you will lose the normal function of the key you assign as a Windows key, so choose it wisely. The useless and annoying Caps Lock key is a good choice; on my computer its key code is 66. Put two lines in .xinitrc to achieve this (see below). I add a couple of other things in .xinitrc as well, to make the cursor work properly and to set the language to gb instead of us. Here is my ~/.xinitrc file, with comments.


# Next line gives a proper arrow pointer in dwm instead
# of just a cross ('X').
xsetroot -cursor_name left_ptr
#
# set your keyboard layout for your preferred language.
setxkbmap -layout gb
#
# Make Caps Lock (66) give Super_L (Windows).
/usr/bin/xmodmap -e "remove Lock = Caps_Lock"
/usr/bin/xmodmap -e "keycode 66 = Super_L"
#
# The next line starts dwm; it should come last
exec dwm