dwm the suckless way

dwm as a window manager; simple config.h and statusbar modifications

So I was learning about suckless software and their philosophy lately. I found it fascinating, so I wanted to learn more about it. I had been using st the simple terminal before and I liked it, but I couldn’t quite make it replace urxvt because it just fits my workflow better.

dwm had been just one crazy idea for me; people who would recompile their window manager just to make one minor modification. I thought no, that’s not for me.

Coming from i3, I was used to seamlessly restarting my window manager to reload the config file(s).

This is also possible in dwm using very simple scripts but not subject of this blog post. I just want to share some thoughts about my (first) experience with dwm.

Compiling from source

suckless is all about having unbloated software that is simple enough for every interested user in order understand, adjust and recompile the source code for themselves.

It just takes 2 seconds

dwm is so small, compiling it is done within seconds, so it’s really not much different from having i3 reload its config files in practice. It’s just the added benefit that it’s all done in C, so it’s cleaner and just sucks less than using several different languages.

Fedora comes with a special package for dwm that introduces a “dwm-start” binary which automatically looks on your system for a ~/.dwm/config.h file, recompiles the source if the config.h has changed from the last compilation time and then installs the binary and executes it.

You can actually do the same with just 3 lines of bash code in your ~/.xinitrc but seeing that the official package in the Fedora packages comes that way that it is supposed to be recompiled every time kind of convinced me to do it :)

So I proceeded to do some simple changes to the config.h and start using dwm-start as my preferred way to start dwm on fedora. There is a config.def.h example config file that comes with dwm which you can use as a base to create your first config.h.

I changed the name of the tags, the default font, and default terminal to urxvt. Added Keybindings for volume control and nothing more.

The standard way of dwm is already pretty good

I did not do much more, using i3 I was used to very long config files to get everything right the way I wanted but with dwm the default way is already pretty nice.

The dwm way of tiling

Part of why dwm just feels great is because it is designed with the idea in mind that you never should have to think about HOW it is supposed to tile, it just TILES and you do your work.

(I think the origins for the dwm tiling philosophy lie with the old Acme editor from Plan9)

I found a great introduction to the dwm way of tiling on this blog post

Creating your own status bar

This is so simple with dwm (maybe more simple than with i3). So I want to speak about my first own status bar. On dwm this is set just by

xsetroot -name "blabla"

dwm reads this x default value and puts it in the status bar. So all you need is one simple bash script that you run when you are using dwm to create your status bar.

I wrote the following script

xrunning=~/.dwm/isrunning
touch "$xrunning"

cpu_temperatur() {
	echo $(head -c 2 /sys/class/thermal/thermal_zone0/temp)C
}

while [[ -f "$xrunning" ]]; do
	DATUM="$(date '+%R:%S')"
	IPADDR="$(ip addr show enp7s0|grep inet |head -1 | awk '{print $2}')"
	sleep 1
	xsetroot -name "YABBES @ $IPADDR + $DATUM CPU @ $(cpu_temperatur)"
	
done &

Which results in a simple statusbar with my ip address, the current time and my cpu temperature. You will notice that I didn’t use a simple while true but rather use the existence of the file $xrunning as a condition for my statusbar to periodically update.

I adjusted this because with this solution I have a way of stopping this script when I want to do further modifications. At first I didn’t and then it was a little hard to find the related process ;-) I had to hunt down the sleep process in ps aux (which changed every second) to kill it it was crazy :-P

dwm vs i3

It’s really hard to talk about all features of what makes dwm; I cannot do this, but my experience is that dwm is a window manager that helps you NOT THINK about how to position your windows. It has one fixed style, it’s all about the ratio between Master and Stack that you set and then the windows you open will just get placed by dwm.

I find this very convenient and nice. So far I like my dwm experience a lot.