dwm is a dynamic window manager for X. 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 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 multi-head support for xrandr and Xinerama.

Installing

These instructions will install dwm using makepkg along with the Arch Build System, or ABS for short. This will allow reconfiguring it at a later time without complications. If only interested in installing dwm for a test drive, simply install the binary package from the repositories instead:

# pacman -S dwm

Note that by omitting compiling dwm from source a great deal of customizability is lost, since dwm's entire configuration is performed by editing its source code. Taking this in mind, the rest of the article assumes that dwm has been compiled from source as explained in the entirety of this section.

You will probably also want to consider installing dmenu, a fast and lightweight dynamic menu for X:

Download build scripts with ABS

Once the required packages are installed, use ABS to update and then copy the dwm build scripts from the ABS tree to a temporary directory. For example:

# abs community/dwm
$ cp -r /var/abs/community/dwm ~/dwm

Build and install package

Use cd by switching to the directory containing the build scripts (the example above used ~/dwm). Then run:

$ makepkg -i

This will compile dwm, build an Arch Linux package containing the resulting files, and install the package file all in one step. If problems are encountered, review the output for specific information.

Tip: If this directory (~/dwm) is saved, it can subsequently be used for making changes to the default configuration.

Configuring

dwm, as mentioned before, is exclusively configured at compile-time via some of its source files, namely config.h and config.mk. While the initial configuration provides a good set of defaults, it's realistic to expect that at some point potential users will probably want to make adjustments to their setups.

Method 1: ABS rebuild (recommended)

Modifying dwm is quite simple using this route.

Customizing config.h

Browse to the dwm source code directory saved during the installation process; ~/dwm in the example. The config.h found within this directory is where the general dwm preferences are stored. Most settings within the file should be self-explanatory, while others may not share the same trait. For detailed information on these settings, see the dwm website.

Note: Be sure to make a backup copy of config.h before modifying it, just in case something goes wrong.

Method 2: Mercurial (advanced)

dwm is maintained upstream within a Mercurial version control system at suckless.org. Those already familiar with Mercurial may find it more convenient to maintain configurations and patches within this system. A detailed tutorial on this method is available at the dwm website.

Before building dwm from the Mercurial sources, be sure to alter config.mk accordingly, because failure to do so may result in X crashes. Here are the values that need changing:

Modify PREFIX:

PREFIX = /usr

The X11 include folder:

X11INC = /usr/include/X11

And the the X11 lib directory:

X11LIB = /usr/lib/X11

Starting dwm

To start dwm with startx or the SLIM login manager, simply append the following to ~/.xinitrc:

exec dwm

For GDM, add it to ~/.Xclients instead, and select "Run XClient Script" from the Sessions menu.

Starting a customized dwm from a display manager

The default /usr/share/xsessions/dwm.desktop does not allow for a customized start like can be done in .xinitrc.
A solution to this problem is to make a start script, for example /usr/bin/dwm-personalized and make an alternative xsession .desktop file (/usr/share/xsessions/dwm-personalized.desktop).

Using dbus with dwm

If you want to use xfce4-power-manager with dbus/polkit for example to hibernate, you can start dwm the following way from .xinitrc to enable dbus properly (as dwm doesn't provide its own autostart-mechanism which would allow for launching applications after starting only dwm with dbus-support):

exec ck-launch-session bash -c "xfce4-power-manager & dwm"

An even better way would be to put all apps into their own file, e.g. ~/bin/startdwm, and then calling that file from .xinitrc:

Note: the "dwm || exit" allows you to exit dwm more intuitively by calling "$ killall dwm" instead of having to remember the script name and typing "$ killall startdwm". You can still restart dwm simply by hitting ALT+SHIFT+Q as long as you have that while-loop.

Statusbar configuration

dwm uses the root window's name to display information in its statusbar, which can be changed with xsetroot -name.

Basic statusbar

This example prints the date in ISO 8601 format. Add it to files ~/.xinitrc or ~/.Xclients or see this page's discussion for more details about the GDM-3 case :

Basic usage

Using dmenu

Dmenu is a useful addon to dwm. Rather than a standard list-style menu, it acts as a sort of autocomplete to typing in the names of binaries. It is more advanced than many program launchers and integrates well within dwm.

To start it, press Template:Keypress + Template:Keypress (Template:Keypress should be the Template:Keypress key by default). This can, of course, be changed if you so desire. Then, simply type in the first few characters of the binary you wish to run until you see it along the top bar. Then, simply use your left and right arrow keys to navigate to it and press enter.

Closing a window

Window layouts

By default, dwm will operate in tiled mode. This can be observed by new windows on the same tag growing smaller and smaller as new windows are opened. The windows will, together, take up the entire screen (except for the menu bar) at all times. There are, however, two other modes: floating and monocle. Floating mode should be familiar to users of non-tiling window managers; it allows users to rearrange windows as they please. Monocle mode will keep a single window visible at all times.

To switch to monocole mode, press Template:Keypress + Template:Keypress. To check if you are in monocle mode, you can see an M in square brackets (if no windows are open on that tag) or a number in square brackets (which corresponds with the number of windows open on that tag). Thus, a tag with no windows open would display this: [M], and a tag with 'n' windows open would display this: [n].

Exiting dwm

Extended usage

Patches & additional tiling modes

The official website has a number of patches that can add extra functionality to dwm. Users can easily customize dwm by applying the modifications they like. The Bottom Stack patch provides an additional tiling mode that splits the screen horizontally, as opposed to the default vertically oriented tiling mode. Similarly, bstack horizontal splits the tiles horizontally.

Enable one layout per tag

The default behaviour of dwm is to apply the currently selected layout for all tags.To have different layouts for different tags use the pertag patch.

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 False 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.

Urxvt

Another choice for urxvt users is applying the hints patch and regressing to dwm's original behaviour:

static Bool resizehints = True;

Restart dwm without logging out or closing programs

For restarting dwm without logging out or closing applications, change or add a startup script so that it loads dwm in a while loop, like this:

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

It's 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 desiring to actually end the X session simply execute killall startdwm, or bind it to a convenient key.

Make the right Alt key work as if it were Mod4 (Windows Key)

When using Mod4 (aka 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 performing 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:

<keybindname> can be anything... <command> <-flags> and <arguments> can be anything but they have to be individually enclosed in "",

{ MODKEY, XK_<key>, spawn, {.v = <keybindname> } },

...would bind Mod+<key> to the command defined previously.

{ MODKEY|ShiftMask, XK_<key>, spawn, {.v = <keybindname> } },

...would bind Mod+Shift+<key> Use ControlMask for Ctrl key.

Single keys such as Fn or multimedia keys have to be bound with the hex codes obtainable from the program "xev"

{ 0, 0xff00, spawn, {.v = <keybindname> } },

...would bind foo key 0xff00 to <keybindname>

Fixing misbehaving Java applications

As of JRE 6u20, Java applications misbehave in dwm because it is not a known window manager to Java. This causes menus to close when the mouse is released, and other little issues. First, install wmname from the [community] repository:

# pacman -S wmname

Now all you have to do is use wmname to set a WM name that Java recognizes:

$ wmname LG3D

This is not permanent, so you may want to add this command to your .xinitrc.