Debian/Ubuntu minimal Xorg installation with dwm

I already have an article about minimal Xorg installation in FreeBSD with dwm. This article is about the same but with Debian-based systems. The method below is useful when the hard drive has small amount of free space. So, for disk space economy. Also it is good feeling to know that the system has only necessary packages. But I make it just for fun and interest.

First of all, I used minimal Debian installation with daily-generated .iso.

Debian minimal installation - do not install additional software in installation process
Uncheck all the options

There is no tools like wget, dbus and others, any desktop environment is missing.

When the system is installed, we can start Xorg installation process.

Minimal Xorg core installation

First, we need to install Xorg core, it is very minimal:

sudo apt install --no-install-recommends xserver-xorg-core               # Basic Xorg libraries, utilities
sudo apt install --no-install-recommends xserver-xorg-input-all         # Provides input driver for devices like keyboard, touchpad
sudo apt install --no-install-recommends xserver-xorg-video-fbdev   # Xorg display driver
sudo apt install --no-install-recommends xserver-xorg-video-(your videocard, can be intel, nouveau, or ati)     # Free and open-sourced video drivers

Then install additional utilities and fonts that is required for correct work:

sudo apt install --no-install-recommends dbus                        # Necessary for process comunication
sudo apt install --no-install-recommends fonts-dejavu-core   # Minimal set of fonts, dejavu fonts are used by dwm by default
sudo apt install --no-install-recommends xinit                        # X session starting tools

Try to perform startx command now:

startx

If there is an error and in the log file you see this message:

(EE) modeset(0): drmSetMaster failed: Permission denied
(EE) AddScreen/ScreenInit failed for driver 0

The additional package need to install.

This means that X-server doesn’t have enough rights (Xorg tries to access some files which are required by old drivers). We need to install another package and correct a config and this problem will disappear:

sudo apt-get install xserver-xorg-legacy

Then open /etc/X11/Xwrapper.config file:

sudo nano /etc/X11/Xwrapper.config

And add the following lines (which are missing):

allowed_users=console
needs_root_rights=yes

Now try startx command, X-server should shut down correctly (successfully):

startx

Preparations for dwm

At the runtime process, dwm requires a couple of dependencies. These packages must be installed:

sudo apt install --no-install-recommends libxinerama1   # Xinerama extension for X protocol (multiple screens attached to a single display)
sudo apt install --no-install-recommends libxft2             # Font drawing library for X

Default dwm from repository

Now we can try already compiled, default dwm from repository. OK, install it:

sudo apt install --no-install-recommends dwm      # Without any modifications, already compiled dwm from repository

Then open ~/.xinitrc file:

nano ~/.xinitrc

And add the following line inside:

exec dwm

Start X-server:

startx

Use Alt + Shift + Q shortcut to quit from dwm and X.

Modification and building of dwm

Build-dependencies and git repository download tool

sudo apt install --no-install-recommends git ca-certificates 			                # For sources downloading from git repostiories, certificates for secure connection
sudo apt install --no-install-recommends build-essential				        # gcc, make and other tools for sources compiling
sudo apt install --no-install-recommends libx11-dev libxinerama-dev libxft-dev	# Development headers, required for dwm and dmenu building

Sources downloading

mkdir sources
cd sources
git clone https://git.suckless.org/dmenu
git clone https://git.suckless.org/dwm

dmenu modification and building (used by dwm environment with Alt + P shortcut)

dmenu config modification:

cd dmenu
cp config.def.h config.h
nano config.h
---Here you can make some changes, set up fonts, colors, where dmenu will appear (top or bottom), how many lines and others

dmenu building and installing:

sudo make install clean		# ~1 sec of compilation
whereis dmenu			# Show path where dmenu is installed
...
dmenu: /usr/local/bin/dmenu   # dmenu is installed in our system with our config settings

dwm modification and building

Make some config changes and build dwm:

cd dwm/
cp config.def.h config.h

Install a terminal that you will use with a dwm:

sudo apt install --no-install-recommends rxvt-unicode      # Install any terminal which you like

Open config.h to make urxvt our default terminal:

nano config.h

Replace this line (st terminal is used by default):

static const char *termcmd[] = { "st", NULL }

With this line (now urxvt will be used):

static const char *termcmd[] = { "urxvt", NULL }

Now build dwm:

sudo make install clean

Don’t forget make dwm to start with X session, open .xinitrc file:

nano .xinitrc

And add the following line:

exec dwm

Start X session with dwm:

startx

Use the following shortcuts:

Alt + Shift + Enter - Run terminal which is in config.h
Alt + P                   - Run dmenu, write program name there and press [Enter] to run the program
Alt + Shift + Q       - Quit from dwm and X
Debian with dwm with minimal xorg installation, 378 packages installed
Debian with minimal X installation with dwm and edited urxvt config

I slightly modified urxvt config file. Read this article – urxvt + Iosevka fonts to find out how to do similar.

Firefox is only available in unstable area of repository. See the article how to install from unstable repository when it needed to install firefox.

Alt + P to run dmenu, then type fire press [Tab] to autofill the program name since it found:

dmenu program search “fire”

Press [Enter] to run firefox:

Firefox under minimal Xorg installation works correctly. Firefox requires additional ~60 packages as dependencies to be installed. So, this installation with firefox is ~450 packages summary. Debian has a very fragmented repository, unlike FreeBSD or Arch Linux: ffmpeg is only one package in FreeBSD but more than 20 in Debian (ffmpeg libraries, tools are separated packages)

Leave a Reply

Your email address will not be published.