Last modified: October 11, 2024

This article is written in: 🇺🇸

Dynamic Window Manager (DWM)

The Dynamic Window Manager (DWM) is a minimal, lightweight, and highly efficient tiling window manager designed to help you manage application windows in a clean and distraction-free manner. Instead of overlapping windows as seen in traditional window managers, DWM organizes windows in a tiled layout, making it easy to see and navigate multiple applications simultaneously. DWM is based on the X Window System, making it suitable for use on Unix-like operating systems.

DWM stands out for its extreme simplicity and high customization capability. It is part of the suckless software philosophy, which emphasizes clarity, simplicity, and resource efficiency.

dwm

Here's how DWM looks in action. Each window takes a portion of the screen, allowing for easy multitasking.

Installation

Installation of DWM is straightforward. If you're on a Debian-based system such as Ubuntu or Mint, you can install DWM and its related suckless-tools packages using the following command in your terminal:

sudo apt install dwm suckless-tools

The suckless-tools package contains additional utilities developed by the suckless community, including dmenu, a fast and lightweight dynamic menu for X, and slock, a simple screen locker utility.

After installation, you can choose DWM as your window manager from the login screen.

Remember that DWM is highly customizable, but changes typically require modifying the source code and recompiling. So if you're up for some tinkering, you can clone the DWM source code from the suckless website, make changes to suit your needs, and then build and install your custom version of DWM.

Usage

Configuration

Unlike other window managers that use configuration files, DWM is customized by directly modifying its source code and then recompiling it. This approach provides a lot of flexibility and control over DWM's behavior and appearance. The main configuration is located in the config.h file, which can be found in the DWM source code directory.

Follow these steps to customize DWM to your preferences:

Download the DWM Source Code

You can clone the source code from the official suckless git repository using the following command:

git clone https://git.suckless.org/dwm

The config.def.h file contains the default settings. To customize DWM, you should first copy config.def.h to config.h. Then, you can edit the config.h file with your preferred text editor (e.g., nano, vim, emacs). Here's how to do that:

cd dwm
cp config.def.h config.h
nano config.h

Customize the config.h File

In the config.h file, you can change various settings according to your preferences. For example, you can modify key bindings, set custom colors, define the status bar's appearance, and select the default font.

Changing the Border Configuration:

I. Within config.h, locate the section where the border settings are defined. It typically looks like this:

static const unsigned int borderpx  = 1;        /* border pixel of windows */

borderpx controls the width of the border around each window. The default value is usually 1 pixel.

II. To increase or decrease the border width, change the value of borderpx. For example, to set the border width to 2 pixels, change the line to:

static const unsigned int borderpx  = 2;

If you want to remove the border entirely, you can set borderpx to 0:

static const unsigned int borderpx  = 0;

III. The border color for both focused and unfocused windows is defined in the color scheme section of config.h. Look for the following lines:

static const char col_gray1[]       = "#222222";
static const char col_gray2[]       = "#444444";
static const char col_gray3[]       = "#bbbbbb";
static const char col_gray4[]       = "#eeeeee";
static const char col_cyan[]        = "#005577";
static const char *colors[][3]      = {
   /*               fg         bg         border   */
   [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
   [SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
};

Here, col_cyan is used for the border of the focused window, and col_gray2 is used for the unfocused windows. To change the border color, replace the hex color code with your preferred color. For example, to change the focused window border to red:

static const char col_red[]         = "#ff0000";
static const char *colors[][3]      = {

   /*               fg         bg         border   */

   [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },

   [SchemeSel]  = { col_gray4, col_red,   col_red   },

};

IV. After adjusting the border settings and any other customizations, save your changes and exit the text editor.

Compile and Install the Modified DWM

After modifying the config.h file, you need to compile the DWM source code and install the new binary:

sudo make clean install

This command will clean up any previous builds and compile your customized version of DWM.

Apply the Changes

To apply your changes, you need to restart DWM. You can do this by logging out and logging back in, or by restarting your X session. Once you log back in, the updated DWM with your new border settings and other customizations should be in effect.

Further Resources

Table of Contents

    Dynamic Window Manager (DWM)
    1. Installation
    2. Usage
    3. Configuration
      1. Download the DWM Source Code
      2. Navigate to the dwm Directory and Create a config.h File
      3. Customize the config.h File
      4. Compile and Install the Modified DWM
      5. Apply the Changes
    4. Further Resources