Quick and dirty dwm + st installation

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.

Dependencies

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

dwm

Starting dwm

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

st

Here's my complete config.h file for st.

Fix st crashing for color emojis

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.

Links

Happy Hacking & have a great day!