Home / Tech / Install dwm from scratch under Ubuntu Minimal
Created on Mon, April 24 2017 11:00

This article will teach you how to install the latest suckless dwm with a minimal Ubuntu install.

Install Ubuntu Server

Install Ubuntu Server with no additional packages (just base). After installation, you should end up at a command-line login.

Install components for dwm

Here's the list of packages we will install on this base setup:

You can install these using apt like so (as root):

sudo apt install xorg-xserver vim stterm suckless-tools build-essential libx11-dev libxinerama-dev libxft-dev

Git some fresh dwm

We need to install git to the latest dwm from suckless. The advantage of installing from source is that you can easily patch and modify your configuration. And you simply need to fetch the latest changes from this repo to get the latest dwm.

apt install git

The official suckless dwm git repo is here: dwm

Let's git our dwm:

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

Change into the dwm directory and compile dwm:

cd dwm
make
sudo make install clean

If there are no errors, it should be installed and ready to use!

Starting dwm using xinit

We want to automatically login to our dwm session when we initially login. The window manager (dwm) needs to be launched by our display manager (X). Usually you can start this using the startx tool.

First we need to xinit to have the startx utility:

apt install xinit

Then we need to create a simple xinitrc at our home directory:

touch $HOME/.xinitrc

But we want it to automatically run startx when we log in. For that we need to edit one more file (creating as needed) in our home directory:

touch $HOME/.bash_profile 
echo "startx" >> $HOME/.bash_profile

Now let us write our xinitrc:

echo "exec dwm" >> $HOME/.xinitrc

Bonus: Tell the time

By default, dwm only displays the the current dwm version on the status bar. Let's make it tell the time!

Edit your xinitrc and append this before the exec dwm line:

xsetroot -name "$( date +"%F %R" )" &
while true; do
   xsetroot -name "$( date +"%F %R" )"
   sleep 1m
done &

What this does is run an infinite loop that updates the dwm statusbar using xsetroot to display the output of the date command.

Reboot for good measure

Fresh Dwm install

After rebooting, log in to your account and X should launch dwm. You now have a base dwm install!

Up next: Web development using dwm