11 Jul 2021
dwm, the dynamic tiling window manager and st, the terminal emulator are solid programs coming from the suckless project.
Like all suckless projects, these require changes in source code (as patches) for configuration.
Install gcc, make and x11 development libraries to get our build environment ready. For voidlinux, I run the following.
$ sudo xbps-install -S base-devel libX11-devel libXft-devel libXinerama-devel
Clone the repo with
$ git clone https://git.suckless.org/dwm --depth=1
Run a test build
$ cd dwm
$ make
If everything went well, there should be a config.h
file generated for us.
Delete it for the time being. We are going to add some patches.
By default if we change to Monocle/or any other mode in one tag/workspace, all other tags use that mode too. I want the modes to be restricted to just that one tag. The pertag patch does this. I also need a system tray.
If you downloaded dwm as an archive, instead of git, get the patch with
the dwm version dwm-pertag-6.2.diff
and not the one with a date + commit
hash dwm-pertag-20200914-61bb8b2.diff
.
Since we got our dwm from git we'll use the latter.
$ mkdir patches
$ cd patches
$ wget https://dwm.suckless.org/patches/pertag/dwm-pertag-20200914-61bb8b2.diff
$ wget https://dwm.suckless.org/patches/systray/dwm-systray-20210418-67d76bd.diff
To patch, we'll use the patch
command. You can also use git apply patch.diff
.
While in the root of the dwm source directory run,
$ patch -p1 < patches/dwm-pertag-20200914-61bb8b2.diff
$ patch -p1 < patches/dwm-systray-20210217-61bb8b2.diff
The systray patch will make the statusline show ...
when its a bit long. To
change that, open dwm.c
and go to the void drawbar(Monitor *m)
function.
Change the line that says
tw = TEXTW(stext) - lrpad + 2; /* 2px padding */
to this
tw = TEXTW(stext) - lrpad / 2 + 2;
To compile and install, run
$ make
$ sudo make install
Add the following to $HOME/.xinitrc
dwm_status_bar &
exec dwm
Here's the contents for dwm_status_bar
. It updates the status bar every 10
seconds.
#!/bin/sh
bat() {
status="*"
percent="$(awk '{ sum += $1 } END { print sum }' /sys/class/power_supply/BAT*/capacity)"
online="$(acpi -V | grep 'on-line')"
if test -z "$online"
then
status=""
fi
printf '%s%s%%\n' "$status" "$percent"
}
get_line() {
BAT=$(bat)
CLOCK=$(date "+%H:%M")
echo "$BAT $CLOCK"
}
while true
do
xsetroot -name "$(get_line)"
sleep 10s
done
Here's my complete config.h file for dwm. The config has updates keybind and the applied patches - i3wm like keys, volume keys and 2 or 3 script invocations.
If you're interested in the scripts, get them from here.
For people using a login manager like gdm or lightdm, make a file called
/usr/share/xsessions/dwm.desktop
with the following content.
[Desktop Entry]
Encoding=UTF-8
Name=Dwm
Comment=the dynamic window manager
Exec=dwm
Icon=dwm
Type=XSession
Clone the repo with
$ git clone https://git.suckless.org/st --depth=1
There are 4 patches, that I usually apply.
Getting the patches
$ cd st
$ mkdir patches
$ cd patches
$ wget https://st.suckless.org/patches/boxdraw/st-boxdraw_v2-0.8.3.diff
$ wget https://st.suckless.org/patches/clipboard/st-clipboard-0.8.3.diff
$ wget https://st.suckless.org/patches/font2/st-font2-20190326-f64c2f8.diff
$ wget https://st.suckless.org/patches/scrollback/st-scrollback-0.8.4.diff
While in the root of the st source directory run,
$ patch -p1 < patches/st-boxdraw_v2-0.8.3.diff
$ patch -p1 < patches/st-clipboard-0.8.3.diff
$ patch -p1 < patches/st-scrollback-0.8.4.diff
$ patch -p1 < patches/st-font2-20190326-f64c2f8.diff
To install
$ make
$ sudo make install
Here's my complete config.h file for st.
It is a known issue that st
crashes when rendering color emojis. The suckless team even has this in their
FAQ. The
solution for archlinux users
is to install a package called libxft-bgra
and rebuild st
.
libxft-bgra
being a patched package, was unfortunately not available on
voidlinux. Here's a solution that the community suggests that we do.
In $HOME/.config/fontconfig/fonts.conf
, set a fallback font that does not
produce color emojis for Monospace
...
<alias>
<family>monospace</family>
<prefer>
<family>Hack</family>
<family>Symbola</family>
</prefer>
</alias>
...
Look up symbola for your distro. If its not in your package manager's respositories,
get it from here or
here and put the *.ttf
file in
$HOME/.fonts
or $HOME/.local/share/fonts
.
Here's my complete fontconfig file, for reference.
Happy Hacking & have a great day!