John Jago

A guide to dwm on Debian

Like most people, my first Linux distribution was Ubuntu. As time passed, I became interested in finding quality software that does exactly what it needs to do and nothing more. Naturally this led me to try other distros, each with a different desktop environment. When I discovered that you can run a window manager without a desktop environment, I was hooked. At first I used i3, and eventually I found dwm, a minimalist window manager whose source code is not intended to exceed 2000 lines. This makes it possible to quickly read and understand the source code.

This will be a guide to installing and configuring dwm and a few related programs on a fresh Debian install without any desktop environment. If you already have a desktop environment installed, it is possible to have both options installed and available, but it requires additional steps that won’t be covered here.

The best resource for learning about dwm is the documentation. Because dwm is not as popular as awesome or i3, you’ll have a hard time finding answers to your questions on Stack Overflow. You’re better off reading the docs or trying to figure it out on your own, which is doable considering the simplicity and small size of the program.

Download

First we need to download dwm. Replace the version number as needed. I will also download st, a terminal emulator, and dmenu, a program to quickly launch executables. Both of these make dwm more usable.

wget https://dl.suckless.org/dwm/dwm-6.2.tar.gz
wget https://dl.suckless.org/st/st-0.8.2.tar.gz
wget https://dl.suckless.org/tools/dmenu-4.9.tar.gz

Then we extract each one.

tar xf dwm-6.2.tar.gz
tar xf st-0.8.2.tar.gz
tar xf dmenu-4.9.tar.gz

Install

If you ever download software and don’t know what to do with it, always read the README first. dwm’s README is short and helpful.

On Debian, at least when I ran through these steps, there was no need to make changes to config.mk. Run sudo make clean install in the root directory of dwm, where the Makefile is. Chances are there will be some missing dependencies. When I ran it, I had to do the following:

sudo apt install make gcc libx11-dev libxft-dev libxinerama-dev xorg

However, it’s best to install dependencies one at a time and then rerun sudo make clean install until it works so that you don’t install things that you don’t need.

Next, create a file called .xinitrc in your home directory. Place this inside of it:

while xsetroot -name "`date` `uptime | sed 's/.*,//'`"
do
	sleep 1
done &
exec dwm

Only the last line is necessary. The other lines display the date and the load average over the last 15 minutes in the top right corner. You can change this to be whatever you want. Battery percentage is helpful if you’re using a laptop. Get creative.

Once you create that file, run the command startx to launch dwm.

Defer to the dwm tutorial for a complete list of commands.

st and dmenu

The steps to configure and install st and dmenu are very similar. In fact, running sudo make clean install on each should be all you need to do.

Configure

One thing about dwm that most people think is weird is that you have to edit the source code to customize it instead of editing a configuration file. Unless you change things daily, this isn’t an issue as compiling takes only a few seconds. To be fair, it’s not really source code that you’re editing. It’s a C header file with some variables.

To configure dwm, copy config.def.h to config.h and make your changes in config.h. Then run sudo make clean install.

If dwm feels too minimalist for you, don’t leave just yet. Many people have submitted patches that add more functionality. All you need to do to apply a patch is download the patch into the root directory of dwm and run git apply name-of-file.diff. But applying patches haphazardly could become a mess! Luckily, there is a guide to managing your configuration with Git.

Exercise for the reader

At this point, you may wonder how you’re going to control sound volume and screen brightness now that there is no icon on the taskbar that you can click on and now that some keys no longer work as they did when you had a full desktop environment. There is no one solution, so situations like this force you to learn and find what works best for your workflow.