AB9IL.net: Ubuntu Linux with DWM-Flexipatch

Written and curated by Philip Collier / AB9IL. Hey, Trolls: Convicted felon Trump is going to jail; Putin to hell. Say goodbye.
HOME Software Defined Radio WiFi Antennas Air and Space Radio Linux or Windows Digital Audio Liberation Tech Video Gallery Photo Gallery

Live Internet SDR List Radio Caroline BBC Radio 4 LW

Airband Radio on the RTL-SDR
How to maximize RTL-SDR performance for aeronautical comms.

We earn a commission if you make a purchase, at no additional cost to you.
screenshot of Ubuntu Linux with the DWM window manager

DWM, the Dynamic Window Manager, is one of the software offerings from Suckless.org. It manages the dimensions and position of application windows arranging them as tiles on the screen. Tiling window managers automatically make the most efficient use of screen area. There is no official flavor of Ubuntu Linux built around a tiling window manager, but there are derivatives and respins using the popular i3 window manager. In this article, you will learn how I installed and make heavy use of DWM on Ubuntu 20.04 and 22.04.

The easiest way to begin setting up DWM on an Ubuntu system is to start with a minimal system installation and build it up with no desktop environment and DWM managing the windows. If you have a fully packed setup with a desktop and the whole suite of applications, that is okay too. I had an Ubuntu MATE system and kept MATE because I liked the apps and look; i3 was my extra sauce for tiling the windows. Reconfiguring to autostart i3 instead of MATE was simple.

Build DWM from source, and use the flexipatch fork! We shall avoid the DWM version in the Ubuntu repositories because it is a generic binary which cannot be further configured. Suckless software is designed for you to configure in the source code and compile as the last step. Furthermore, the basic DWM source code can be a messy tangle when customizing with multiple patches. The best way, by far, to keep the patches organized is DWM flexipatch. It reduces patching to a simple process of editing one file before compiling the binary.

Here are the basic steps:

  1. Have a working Ubuntu system, minimal preferred.
  2. Install DWM dependencies, git, and build-essential package.
  3. Clone the DWM-flexipatch git repository.
  4. Edit the source code (one file for multiple customizations).
  5. Compile the DWM binary.
  6. Configure Ubuntu to run DWM.
  7. Logout and in or reboot into a DWM session.

Several of the commands must be executed as root. For tasks with one or two such commands, I suggest using sudo. If executing more commands with root privileges, change to a root shell with sudo su. When you want to go back to being your regular user, use the command exit.

Downloading Dependencies and More

Several necessary packages need to be installed to support building and running DWM. Execute the following root commands to install them:

sudo apt update && sudo apt install \
libxft-dev libx11-dev libxinerama-dev \
libxcb-xkb-dev libx11-xcb-dev \
libxcb-res0-dev libxcb-xinerama0-dev \

Downloading and Configuring DWM-Flexipatch

Use git to download the DWM flexipatch software. I believe it should go to a safe, sensible location on the system, so use these commands to set up the directories:

sudo su
mkdir -p /usr/local/src
cd /usr/local/src
git clone "https://github.com/bakkeby/dwm-flexipatch.git"

If everything executed without errors, the next step is to select which patches to use for your soon-to-be-fabulous Ubuntu system running DWM. Move into the newly cloned git repo for DWM-flexipatch and open the config file in your text editor. Here, the example uses nano, but use the command for your actual editor. Also, we continue working in the root shell:

cd /usr/local/src/dwm-flexipatch
nano patches.def.h

The file patches.def.h is where to enable or disable DWM patches. To enable a patch, find it in the list and change its status from "0" to "1" and it will be smoothly integrated into the main DWM source code. Start at the top and move down the file, enabling patches you want and making sure to set "0" for patches you do not want integrated in your build of DWM. Here is an example from my build:

#define PERTAG_PATCH 1
#define XRDB_PATCH 1

It is also possible to make changes not included in any patches. You may want certain colors, fonts, or other styles in your build. You may want to use certain keybinds or make specific applications open in floating windows. Those changes should be made to the file config.def.h. In my local build, I changed colors and fonts DWM will use:

// dmenu font
static const char dmenufont[]            = "BitstreamVeraSansMono Nerd Font Mono:size=10";

// colors
static char normfgcolor[]                = "#bbbbbb";
static char normbgcolor[]                = "#222222";
static char normbordercolor[]            = "#444444";
static char normfloatcolor[]             = "#db8fd9";

static char selfgcolor[]                 = "#eeeeee";
static char selbgcolor[]                 = "#005577";
static char selbordercolor[]             = "#217cd0";
static char selfloatcolor[]              = "#217cd0";

static char titlenormfgcolor[]           = "#bbbbbb";
static char titlenormbgcolor[]           = "#222222";
static char titlenormbordercolor[]       = "#444444";
static char titlenormfloatcolor[]        = "#db8fd9";

static char titleselfgcolor[]            = "#eeeeee";
static char titleselbgcolor[]            = "#005577";
static char titleselbordercolor[]        = "#005577";
static char titleselfloatcolor[]         = "#005577";

static char tagsnormfgcolor[]            = "#bbbbbb";
static char tagsnormbgcolor[]            = "#222222";
static char tagsnormbordercolor[]        = "#444444";
static char tagsnormfloatcolor[]         = "#db8fd9";

static char tagsselfgcolor[]             = "#eeeeee";
static char tagsselbgcolor[]             = "#005577";
static char tagsselbordercolor[]         = "#005577";
static char tagsselfloatcolor[]          = "#005577";

After editing the DWM and Flexipatch source code, save the files and continue to the next stage: compling the executable DWM binary.

Compiling the DWM Executable

The most time consuming part of installing DWM is editing the source code. Actually compiling the binary takes a split second. My recommendation is to keep a more clean system by keeping DWM files contained in its local git directory. Compile the binary and create a symlink which the system will use to find it.

For the first act of compiling DWM (and inside the cloned repo directory):

make clean; make
ln -s /usr/local/src/dwm-flexipatch/dwm /usr/local/bin/dwm

For subsequent compilations, when config and patches "dot h" files exist:

rm config.h; rm patches.h; make clean; make

At this point in the process, DWM has been compiled and linked, so the system may use it. The sections below show how to configure the system to actually run DWM at boot time or when selected in the display manager.

Configuring Ubuntu to Run DWM

My DWM setup is a typically minimalist one. At boot time, the machine does an automatic login, starts the X server, and then starts DWM. What actually starts DWM is ths sequence:

  1. The system reads the user's .profile for some X server settings.
  2. The system reads .xinitrc for more settings and receives the command to start DWM.
  3. In addition to DWM, dwm-bar and other utilities are started.

Here is the pertinent code contained in the two files listed above. You may notice that there are two commands to start X. There were some instances of it not starting on certain machines, related to their displays; the redundancy was a solution which got X started reliably.

# this is .profile

# start xserver
if [ -z "" ] && [ -n "" ] && [ "" -eq 1 ]; then
    exec startx

The .xinitrc can be used to start other helpful applications, such as the settings manager, screen compositor, and wallpaper manager:

# this is .xinitrc

# get user directories
(xdg-user-dirs-update) &

# bluetooth
(blueman-applet) &

# app settings
(mate-settings-daemon) &

# use picom compositor
(picom --experimental-backends --config ~/.config/picom/picom.conf) &

# background wallpaper
(feh --no-fehbg --bg-scale /usr/share/backgrounds/wallpaper.png) &

# start the window manager and status bar
while type dwm >/dev/null; do /usr/local/src/dwm-bar/dwm_bar.sh & dwm && continue || break; done

The above files work fine for a single window manager environment. When the system has a desktop environment installed, DWM needs be listed in the display manager as a sesson option. Instead of starting DWM from .xinitrc, a launcher needs to be placed in the shared xsessions directory: /usr/share/xsessions/dwm.desktop.

Open a terminal, start a text editor as root:

nano /usr/share/xsessions/dwm.desktop

Enter the necessary launcher contents:

[Desktop Entry]
Comment=Dynamic Window Manager

When restarting the computer, or logging out and back in, the display manager's login screen should offer "dwm" in the list of available sessions.

What about making DWM the default session? That may be accomplished by editing certain configurations. First, open your text editor as root and make DWM the default for your user:

sudo nano /var/lib/AccountsServices/users/your-user-name

Here is the content to edit:


Also, DWM should be selected in the update-alternatives tool. DWM should be listed as an alternative; enter its corresponding number in the list to set it as the default alternative:

sudo update-alternatives --config x-session-manager

For example, here is a list of session alternatives.

There are 3 choices for the alternative x-session-manager (providing /usr/bin/x-session-manager).

  Selection    Path                    Priority   Status
  0            /usr/bin/gnome-session   50        auto mode
  1            /usr/bin/gnome-session   50        manual mode
  2            /usr/bin/i3              50        manual mode
* 3            /usr/bin/dwm             40        manual mode

Press  to keep the current choice[*], or type selection number:

Further Tweaking DWM

After using DWM for a while, you will probably find a few things to adjust for a better user experience. It is the best thing about Linux that nearly unlimited customizations are possible. You can change the keybindings, colors, fonts, and set up specific behaviors for managing windows. You can tweak the tiles and floats all sorts of ways. Essential is knowing exactly what you want and then making the proper changes in the source code.

There are some other things to consider for your Ubuntu Linux system, which will affect some of the settings in your DWM condiduration:

When things are working well, make backups of your patches.def.h and config.def.h files.

It is a good idea to create a patch for manual changes you make to the file config.def.h. That is for things like fonts, colors, keybinds, window borders, etc. In the code below the original file is the unedited version from the cloned git repository; the new file is the one you have edited and want to create a patch from. The resulting config.def.h is the patch. After creating it, keep it in a safe place to use in the future, to restore your setup after getting a fresh upgrade from the online git repository.

Use the diff utility with options "-Naru" and proper path and file names.

diff -Naru original.def.h new.def.h > config.patch


DWM opens the door to much greater efficiency during your computing sessions. It handles the tasks of placing, shaping, and sizing your application windows on the screen. With a good set of keybinds, you can fly through your work flow. Among tiling window managers, DWM is among the most lightweight and fast.

The steps given above will help you download, configure, install, and start DWM. DWM-Flexipatch greatly simplifies the use of patches to configure DWM. Instead of poking around in the code, getting a patch is as simple as setting zeroes and ones in the flexipatch config file.

Enjoy DWM; happy computing.

© 2005 - 2024 AB9IL.net, All Rights Reserved.
About Philip Collier / AB9IL, Commentaries and Op-Eds, Contact, Privacy Policy and Affiliate Disclosure, XML Sitemap.
This website is reader-supported. As an Amazon affiliate, I earn from qualifying purchases.