tonybtw.com

tonybtw.com

https://git.tonybtw.com/tonybtw.com.git git://git.tonybtw.com/tonybtw.com.git
12,311 bytes raw
1
#+TITLE: Niri, btw
2
#+AUTHOR: Tony, btw
3
#+date: 2025-11-05
4
#+HUGO_TITLE: Niri, btw!
5
#+HUGO_FRONT_MATTER_FORMAT: yaml
6
#+HUGO_CUSTOM_FRONT_MATTER: :image "/img/niri.png" :showTableOfContents true
7
#+HUGO_BASE_DIR: ~/repos/tonybtw.com
8
#+HUGO_SECTION: tutorial/niri
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 tutorial on how to setup Niri on Arch/NixOS/Gentoo. It is a wonderful wayland compositor masquerading as a window manager.
13
14
* Intro
15
16
What's up guys, my name is Tony, and today I'm gonna give you a quick and painless guide on installing and configuring Niri.
17
18
Niri is a "scrollable-tiling" wayland compositor that masquerades as a window manager. Here are some of the unique features of niri:
19
20
- Infinite horizontal Scroll
21
- Dynamic workspaces like in GNOME
22
- An Overview that zooms out workspaces and windows
23
- Built-in screenshot UI
24
- Per Monitor Workspaces (Shoutout to The Linux Cast because I know he loves that so much, and he loves xwayland-sattelite.)
25
- and much more.
26
27
A quote from the famous philosopher, Argocrates:
28
#+begin_quote
29
"Niri is the anti-window manager. I can just constantly spawn new windows, without having to worry about my window manager trying to "manage" my windows layout against a set output size. The only downside is that sometimes I forget I have 300 terminals opened all the way to the right."
30
#+end_quote
31
32
Let's jump into the installation.
33
34
* Install Dependencies for Niri
35
36
Alright so I'm on arch linux, btw, but this is going to work on NixOS, Gentoo, LFS, etc. I'll leave install instructions for all 3 of those distributions in this written guide in a link below the subscribe button.
37
38
For arch, here are the dependencies we need to install:
39
40
[[https://github.com/YaLTeR/niri][Github Repo]]
41
42
*** Arch Linux
43
#+begin_src sh
44
yay -S niri noctalia-shell
45
#+end_src
46
47
*** NixOS
48
For NixOS, you can add niri to your system configuration. Here's how to enable it:
49
50
#+begin_src nix
51
# In your configuration.nix or flake.nix
52
{
53
  programs.niri.enable = true;
54
55
  # Or add to your packages
56
  environment.systemPackages = with pkgs; [
57
    niri
58
    xwayland-satellite
59
  ];
60
}
61
#+end_src
62
63
For noctalia-shell on NixOS, you'll need to add it as a flake input (see the noctalia-shell section below for details).
64
65
*** Gentoo
66
For Gentoo, niri can be installed from GURU overlay:
67
68
#+begin_src sh
69
# Add the GURU overlay
70
sudo eselect repository enable guru
71
sudo emerge --sync guru
72
73
# Install niri
74
sudo emerge gui-wm/niri
75
#+end_src
76
77
We're going to use Noctalia Shell today as a bar, because I've used waybar for all of my previous wayland videos, I wanted to shake things up a bit. I'll do more of a deep dive on Quickshell in a separate video, but for today we're going to focus on Niri and how to customize and utilize it.
78
79
** Requirements for Niri
80
- glibc
81
- wayland
82
- wayland-protocols
83
- libinput
84
- libdrm
85
- libxkbcommon
86
- pixman
87
- git
88
- meson
89
- ninja
90
- libdisplay-info
91
- libliftoff
92
- hwdata
93
- seatd
94
- pcre2
95
96
** Extra stuff for my setup today:
97
- alacritty (terminal emulator)
98
- fuzzel (a dmenu clone for wayland)
99
- swaybg (for wallpapers)
100
- firefox (web browser)
101
- ttf-jetbrains-mono-nerd (font)
102
- xwayland-sattelite
103
104
So let's install these with pacman -Sy
105
#+begin_src sh
106
sudo pacman -Sy alacritty fuzzel swaybg firefox ttf-jetbrains-mono-nerd xwayland-sattelite
107
#+end_src
108
109
Alright, lets jump into niri by typing 'Niri'
110
111
* Load Niri
112
We're in niri now by and as you can see, this awesome help tool reminds you of the default kebinds. You can open this at any time with super shift slash.
113
114
So lets hit Super + T to open alacritty, by defualt.
115
116
Open up .config/niri/config.kdl, and lets change a few keybinds, and options.
117
118
First, lets add this option to the top of the file:
119
120
#+begin_src kdl
121
prefer-no-csd
122
#+end_src
123
124
This flag will make niri ask the applications to omit their client-side decorations, so we won't see this header on alacritty.
125
126
As always, let's fix the repeat rate and repeat delay, heres how to do it in niri:
127
128
#+begin_src kdl
129
input {
130
    keyboard {
131
        repeat-delay 200
132
        repeat-rate 35
133
    }
134
}
135
#+end_src
136
137
For touchpad settings, this is up to you, I prefer 'natural-scroll' off, but I'll leave all these options commented out in my config so you guys can adjust them as needed for your preferences.
138
139
And let's uncomment this so our focus follows our mouse:
140
141
#+begin_src kdl
142
focus-follows-mouse max-scroll-amount="0%"
143
#+end_src
144
145
Let's add some keybinds here:
146
#+begin_src kdl
147
    Mod+Return hotkey-overlay-title="Open a Terminal: alacritty" { spawn "alacritty"; }
148
    Mod+D hotkey-overlay-title="Run an Application: fuzzel" { spawn "fuzzel"; }
149
150
    Mod+Shift+1 { move-column-to-workspace 1; }
151
    Mod+Shift+2 { move-column-to-workspace 2; }
152
    Mod+Shift+3 { move-column-to-workspace 3; }
153
    Mod+Shift+4 { move-column-to-workspace 4; }
154
    Mod+Shift+5 { move-column-to-workspace 5; }
155
    Mod+Shift+6 { move-column-to-workspace 6; }
156
    Mod+Shift+7 { move-column-to-workspace 7; }
157
    Mod+Shift+8 { move-column-to-workspace 8; }
158
    Mod+Shift+9 { move-column-to-workspace 9; }
159
#+end_src
160
161
And lets change control to shift here as well for moving things to separate workspaces.
162
163
Now for the layout section, let's customize the gaps and focus ring:
164
165
#+begin_src kdl
166
layout {
167
    gaps 5
168
169
    focus-ring {
170
        width 1.5
171
        active-color "#7fc8ff"
172
        inactive-color "#505050"
173
    }
174
175
    border {
176
        off
177
    }
178
}
179
#+end_src
180
181
I also like to add some rounded corners to my windows with window rules:
182
183
#+begin_src kdl
184
window-rule {
185
    geometry-corner-radius 4
186
    clip-to-geometry true
187
}
188
#+end_src
189
190
This is about 90% complete, and thats because the defaults for niri are already really good imo. If you have multiple monitors, you need to edit the monitors block, and you can get information about your monitors with `niri msg outputs`
191
192
The file reloads automatically so we can test opening another terminal here, and boom there we go.
193
194
Alright this is nice, but we can do better. I personally could get by just like this, but lets add that noctalia shell.
195
196
* Noctalia Shell + Autostart
197
So for noctalia shell, we've already installed it with yay if you're on Arch. Here are the instructions for all distributions:
198
199
*** Arch Linux
200
#+begin_src sh
201
yay -S noctalia-shell
202
#+end_src
203
204
*** NixOS
205
For NixOS, noctalia-shell needs to be added as a flake input. Add this to your flake.nix:
206
207
#+begin_src nix
208
{
209
  inputs = {
210
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
211
    noctalia-shell.url = "github:Noctalia-Shell/noctalia-shell";
212
  };
213
214
  outputs = { self, nixpkgs, noctalia-shell }: {
215
    nixosConfigurations.yourHostname = nixpkgs.lib.nixosSystem {
216
      system = "x86_64-linux";
217
      modules = [
218
        ./configuration.nix
219
        ({ pkgs, ... }: {
220
          environment.systemPackages = [
221
            noctalia-shell.packages.x86_64-linux.default
222
          ];
223
        })
224
      ];
225
    };
226
  };
227
}
228
#+end_src
229
230
*** Gentoo
231
For Gentoo, noctalia-shell can be compiled from source:
232
233
#+begin_src sh
234
# Install quickshell first (dependency)
235
git clone https://github.com/outfoxxed/quickshell
236
cd quickshell
237
# Follow the build instructions in their README
238
239
# Then install noctalia-shell
240
git clone https://github.com/Noctalia-Shell/noctalia-shell
241
# Copy the config to ~/.config/quickshell/noctalia
242
#+end_src
243
244
Lets test to see if we have access to noctalia shell by typing:
245
246
`noctalia-shell`
247
`qs -c ~/.config/quickshell/noctalia`
248
249
So lets add this to our spawn-at-startup!
250
251
#+begin_src kdl
252
spawn-at-startup "noctalia-shell"
253
#+end_src
254
255
Noctalia-shell is highly customizable. Here are some of my settings that you can adjust in `~/.config/quickshell/noctalia/settings.json`:
256
257
#+begin_src json
258
{
259
    "bar": {
260
        "position": "top",
261
        "widgets": {
262
            "left": [
263
                { "id": "SystemMonitor", "showCpuTemp": true, "showCpuUsage": true, "showMemoryUsage": true },
264
                { "id": "ActiveWindow", "showIcon": true, "maxWidth": 145 },
265
                { "id": "MediaMini", "maxWidth": 145 }
266
            ],
267
            "center": [
268
                { "id": "Workspace", "labelMode": "name", "hideUnoccupied": false }
269
            ],
270
            "right": [
271
                { "id": "ScreenRecorder" },
272
                { "id": "Tray" },
273
                { "id": "Battery" },
274
                { "id": "Volume" },
275
                { "id": "Clock", "formatHorizontal": "HH:mm ddd, MMM dd" },
276
                { "id": "ControlCenter" }
277
            ]
278
        }
279
    },
280
    "colorSchemes": {
281
        "darkMode": true,
282
        "predefinedScheme": "Tokyo Night"
283
    },
284
    "ui": {
285
        "fontDefault": "JetBrainsMono Nerd Font Propo"
286
    }
287
}
288
#+end_src
289
290
The color scheme is in `~/.config/quickshell/noctalia/colors.json`, and I'm using a Tokyo Night theme.
291
292
293
* Wallpaper
294
Actually, if you're using noctalia-shell, wallpaper management is built right in! Noctalia has a wallpaper selector and can automatically rotate through your wallpapers.
295
296
In your `~/.config/quickshell/noctalia/settings.json`, configure the wallpaper settings:
297
298
#+begin_src json
299
{
300
    "wallpaper": {
301
        "directory": "/home/tony/walls",
302
        "enabled": true,
303
        "fillMode": "crop",
304
        "randomEnabled": true,
305
        "randomIntervalSec": 300,
306
        "transitionDuration": 1500
307
    }
308
}
309
#+end_src
310
311
This will automatically handle your wallpapers with smooth transitions. But if you want to use swaybg manually, you can still add it to your niri config:
312
313
#+begin_src kdl
314
spawn-sh-at-startup "swaybg -i ~/walls/wall1.png"
315
#+end_src
316
317
* Screenshot Script
318
Good news! Niri has a built-in screenshot UI that's actually really nice. You can trigger it with these keybinds (already in the default config):
319
320
#+begin_src kdl
321
Mod+S { screenshot; }
322
Ctrl+Print { screenshot-screen; }
323
Alt+Print { screenshot-window; }
324
#+end_src
325
326
Screenshots are saved to `~/Pictures/Screenshots/` by default, but you can change this in your config:
327
328
#+begin_src kdl
329
screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png"
330
#+end_src
331
332
If you prefer the traditional grim + slurp workflow, you can still use that:
333
334
#+begin_src sh
335
#!/bin/sh
336
grim -g "$(slurp)" - | wl-copy
337
#+end_src
338
339
And bind it in your config.kdl:
340
341
#+begin_src kdl
342
Mod+Shift+S { spawn "path-to-your-screenshot-script"; }
343
#+end_src
344
345
* Additional Customizations
346
So at this point, the world is really your oyster. Niri is incredibly flexible and customizable.
347
348
Here's a summary of my favorite keybinds:
349
350
| Keybind             | Action                              |
351
|---------------------+-------------------------------------|
352
| Super+Return        | Opens a terminal (alacritty)        |
353
| Super+D             | Runs fuzzel (application launcher)  |
354
| Super+Q             | Closes a window                     |
355
| Super+H/J/K/L       | Navigate between windows (vim-style)|
356
| Super+1-9           | Switch to workspace 1-9             |
357
| Super+Shift+1-9     | Move window to workspace 1-9        |
358
| Super+S             | Take a screenshot                   |
359
| Super+O             | Toggle Overview mode                |
360
| Super+F             | Maximize column                     |
361
| Super+Shift+F       | Fullscreen window                   |
362
| Super+R             | Cycle through preset column widths  |
363
| Super+C             | Center the current column           |
364
365
Some advanced features I really like:
366
367
Named workspaces - You can create custom named workspaces instead of just numbers:
368
369
#+begin_src kdl
370
workspace "a" { }
371
workspace "b" { }
372
workspace "c" { }
373
#+end_src
374
375
Window rules - Automatically manage specific applications:
376
377
#+begin_src kdl
378
window-rule {
379
    match title="Firefox"
380
    open-on-workspace "c"
381
    open-maximized true
382
}
383
#+end_src
384
385
The Overview feature (Super+O) is absolutely killer - it gives you a birds-eye view of all your workspaces and windows, similar to GNOME's Activities view.
386
387
* Final Thoughts
388
389
You're now ready to use Niri as a modern, fast, and extensible wayland compositor.
390
391
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
392
my youtube channel here: [[https://youtube.com/@tony-btw][YouTube]], or my website here: [[https://www.tonybtw.com][tony,btw]]
393
394
You can support me here: [[https://ko-fi.com/tonybtw][kofi]]