Skip to content

Dwm Howto

Kyle Terrien edited this page Jan 2, 2018 · 1 revision

dwm is the suckless.org "dynamic window manager" for X. It is a dynamic tiling window manager, which means:

  • window manager - a program that handles how windows are positioned on the screen
  • tiling - The window manager arranges windows next to each other as opposed to letting the windows overlap.
  • dynamic - The window manager attempts to position the windows for you according to preset layouts.

Try dwm if you are the kind of user who likes to maximize every window but still wishes to see other windows at the same time. Also, consider dwm if you are the kind of person who enjoys C, dislikes unnecessary complexity, and does not shy away from the "do it yourself" approach.

This article is an addon to the Window-Maker-Howto. This article assumes you have at least browsed through that article.

Installation

Your distribution may have a dwm package. I recommend against installing it. dwm has way too many important options that are set at compile time. Compile from dwm source instead.

However, do install your distributions dmenu package, because it provides the launcher dmenu_run. If your distribution does not package dmenu, then grab the dmenu source and install yourself.

After untarring the dwm source, make a config file from the default config file.

$ cp config.def.h config.h

We will come back to adjusting the config file in a little bit. Now, compile and install.

$ make
$ sudo make install

This will install to /usr/local by default.

Xorg session configuration

Adjust .xinitrc so that it calls dwm.

exec dwm

Brief tutorial

Refer to the dwm tutorial on the suckless.org site. dwm is heavily keyboard driven, so this document is a must read.

Configuration

The bad news: by default, dwm uses many -key bindings that frequently conflict with running applications.

The good news: everything is configurable in config.h. Simply open the file and hack away. The comments describe just about everything you need to know.

The bad news: all the options are compile-time options. This is why I highly recommend compiling dwm from source instead of installing your distribution's binary package.

Unfortunately, a recompile means that you need to install the new dwm binary and restart dwm.

$ make
$ sudo make install

To aid restarts I find it helpful to create a wrapper script (called startdwm) that continually restarts dwm. (Taken from Arch Wiki)

#!/bin/sh
while true; do
    # Log stderror to a file 
    dwm 2> ~/.dwm.log
    # No error logging
    #dwm >/dev/null 2>&1
done

Then, adjust .xinitrc to call startdwm.

exec startdwm

To exit dwm entirely, kill processes manually

$ killall startdwm
$ killall dwm

Status bar

The status bar displays the name of the root window. dwm has no logic to automatically update, so you will need to write your own helper script.

Example: replace the contents of the status bar with the hostname.

$ xsetroot -name "$(uname -n)"

The stupid/simple way is to put an xsetroot command in a while loop that forks to the background. (Put in .xinitrc or startdwm)

while true; do
    xsetroot -name "$(cat /proc/loadavg)"
    sleep 5
done &

A better way is to write your own system monitor that occasionally updates the name of the root window. go-dwmstatus is a good place to start. It is a simple program written in Go that is easy to customize. Also, it compiles to a single statically-linked binary.

System tray

Bad news: dwm has no system tray. Also, the developer is against including a system tray in the mainline source.

Good news: there is a systray patch.