forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiB9d8f4f8Ivan Molodetskikh1 month ago2997 commits

Configuration:-Introduction.md152 lines, 4.6 KiBHistoryRawDownload
1### Per-Section Documentation
2
3You can find documentation for various sections of the config on these wiki pages:
4
5* [`input {}`]./Configuration:-Input.md
6* [`output "eDP-1" {}`]./Configuration:-Outputs.md
7* [`binds {}`]./Configuration:-Key-Bindings.md
8* [`switch-events {}`]./Configuration:-Switch-Events.md
9* [`layout {}`]./Configuration:-Layout.md
10* [top-level options]./Configuration:-Miscellaneous.md
11* [`window-rule {}`]./Configuration:-Window-Rules.md
12* [`layer-rule {}`]./Configuration:-Layer-Rules.md
13* [`animations {}`]./Configuration:-Animations.md
14* [`gestures {}`]./Configuration:-Gestures.md
15* [`recent-windows {}`]./Configuration:-Recent-Windows.md
16* [`debug {}`]./Configuration:-Debug-Options.md
17* [`include "other.kdl"`]./Configuration:-Include.md
18
19### Loading
20
21Niri will load configuration from `$XDG_CONFIG_HOME/niri/config.kdl` or `~/.config/niri/config.kdl`, falling back to `/etc/niri/config.kdl`.
22If both of these files are missing, niri will create `$XDG_CONFIG_HOME/niri/config.kdl` with the contents of [the default configuration file]https://github.com/niri-wm/niri/blob/main/resources/default-config.kdl, which are embedded into the niri binary at build time.
23Please use the default configuration file as the starting point for your custom configuration.
24
25The configuration is live-reloaded.
26Simply edit and save the config file, and your changes will be applied.
27This includes key bindings, output settings like mode, window rules, and everything else.
28
29You can run `niri validate` to parse the config and see any errors.
30
31To use a different config file path, pass it in the `--config` or `-c` argument to `niri`.
32
33You can also set `$NIRI_CONFIG` to the path of the config file.
34`--config` always takes precedence.
35If `--config` or `$NIRI_CONFIG` doesn't point to a real file, the config will not be loaded.
36If `$NIRI_CONFIG` is set to an empty string, it is ignored and the default config location is used instead.
37
38### Syntax
39
40The config is written in [KDL].
41
42#### Comments
43
44Lines starting with `//` are comments; they are ignored.
45
46Also, you can put `/-` in front of a section to comment out the entire section:
47
48```kdl
49/-output "eDP-1" {
50 // Everything inside here is ignored.
51 // The display won't be turned off
52 // as the whole section is commented out.
53 off
54}
55```
56
57#### Flags
58
59Toggle options in niri are commonly represented as flags.
60Writing out the flag enables it, and omitting it or commenting it out disables it.
61For example:
62
63```kdl
64// "Focus follows mouse" is enabled.
65input {
66 focus-follows-mouse
67
68 // Other settings...
69}
70```
71
72```kdl
73// "Focus follows mouse" is disabled.
74input {
75 // focus-follows-mouse
76
77 // Other settings...
78}
79```
80
81#### Sections
82
83Most sections cannot be repeated. For example:
84
85```kdl
86// This is valid: every section appears once.
87input {
88 keyboard {
89 // ...
90 }
91
92 touchpad {
93 // ...
94 }
95}
96```
97
98```kdl,must-fail
99// This is NOT valid: input section appears twice.
100input {
101 keyboard {
102 // ...
103 }
104}
105
106input {
107 touchpad {
108 // ...
109 }
110}
111```
112
113Exceptions are, for example, sections that configure different devices by name:
114
115<!-- NOTE: this may break in the future -->
116```kdl
117output "eDP-1" {
118 // ...
119}
120
121// This is valid: this section configures a different output.
122output "HDMI-A-1" {
123 // ...
124}
125
126// This is NOT valid: "eDP-1" already appeared above.
127// It will either throw a config parsing error, or otherwise not work.
128output "eDP-1" {
129 // ...
130}
131```
132
133### Defaults
134
135Omitting most of the sections of the config file will leave you with the default values for that section.
136A notable exception is [`binds {}`]./Configuration:-Key-Bindings.md: they do not get filled with defaults, so make sure you do not erase this section.
137
138### Breaking Change Policy
139
140As a rule, niri updates should not break existing config files.
141(For example, the default config from niri v0.1.0 still parses fine on v25.02 as I'm writing this.)
142
143Exceptions can be made for parsing bugs.
144For example, niri used to accept multiple binds to the same key, but this was not intended and did not do anything (the first bind was always used).
145A patch release changed niri from silently accepting this to causing a parsing failure.
146This is not a blanket rule, I will consider the potential impact of every breaking change like this before deciding to carry on with it.
147
148Keep in mind that the breaking change policy applies only to niri releases.
149Commits between releases can and do occasionally break the config as new features are ironed out.
150However, I do try to limit these, since several people are running git builds.
151
152[KDL]: https://kdl.dev/