tonybtw.com

tonybtw.com

https://git.tonybtw.com/tonybtw.com.git git://git.tonybtw.com/tonybtw.com.git
13,461 bytes raw
1
#+title: How to Install and Customize DWL | Wayland Minimalism Endgame?
2
#+author: Tony, btw
3
#+date: 2025-09-05
4
#+HUGO_TITLE: How to Install and Customize DWL | Wayland Minimalism Endgame?
5
#+HUGO_FRONT_MATTER_FORMAT: yaml
6
#+HUGO_CUSTOM_FRONT_MATTER: :image "/img/dwl.png" :showTableOfContents true
7
#+HUGO_BASE_DIR: ~/repos/tonybtw.com
8
#+HUGO_SECTION: tutorial/dwl
9
#+EXPORT_FILE_NAME: index
10
#+OPTIONS: toc:nil broken-links:mark
11
#+HUGO_AUTO_SET_HEADLINE_SECTION: nil
12
#+DESCRIPTION: This is a quick and painless guide on how to install and customize DWL, which is a DWM port to wayland, more or less. Is it the end game of desktop minimalism?
13
14
* Table of Contents :toc:
15
- [[#intro][Intro]]
16
- [[#install-dependencies-for-dwl][Install Dependencies for DWL]]
17
  - [[#installation-commands-by-distribution][Installation Commands by Distribution]]
18
- [[#create-config-file][Create config file]]
19
  - [[#patch-this-shit-so-we-can-use-monitors][patch this shit so we can use monitors...]]
20
- [[#load-dwl][Load DWL]]
21
- [[#slstatus][Slstatus]]
22
- [[#wallpaper][Wallpaper]]
23
- [[#screenshot-script][Screenshot Script]]
24
- [[#remove-boxes-and-other-cleanup][Remove Boxes, and other cleanup.]]
25
- [[#keybinds][Keybinds]]
26
  - [[#application-launchers][Application Launchers]]
27
  - [[#screenshots][Screenshots]]
28
  - [[#window-management][Window Management]]
29
  - [[#layout-management][Layout Management]]
30
  - [[#status-bar-and-gaps][Status Bar and Gaps]]
31
  - [[#tag-management-workspaces][Tag Management (Workspaces)]]
32
  - [[#monitor-management][Monitor Management]]
33
  - [[#system-control][System Control]]
34
- [[#final-thoughts][Final Thoughts]]
35
36
* Intro
37
What's up guys, my name is Tony, and today I'm gonna give you a quick and painless guide on installing and configuring DWL.
38
39
DWL is basically a drop in replacement for DWM, but for the wayland display server. DWM is often reffered to as the most minimal window manager you can run on xorg, however, due to xorg's client/server model, many people view wayland as a better late-game solution for security and simplicity.
40
41
If you're someone who loves the simplicity, extensibility, and minimality of DWM, but prefers the wayland display protocol over xorg, this is the perfect solution for you. Let's jump right into it.
42
43
* Install Dependencies for DWL
44
45
Alright so I'm on arch linux, btw, but this is going to work on Nix, gentoo, etc. I'll leave install instructions for all 3 of those distributions in this written guide in a link below the subscribe button.
46
47
For arch, here are the dependencies we need to install:
48
49
1. wayland, wayland-protocols
50
2. wlroots_0_19 (dependency for dwl)
51
3. foot (terminal emulator)
52
4. base-devel (so we can compile dwl)
53
5. git (to clone the 2 repos for dwl, and slstatus)
54
6. wmenu (a dmenu clone for wayland)
55
7. wl-clipboard (wayland clipboard tool)
56
8. grim, slurp for screenshots
57
9. swaybg (for wallpapers)
58
10. firefox (web browser)
59
11. ttf-jetbrains-mono-nerd (font)
60
61
And let's clone dwl, and slstatus while we're at it.
62
#+begin_src sh
63
git clone https://codeberg.org/dwl/dwl.git
64
git clone https://git.suckless.org/slstatus
65
#+end_src
66
67
Alright, let's start modifying dwl before we launch it.
68
69
** Installation Commands by Distribution
70
71
*** Arch Linux
72
#+begin_src sh
73
sudo pacman -S wayland wayland-protocols wlroots foot base-devel git wmenu wl-clipboard grim slurp swaybg firefox ttf-jetbrains-mono-nerd
74
#+end_src
75
76
*** Gentoo Linux
77
#+begin_src sh
78
sudo emerge -av dev-libs/wayland dev-libs/wayland-protocols gui-libs/wlroots x11-terms/foot sys-devel/base-devel dev-vcs/git gui-apps/wmenu gui-apps/wl-clipboard media-gfx/grim gui-apps/slurp gui-apps/swaybg www-client/firefox media-fonts/jetbrains-mono
79
#+end_src
80
81
*** NixOS
82
Add to your =configuration.nix=:
83
#+begin_src nix
84
environment.systemPackages = with pkgs; [
85
  wayland
86
  wayland-protocols
87
  wlroots_0_19
88
  foot
89
  git
90
  wmenu
91
  wl-clipboard
92
  grim
93
  slurp
94
  swaybg
95
  firefox
96
  jetbrains-mono
97
];
98
#+end_src
99
100
101
* Create config file
102
Let's jump into our config.def.h file and setup some sane defaults before launching into dwl
103
104
As always, I'm going to change my mod key from alt to super. We can do that here on line 110:
105
106
#+begin_src c
107
#define MODKEY WLR_MODIFIER_LOGO
108
#+end_src
109
110
And on line 66, we have the repeat delay settings right here:
111
112
#+begin_src c
113
static const int repeat_rate = 35;
114
static const int repeat_delay = 200;
115
#+end_src
116
117
Also, lets change up some keybinds here to what I'm used to.
118
119
#+begin_src c
120
static const Key keys[] = {
121
    { MODKEY,                    XKB_KEY_d,          spawn,          {.v = wmenucmd} },
122
    { MODKEY,                    XKB_KEY_Return,     spawn,          {.v = termcmd} },
123
	{ MODKEY,                    XKB_KEY_q,          killclient,     {0} },
124
125
    // To avoid duplicate keybind, swap inc master to p
126
    { MODKEY,                    XKB_KEY_p,          incnmaster,     {.i = -1} },
127
};
128
#+end_src
129
130
I just like to change my terminal to super enter, my run prompt to super d, and my kill client with super q.
131
Alright I think that should be good enough for a first build. Let's save and quit this file, run sudo make clean install,
132
lets jump into a tty, and run dwl.
133
134
** TODO patch this shit so we can use monitors...
135
136
* Load DWL
137
We're in dwl now by and as you can see, it's literally just a blank screen with a mouse cursor. Super minimal.
138
139
Ok so because dwl is so minimal, we literally have to patch it to get a bar. So lets open firefox here, we have our wmenu binded to super d, and lets type firefox (we'll customize that later), and lets search dwl patches. Here the 2nd link, we see a community repo of patches. Link will be provided to this below the subscribe button.
140
141
Let's grab the bar patch, and apply it. Save it to dotfiles/dwl/patches
142
143
#+begin_src sh
144
cd ~/dotfiles/dwl
145
patch -i patches/bar.diff
146
#+end_src
147
148
And that looks good. Let's customize it a little bit here with the font.
149
Open up config.def.h and specify the font here:
150
#+begin_src c
151
static const char *fonts[]                 = {"JetBrainsMono Nerd Font Mono:style=Bold:size=16"};
152
#+end_src
153
154
While we're in here, let's make our wmenu prompt look a little better by changing our wmenu command to this:
155
156
#+begin_src c
157
static const char *wmenucmd[] = {
158
    "wmenu-run",
159
    "-f", "JetBrainsMono Nerd Font 16",
160
    "-l", "10",
161
    NULL
162
};
163
#+end_src
164
165
This just tells wmenu to run in a list of 10 items vertically, and changes the font to match our bar.
166
Alright, we're ready to bounce rebuild dwl, and relaunch it. Let's give it a go.
167
168
#+begin_src sh
169
rm config.h
170
sudo make clean install
171
#+end_src
172
173
Why we remove config.h is because config.def.h gets copied into config.h every time we rebuild, and if config.h is already there, we wont see our changes.
174
175
We can quit back to the tty with super shift q, and lets run dwl again by typing dwl. Awesome. There is our bar. And if we run wmenu with super d, we see it matches our new setup, and is actually readable. Sweet.
176
177
Let's jump into slstatus.
178
179
* Slstatus
180
So we've cloned slstatus, we really just need to build it. Let's cd into it for now and just use the defaults.
181
182
Let's run sudo make clean install. ok lets quit out of dwl here, and now instead of running dwl, lets run
183
184
#+begin_src sh
185
slstatus -s | dwl
186
#+end_src
187
188
That is going to tell slstatus to print to std out, and dwl will take it in.
189
Now we have a status bar on the right side. It's minimal for now but we'll fix it up later.
190
191
* Wallpaper
192
We need a wallpaper. With swaybg, we can set one, but we need to download one first. so lets open firefox, and head over to wallhaven.cc and pick one from there.
193
194
Let's grab this one, and put it in ~/walls/wall1.png
195
196
Now we can set that with
197
198
#+begin_src sh
199
swaybg -i ~/walls/wall1.png & disown
200
#+end_src
201
202
Let's add disown here so when we close this terminal, our wallpaper persists.
203
204
But we see the issue here, we want this wallpaper to be enabled whenever we launch dwl.
205
So we need to create a 1 line startup script. Let's just do it in our home directory for now, and if you want to use it in a display manager, i advise you move it over to .local/bin, and add that to your path. I'll leave instructions below on that, but for now lets just make a new file caled start_dwl.sh
206
207
#+begin_src sh
208
#!/bin/sh
209
slstatus -s | dwl -s "sh -c 'swaybg -i /home/tony/walls/wall1.png &'"
210
#+end_src
211
212
If you want to add this to your path, heres how to do it:
213
214
#+begin_src sh
215
mkdir ~/.local/bin
216
cp ~/start_dwl.sh ~/.local/bin/start_dwl
217
vim ~/.bashrc
218
export PATH="$HOME/.local/bin:$PATH"
219
source ~/.bashrc
220
#+end_src
221
222
This will create .local/bin, and add this to your existing script path.
223
224
We can launch dwl now with ./start_dwl.sh, and there we go. we see slstatus, we see our wallpaper. Awesome.
225
226
* Screenshot Script
227
We can add a screenshot script here with `grim`, `slurp`, and `wl-copy`
228
229
#!/bin/sh
230
timeout 10 slurp > /tmp/selection.txt 2>/dev/null
231
if [ $? -eq 0 ] && [ -s /tmp/selection.txt ]; then
232
    grim -g "$(cat /tmp/selection.txt)" - | wl-copy
233
else
234
    grim - | wl-copy
235
fi
236
rm -f /tmp/selection.txt
237
238
* Remove Boxes, and other cleanup.
239
So at this point, the world is really your oyster. For me, the first thin I see that is a problem, is that I don't like the visual indicator in my workspace numbers that shows what workspaces are occupied. In DWM, there is a patch to remove these boxes, but there isn't one in dwl, so I had to simply modify the source code. It's not that bad, I just jumped into dwl.c and found this section here where that box was drawn, and removed it.
240
241
While I was in this file, I did a lot more, because I wanted a specific setup where I could see differentiate my active, occupied, and empty workspaces just like I do in qtile, hyprland, dwm, etc. So I tinkered with this file a lot, and I'm not going to go through all those changes today. I've went ahead and just pulled down my full version of dwl here, and you can too if you'd like, a link is of course below the subscribe button.
242
243
Here you can see the behaviour: Teal numbers if occupied, purple underline if active, white number if empty.
244
Also, you'll notice I have tweaked my slstatus to accept colors, and underlines as well. That was a heavily lift, but I got it done.
245
246
* Keybinds
247
248
Here are all the configured keybinds for this dwl setup. MODKEY is typically the Super/Windows key.
249
250
** Application Launchers
251
| Key Combination | Action | Description |
252
|-----------------|--------|-------------|
253
| =MODKEY + d= | wmenu | Launch application menu |
254
| =MODKEY + Return= | foot | Launch terminal |
255
256
** Screenshots
257
| Key Combination | Action | Description |
258
|-----------------|--------|-------------|
259
| =Ctrl + F12= | snip script | Take screenshot (via script) |
260
| =MODKEY + s= | /home/tony/scripts/snip.sh | Take screenshot |
261
| =MODKEY + Shift + S= | Screenshot selection | Select area and copy to clipboard |
262
263
** Window Management
264
| Key Combination | Action | Description |
265
|-----------------|--------|-------------|
266
| =MODKEY + j= | Focus next | Focus next window in stack |
267
| =MODKEY + k= | Focus previous | Focus previous window in stack |
268
| =MODKEY + q= | Kill client | Close focused window |
269
| =MODKEY + Return= | Zoom | Move focused window to master |
270
| =MODKEY + Tab= | View last tag | Switch to previously viewed tag |
271
| =MODKEY + e= | Toggle fullscreen | Make window fullscreen |
272
| =MODKEY + Shift + Space= | Toggle floating | Make window floating/tiled |
273
274
** Layout Management
275
| Key Combination | Action | Description |
276
|-----------------|--------|-------------|
277
| =MODKEY + t= | Tiled layout | Set layout to tiled |
278
| =MODKEY + f= | Floating layout | Set layout to floating |
279
| =MODKEY + m= | Monocle layout | Set layout to monocle |
280
| =MODKEY + Space= | Toggle layout | Cycle through layouts |
281
| =MODKEY + h= | Decrease master | Decrease master area size |
282
| =MODKEY + l= | Increase master | Increase master area size |
283
| =MODKEY + i= | Increase masters | Increase number of masters |
284
| =MODKEY + p= | Decrease masters | Decrease number of masters |
285
286
** Status Bar and Gaps
287
| Key Combination | Action | Description |
288
|-----------------|--------|-------------|
289
| =MODKEY + b= | Toggle bar | Show/hide status bar |
290
| =MODKEY + a= | Toggle gaps | Enable/disable window gaps |
291
292
** Tag Management (Workspaces)
293
| Key Combination | Action | Description |
294
|-----------------|--------|-------------|
295
| =MODKEY + [1-9]= | View tag | Switch to tag 1-9 |
296
| =MODKEY + Shift + [1-9]= | Move to tag | Move window to tag 1-9 |
297
| =MODKEY + 0= | View all tags | Show windows from all tags |
298
| =MODKEY + Shift + )= | Tag all | Tag window with all tags |
299
300
** Monitor Management
301
| Key Combination | Action | Description |
302
|-----------------|--------|-------------|
303
| =MODKEY + ,= | Focus left monitor | Focus monitor to the left |
304
| =MODKEY + .= | Focus right monitor | Focus monitor to the right |
305
| =MODKEY + Shift + <= | Move to left monitor | Move window to left monitor |
306
| =MODKEY + Shift + >= | Move to right monitor | Move window to right monitor |
307
308
** System Control
309
| Key Combination | Action | Description |
310
|-----------------|--------|-------------|
311
| =MODKEY + Shift + Q= | Quit dwl | Exit window manager |
312
| =Ctrl + Alt + Backspace= | Terminate server | Force quit (emergency exit) |
313
314
* Final Thoughts
315
Thanks so much for checking out this tutorial. If you got value from it, and you want to find more tutorials like this, check out
316
my youtube channel here: [[https://youtube.com/@tony-btw][YouTube]], or my website here: [[https://www.tonybtw.com][tony,btw]]
317
318
You can support me here: [[https://ko-fi.com/tonybtw][kofi]]