
DWM (dynamic window manager) in Enterprise Linux 8

Dwm (dynamic window manager) is, as the name suggests, a dynamic window manager. For many years he has been the choice of Linux geeks. In this article we will show you how to install and configure dwm in Enterprise Linux 8. Dynamic window manager is a program used for dynamic window management – for opening […]
Dwm (dynamic window manager) is, as the name suggests, a dynamic window manager. For many years he has been the choice of Linux geeks. In this article we will show you how to install and configure dwm in Enterprise Linux 8.
Dynamic window manager is a program used for dynamic window management – for opening and organizing them. It is created by the community of free software developers suckless.org. The foundations of suckless.org philosophy include simplicity, transparency, economy, usability, minimalism and expansion. That’s what twowm is like.
The most important features of two:
- windows can be presented in one of 3 layouts:
- tiled (master and stack layout)
- floated
- monocle
- each window can be assigned multiple tags (workspace equivalent)
- the monitor can display simultaneously windows assigned to several tags
- each monitor has a separate set of tags. You cannot display the same window on multiple monitors simultaneously
- each monitor has a minimum bar status. It contains tags, layout symbol, active window title and text read from root window name property
- the project assumption is a source code not exceeding 2000 SLOC
- dwm is a single binary file
- configuration is done by editing the source code
config.h
. Requires compilation and restart of dwm. The compilation is very fast.
When is it worth using two?
This tool is especially worth recommending when:
- we have limited memory or CPU resources. dwm does not perform any „unnecessary ” tasks other than window management. So it has economical computer resources
- we want to know the CLI tools for operating system management. There are no easily available GUI tools in graphical environments, i.e. GNOME or KDE somehow forces you to learn about CLI tools and get used to the terminal.
When delving into dwm or other programs from suckless.org, some expectations set by years of using MS Windows, KDE, GNOME or another complex graphical environment should be abandoned. People expecting that with a few mouse clicks you can run a web browser, spreadsheet or change the system settings will probably be disappointed. On the other hand, a minimalist and predictable dwm can be a great tool for full control of windows using the keyboard. Undeniably, the mouse is also very useful :)
Installation
ATTENTION
Installing software from sources is potentially dangerous. It is worth testing it in a test environment or analyzing the code yourself.
This article applies to dwm on EuroLinux 8 distribution after minimal installation. commands dnf
are specific to Enterprise Linux systems (Rocky Linux, Oracle, Linux, RHEL, AlmaLinux …). If you use another distribution, the installation of the required packages may vary slightly. Then use the appropriate package manager (e.g. apt
or pacman
). Package names may also vary depending on the distribution. Most of the information about installing and configuring dwm will be useful regardless of the distribution selected.
Source Code
If you do not have a guitar installed, do so:
sudo dnf install git
Then we can download the dwm source code using the guitar:
git clone git://git.suckless.org/dwm
We enter the source code directory, which we can view:
cd dwm
cat README *.h *.c *.mk Makefile
Compilation
We install packages necessary for compiling dwm:
sudo dnf install make gcc libX11-devel libXft-devel libXinerama-devel
To check if the compilation is successful, use the command:
make all clean


Minimal installation of X server
We install packages necessary to run dwm:
sudo dnf install xorg-x11-server-Xorg xorg-x11-xinit
We may need additional drivers, e.g. xorg-x11-drv-intel
or xorg-x11-drivers
. If so – they must be installed.
Installation
To install dwm globally, use:
sudo make clean install
In this way we will install two wm w /usr/local/bin/
and we will add man page
to /usr/local/share/man
. We can change this in a file config.mk
in section # paths
. For example, set a variable PREFIX=$HOME/.local
. It is now possible to install as a regular user (without sudo
).
make clean install
Catalog $HOME/.local/bin
by default it should be added to the environment variable $PATH
. We can check it out by calling echo $PATH
. If it is not – it should be added.
Then we create the file .xinitrc
in the home directory. Attention. The following command will overwrite the file .xinitrc
if this already exists.
echo dwm > $HOME/.xinitrc
First run of dwm
The following command will run the X server, which will run dwm:
startx
In its current state, it is most likely only possible to move the cursor on the screen or switch tags. We can do this using keyboard shortcuts:
• [Atl]+[4]
• [Alt]+[7]
• [Ctrl]+[Alt]+[2]
• [Ctrl]+[Alt]+[5]
• [Ctrl]+[Alt]+[2]
• [Alt]+[0]
• [Ctrl]+[Alt]+[3]
• [Alt]+[1]
.
Tags can also be switched with the mouse.
[Alt]+[Shift]+[q]
closes the dwm and returns to tty
.
Basic keyboard shortcuts
Keyboard shortcuts can always be viewed in manual man dwm
. Mod1
by default means Alt
. Below we will show how to change Alt
on Super
or Windows key
. The code defining keyboard shortcuts is in the file config.h
.
Basics
[Shift]+[Mod]+[Enter] - launch terminal
[Mod]+[b] - show/hide bar
[Mod]+[p] - dmenu for running programs like the x-www-browser
[Mod]+[Enter] - push acive window from stack to master, or pulls last used window from stack onto master.
[Mod] + [j / k] - focus on next/previous window in current tag
[Mod] + [h / l] - increases / decreases master size
Navigation
[Mod]+[2] - moves your focus to tag 2
[Shift]+[Mod]+[2] - move active window to the 2 tag
[Mod] + [i / d] - increases / decreases number of windows on master
[Mod] + [, / .] - move focus between screens (multi monitor setup)
[Shift]+[Mod]+[, / .] - move active window to different screen
[Mod]+[0] - view all windows on screen
[Shift]+[Mod]+[0] - make focused window appear on all tags
[Shift]+[Mod]+[c] - kill active window
[Shift]+[Mod]+[q] - quit dwm cleanly
Layout
[Mod]+[t] - tiled mode. []=
[Mod]+[f] - floating mode. ><>
[Mod]+[m] - monocle mode. [M] single window fullscreen
Floating
[Mod]+[R M B] - to resize the floating window
[Mod]+[L M B] - to move the floating window around
[Mod]+[Space] - toggles to the previous layout mode
[Mod]+[Shift]+[Space] - to make an individual window float
[Mod]+[M M B] - to make an individual window un-float
Basic configuration
The dwm configuration is about editing the file config.h
and recompile make clean install
(with sudo
or without).
Mod: change alt to super / windows
Change the MODKEY variable:
#define MODKEY Mod4Mask
Terminal
The default terminal of dwm is st. It can be installed in a manner analogous to dwm. Of course, nothing prevents you from integrating another terminal, e.g. terminator emulator.
To install the terminator, use:
sudo dnf install terminator
Let’s integrate the terminator with two. Let’s replace the line in the file config.h
in section /* commands */
:
static const char *termcmd[] = { "terminator", NULL };
Then compile and install dwm again make clean install
. After restarting (startx
) we can open several terminal windows (Mod+Shift+Enter
). It is worth experimenting with navigating between windows.
Application Launcher
The default application launcher is dmenu. The dmenu configuration is defined in the file config.h
in lines:
static const char dmenufont[] = "monospace:size=10";
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
In our case, the dmenu program is not installed and is not in EuroLinux repositories. That’s why the abbreviation Mod+p
does not call him. An alternative may be to call the application from the terminal. The dmenu installation is below.
Firefox opens by default in tag No. 9 (definition in config.h
).
Dmenu installation
The dmenu installation is similar to two in:
cd
git clone git://git.suckless.org/dmenu
cd dmenu
sudo make clean install
Mod+p
opens the dmenu.
Multi-monitor
To configure the multi-monitor, use an external tool, e.g. xrandr
. Here is an example of configuring three monitors.
Overview of available monitors:
xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
eDP-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 309mm x 173mm
1920x1080 60.00*+ 59.97 59.96 59.93 48.00
1680x1050 59.95 59.88
1400x1050 59.98
1600x900 59.99 59.94 59.95 59.82
1280x1024 60.02
1400x900 59.96 59.88
1280x960 60.00
1440x810 60.00 59.97
1368x768 59.88 59.85
1280x800 59.99 59.97 59.81 59.91
1280x720 60.00 59.99 59.86 59.74
1024x768 60.04 60.00
960x720 60.00
928x696 60.05
896x672 60.01
1024x576 59.95 59.96 59.90 59.82
960x600 59.93 60.00
960x540 59.96 59.99 59.63 59.82
800x600 60.00 60.32 56.25
840x525 60.01 59.88
864x486 59.92 59.57
700x525 59.98
800x450 59.95 59.82
640x512 60.02
700x450 59.96 59.88
640x480 60.00 59.94
720x405 59.51 58.99
684x384 59.88 59.85
640x400 59.88 59.98
640x360 59.86 59.83 59.84 59.32
512x384 60.00
512x288 60.00 59.92
480x270 59.63 59.82
400x300 60.32 56.34
432x243 59.92 59.57
320x240 60.05
360x202 59.51 59.13
320x180 59.84 59.32
DP-1 connected (normal left inverted right x axis y axis)
1920x1080 60.00 + 59.94
1680x1050 59.95
1280x1024 60.02
1440x900 59.89
1280x960 60.00
1280x720 60.00 59.94
1024x768 60.00
800x600 60.32
640x480 60.00 59.94
720x400 70.08
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
HDMI-2 connected (normal left inverted right x axis y axis)
1920x1080 60.00 +
1600x900 60.00
1280x1024 75.02 60.02
1152x864 75.00
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
720x400 70.08
As you can see, three monitors are connected to eDP-1, DP-1 and HDMI-2 ports. The preferred layout is as follows:
We can set it with the command:
xrandr --output DP-1 --auto --rotate left --left-of eDP-1 --output HDMI-2 --auto --left-of DP-1
Status tekst i .xinitrc
The text in the upper right corner can be replaced by any other text using the command:
setxkbmap pl # allowing local language
xsetroot -name "Jesteś świetny!!"
Variable -name
can accept any text. Let’s try a sample script showing the date and time.
#!/bin/bash
while true
do
xsetroot -name "$(date)"
sleep 1
done
Save this script in a file using a text editor, e.g. vi ~/.local/bin/status.sh
and give him the right to exercise chmod 755 ~./local/bin/status.sh
. Then add a line status.sh &
to file ~/.xinitrc
before dwm
.
cat ~/.xinitrc
status.sh &
dwm
It is worth paying attention to the sign &
. startx
executes commands from xinitrc
sequentially. status.sh
contains an infinite loop. Without & dwm
he would never have done it. If we want to set the default keyboard layout to Polish, we can add at the beginning of the file .xinitrc
command setxkbmap pl
.
cat ~/.xinitrc
setxkbmap pl
status.sh &
dwm
We restart dwm: [Mod]+[Shift]+[q]
and startx
.
Script status.sh
can be extended with any commands that give a text output. Examples:
• cat /sys/class/power_supply/BAT0/capacity
– battery charge status
• cat /sys/class/power_supply/BAT0/status
– charging status.
Summary
We believe that after following the instructions in this article, everyone will be able to build a useful window manager. The possibilities of extending functionality seem limitless. The patch collection is available on suckless website. We encourage you to learn the values promoted by the suckless.org community. Some believe that this should be how software should be developed. Others have different priorities :)