From ArchWiki
Jump to navigation Jump to search


dwm is a dynamic window manager for X. It manages windows in tiled and floating layouts. Either layout can be applied dynamically, optimizing the environment for the application in use and the task performed.


Method 1: Repositories

dwm is available from the standard Arch Linux repositories. If you're just taking dwm for a test spin, this is the most convenient way to do so:

# pacman -S dwm

Method 2: ABS Installation (recommended)

This method will install dwm using the Arch Build System (ABS). This will allow you to reconfigure it at a later time with minimal fuss.


You'll need some basic programming tools in order to compile dwm and build a package for it. You'll also need the ABS package to fetch the necessary build scripts:

# pacman -S base-devel abs

Download build scripts with ABS

Once the required packages are installed, edit /etc/abs.conf as root and make sure that community is enabled in the REPOS array. For example:

REPOS=(core extra community !testing)

Using ABS, fetch the latest build scripts from the repos:

# abs

Lastly, copy the dwm build scripts from the ABS tree to a temporary directory. For example:

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

Build and install package

To compile and install dwm:

  1. Open a terminal and cd 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.

Note: Save this directory somewhere. You can use it again to make changes to the default configuration as described below.


dwm is configured at compile-time via its source source (config.h and config.mk) and must be recompiled whenever making changes. The initial configuration provides a good set of defaults, but at some point you'll probably want to make changes. For patches, customisations, etc., please visit the dwm website.

Method 1: ABS Rebuild (recommended)

If you followed method 2 of the installation phase, then modifying dwm is quite simple.

Customizing config.h

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

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

Once your changes have been made, edit the PKGBUILD file in the same directory and delete the contents of the md5sums array so that it looks like this:


This will eliminate a checksum mismatch between the official config.h and your revised copy.

Now to compile and reinstall:

$ makepkg -efi

Assuming your changes were valid, this command will compile dwm, build and reinstall the resulting package (see makepkg -h for details). As before, if problems were encountered, review the output for specific information.

Note: You must restart dwm in order to see any changes.

Tip: To restart dwm without logging out or closing applications, see the section: Starting dwm.

Method 2: Mercurial (advanced)

dwm is maintained upstream within a Mercurial version control system. If you are already familiar with mercurial, then maintaining your configurations and patches within this system may be more convenient. A detailed tutorial on this method is available at the dwm website.

Patches & Additional tiling modes

The patches page in the official website is full of patches that can add extra functionality to dwm. Users can easily customize dwm applying the patches they like. The Bottom Stack patch provides an additional tiling mode that splits the screen horizontally (opposed to the default tiling mode).

Starting dwm

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

exec dwm

Starting dwm with GDM

For GDM, append the following to ~/.Xclients and select "Run XClient Script" from the Sessions menu:

exec dwm

Statusbar configuration

Piping stdin from another command into dwm will output the results of that command in the status bar.

Basic statusbar

As of (at least) dwm 5.4.x, the statusbar configuration has changed to use xsetroot -name to display information.

This example prints the date in ISO 8601 format. Add this to your ~/.xinitrc or ~/.Xclients file.

while true
   xsetroot -name "$(date +"%F %R")"
   sleep 1m    # Update time every minute
done &
exec dwm

Here is another example for a laptop (make sure you have the acpi package installed):

while true 
    xsetroot -name "$(acpi | awk '{ print $3, $4 }' | sed s/","//g)"
done &
exec dwm

This displays the amount of battery remaining and its status (charging/discharging). The awk command trims away the unneeded text from acpi, and sed removes the commas.

Make sure there is only one instance of dwm in ~/.xinitrc or ~/.Xclients. Combining everything together, it should look something like:

while true
   xsetroot -name "$(date +"%F %R")"
   sleep 1m    # Update time every minute
done &
exec dwm

Conky statusbar

conky-cli, available from the AUR is a special build of conky which prints to stndout. If you're already familiar with conky, a statusbar rich with information can be ready within minutes. Once you have configured conky to your liking, simply pipe it into dwm via your startup file, for example:

conky -c ~/.conkyrc-dwm | exec dwm

The following is a sample conkyrc for a dual core CPU, displaying several stats:

background no
out_to_console yes
update_interval 2
total_run_times 0
use_spacer none

$mpd_smart :: ${cpu cpu1}% / ${cpu cpu2}%  ${loadavg 1} ${loadavg 2 3} :: ${acpitemp}c :: $memperc% ($mem) :: ${downspeed eth0}K/s ${upspeed eth0}K/s :: ${time %a %b %d %I:%M%P}

Tips & Tricks

Fixing gaps around terminal windows

If you find that there are empty gaps of desktop space outside your terminal windows, it is likely due to your terminal font size. You can either tweak the size until you find a sweet spot that closes the gap, or you can toggle resizehints to False in your config.h file:

static Bool resizehints = False; /* False means respect size hints in tiled resizals */

This will cause dwm to ignore resize requests from client windows--this will affect all windows, not just terminals. The downside to this workaround is that some terminals may suffer redraw anomalies (ghost lines, premature line wraps, etc.).

Restart dwm without logging out or closing programs

If you would like to restart dwm without logging out or closing applications, change your startup script to load dwm in a while loop, like this:

/location/of/stdin-script | while true; do /usr/bin/dwm > /dev/null; done;

Simply replace ~/location/to/stdin-script with your own statusbar script or command. Now, you can restart dwm on the fly by pressing M-Q.

Make Alt_R key work as if it were Mod4 (Windows Key)

If you use Mod4 (aka Super aka Windows Key) as your MODKEY, you might find it equally convenient to have your Right Alt key 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 your startup script (e.g. ~/.xinitrc), changing the keycode 113 if necessary to the above result:

xmodmap -e "keycode 113 = Super_L"  # reassign Alt_R to Super_L
xmodmap -e "remove mod1 = Super_L"  # make sure X keeps it out of the mod1 group

Now any functions that are triggered by a Super_L (Windows) key press will also be triggered by an Alt_R key press.

Other Resources

  • dwm -- the official website of dwm
  • dmenu -- a simple application launcher from the developers of dwm
  • dwm wallpapers -- some simple dwm wallpapers

Tutorials and other articles