Using DWM: A Psychopath Window Manager

After a long time using Openbox + Polybar, my urge to tinker flared up again. This time I want to explore a minimalist window manager that’s extremely simple, without any unnecessary extras — it is dwm

So, what is dwm? 

dwm is an Xorg-based window manager created by the suckless community. The word “suck” we often hear as slang meaning bad or crap. Literally “suckless” can be interpreted as “not bad” → i.e. good. The suckless community focuses on building high-quality programs, meaning non-bloated, straight to the point, doing their job without unnecessary fluff — extremely minimal. And dwm is exactly like that: it’s not flashy, but for advanced users who truly appreciate simplicity and resource efficiency, dwm is the right window manager.

dwm 6.5 on Debian Trixie without wallpaper

How do you use it?

Install it first using this command (Debian-based distro) :

sudo apt install dwm suckless-tools 

After that, restart / log out and choose the dwm session in your display manager. In general, using dwm means more keyboard interaction — minimal mouse / touchpad clicking. To launch a program, use the shortcut: Mod + p, where Mod is the left Alt key (Mod can be changed to another key). To open a terminal there’s the shortcut: Mod + Shift + Enter

Configuration

A Linux desktop environment (DE) and window manager (WM) user cannot avoid the need to configure their DE or WM to fit their needs / preferences — for example for appearance or behavior.

In my opinion there are roughly several “levels” of DE / WM configuration:

| Level                | How configuration is done  |
| -------------------- | -------------------------- |
| Standard             | GUI menus / dialogs        |
| Hacker               | via text config files      |
| Psychopath           | via editing source code 😇 |

And dwm is on that psychopath level: config is done by editing the source code.

Yes you read that right: if you want to change the color scheme in dwm, you must edit the source code, then compile, then install — then your appearance changes. Truly a humane WM — forcing its users to become programmers.

How to modify dwm’s source code on Debian Trixie will be explained in the next section.. 

My mods 

To be able to modify dwm, you first need to prepare the compile toolchain, which can be installed with this command: 

sudo apt install build-essential
Of course, we need to grab the source code first. On Debian Trixie this can be done with the command:
apt-get source dwm
from that command you’ll get a folder called dwm-6.5 which contains the dwm source code that you can modify

folder contains dwm source code

1. Adding system status info to the dwm taskbar

The default dwm taskbar is extremely bare. One of the things you won’t find is system information such as battery level and clock. To add that information I will use an additional program: slstatus

a. Compile slstatus

Yes, that’s right — one of the “psychopath ways” of using slstatus is: you need to compile it yourself. Because its source code is tiny, compiling slstatus can be done even on a “prehistoric-era spec” laptop.  Download the source code first at https://dl.suckless.org/tools/slstatus-1.1.tar.gz and extract the file before compiling. To compile slstatus :

go into the slstatus source code directory, then at the bottom look for the line that contains:

static const struct arg args[] = { ... dst ... }

change its contents to something like this:

static const struct arg args[] = {
    { temp, "[TEMP %sC] ", "/sys/class/thermal/thermal_zone0/temp" },
	{ cpu_perc, "[CPU %s%] ", NULL },
	{ ram_perc, "[RAM %s%] ", NULL },
	{ ipv4, "[WLAN IP %s] ", "wlo1" },
	{ datetime, "[%s]", "%d-%b-%Y %H:%M" },
	{ battery_perc, "[BAT %s%] ", "BAT1" }, /*BAT1 bisa diganti dengan BAT0, cek lewat upower*/
};
then compile using this command:
sudo make clean install

change directory and compiling

Note:  
If you get an error during the compile process because some libraries are missing, please read this post which already covers what dependencies are needed to compile suckless tools: : https://cicl.in/posts/install-suckless-dwm-in-debian 

b. Run slstatus via dwm autostart

The slstatus installation process is done, but slstatus does not run automatically when dwm starts. To make slstatus appear on the dwm taskbar you need to execute it via autostart, so after login and dwm appears, slstatus is also launched automatically.

For dwm to be able to execute slstatus through this autostart mechanism, dwm needs to be patched. A patch is simply a source code modification to add certain features. The autostart patch can be applied so dwm has the ability to automatically launch slstatus. The patch code can be downloaded here:  https://dwm.suckless.org/patches/autostart/dwm-autostart-20210120-cb3f58a.diff

To add the autostart patch in dwm:  
1) save the file dwm-autostart-20210120-cb3f58a.diff into the folder that contains the dwm source code 
2) copy the file config.def.h to config.h  
3) apply the patch using the commands: 

cd folder_path_contains_dwm_code
cp -v config.def.h config.h
patch -i dwm-autostart-20210120-cb3f58a.diff
then recompile dwm using this command:
sudo make clean install

create ~/.dwm/autostart.sh file, write this:

slstatus &
and give execute access using +x parameter in chmod command so ~/.dwm/autostart.sh can be executed after login
chmod +x ~/.dwm/autostart.sh

after logout and login again to dwm you will get slstatus in the up - right corner of dwm

slstatus on the dwm taskbar


Comments

Popular posts from this blog

Contoh Inheritance (Pewarisan) di Java

Review Singkat Pilihan Transportasi Umum Rute Solo - Wonosobo

List Jurnal Ilmu Komputer / Informatika Terakreditasi SINTA