dwm

dwm is a dynamic window manager for Xorg. It manages windows in tiled, stacked, and full-screen layouts, as well as many others with the help of optional patches. Layouts can be applied dynamically, optimizing the environment for the application in use and the task being performed. dwm is extremely lightweight and fast, written in C and with a stated design goal of remaining under 2000 source lines of code. It provides multihead support for xrandr and Xinerama.

Installation

Configuration

dwm is configured at compile-time by editing some of its source files, specifically config.h. For detailed information on these settings see the included, well-commented config.def.h as well as the customisation section on the dwm website.

The official website has a number of patches that can add extra functionality to dwm. These patches primarily make changes to the dwm.c file but also make changes to the config.h file where appropriate. For information on applying patches, see the Patching packages article.

Starting

Select Dwm from the menu in a display manager of choice. Alternatively, to start dwm with startx append exec dwm to ~/.xinitrc and prepend other programs to execute them as well, for example:

Usage

Tips and tricks

Statusbar configuration

Note: The following requires the xorg-xsetroot package to be installed.

dwm reads the name of the root window and redirects it to the statusbar. The root window is the window within which all other windows are drawn and arranged by the window manager. Like any other window, the root window has a title/name, but it is usually undefined because the root window always runs in the background.

The information that you want dwm to show in the statusbar should be defined with xsetroot -name "" command in ~/.xinitrc or ~/.xprofile (if you are using a display manager). For example:

xsetroot -name "Thanks for all the fish!"

Dynamically updated information should be put in a loop which is forked to background - see the example below:

In this case the date is shown in ISO 8601 format and PCManFM is launched at startup.

Note: It is not recommended to set the update interval equal to zero or remove the "sleep" line entirely since this will cause CPU usage to rise substantially (you can assess the effect with top and powertop).

dwm can now be restarted without destroying other X windows by pressing the usual Mod-Shift-Q combination.

It is a good idea to place the above startup script into a separate file, ~/bin/startdwm for instance, and execute it through ~/.xinitrc. From this point on, when you wish to end the X session, simply execute killall xinit, or bind it to a convenient key. Alternatively, you could setup your dwm session script so that it relaunches dwm only if the binary changes. This could be useful in the case where you change a setting or update the dwm code base.

Bind the right Alt key to Mod4

When using Mod4 (the Super/Windows Key) as the MODKEY, it may be equally convenient to have the right Alt key (Alt_R) act as Mod4. This will allow you to perform otherwise awkward keystrokes one-handed, such as zooming with Alt_R+Enter.

First, find out which keycode is assigned to Alt_R:

xmodmap -pke | grep Alt_R

Then simply add the following to the startup script (e.g. ~/.xinitrc), changing the keycode 113 if necessary to the result gathered by the previous xmodmap command:

After doing so, any functions that are triggered by the Super_L key press will also be triggered by an Alt_R key press.

Note: There is a #define option in config.h which also allows you to switch the modkey.

Space around font in dwm's bar

By default, dwm's bar adds 2px around the size of the font. To change this, modify the following line in dwm.c:

bh = dc.h = dc.font.height + 2;

Disable focus follows mouse

To disable focus follows mouse behaviour comment out the following line in definiton of struct handler in dwm.c

[EnterNotify] = enternotify,

Note that this change can cause some difficulties; the first click on an inactive window will only bring the focus to it. To interact with window contents (buttons, fields etc) you need to click again. Also, if you have several monitors, you may notice that the keyboard focus does not switch to another monitor activated by clicking.

Floating layout for some windows

For some windows, such as preferences dialogs, it does not make sense for these windows to be tiled - they should be free-floating instead. For example, to make Firefox's preferences dialog float, add the following to your rules array in config.h:

{ "Firefox", NULL, "Firefox Preferences", 1 << 8, True, -1 },

Troubleshooting

Fixing misbehaving Java applications

Try setting export _JAVA_AWT_WM_NONREPARENTING=1. Also see the Java page.

Fixing gaps around terminal windows

If there are empty gaps of desktop space outside terminal windows, it is likely due to the terminal's font size. Either adjust the size until finding the ideal scale that closes the gap, or toggle resizehints to 0 in config.h.

This will cause dwm to ignore resize requests from all client windows, not just terminals. The downside to this workaround is that some terminals may suffer redraw anomalies, such as ghost lines and premature line wraps, among others.

Known issues

Crashes due to Emojis in some fonts

Emojis in title bars may cause dwm to crash with an error similar to the following: