forge
Explore
Log in

Don't you dare go Hollow

wiki: Document config includes

Browse files at this commit

39339032cee3453faa54c361a38db6d83756f750Ivan MolodetskikhParent: a250fcf
docs/mkdocs.yamlmodified+1 -0
@@ -103,6 +103,7 @@ nav:
103 - Animations: Configuration:-Animations.md103 - Animations: Configuration:-Animations.md
104 - Gestures: Configuration:-Gestures.md104 - Gestures: Configuration:-Gestures.md
105 - Debug Options: Configuration:-Debug-Options.md105 - Debug Options: Configuration:-Debug-Options.md
106+ - Include: Configuration:-Include.md
106 - Development:107 - Development:
107 - Design Principles: Development:-Design-Principles.md108 - Design Principles: Development:-Design-Principles.md
108 - Developing niri: Development:-Developing-niri.md109 - Developing niri: Development:-Developing-niri.md
docs/wiki/Configuration:-Include.mdadded+243 -0
@@ -0,0 +1,243 @@
1+<sup>Since: next release</sup>
2+
3+You can include other files at the top level of the config.
4+
5+```kdl,must-fail
6+// Some settings...
7+
8+include "colors.kdl"
9+
10+// Some more settings...
11+```
12+
13+Included files have the same structure as the main config file.
14+Settings from included files will be merged with the settings from the main config file.
15+
16+Included config files can in turn include more files.
17+All included files are watched for changes, and the config live-reloads when any of them change.
18+
19+Includes work only at the top level of the config:
20+
21+```kdl,must-fail
22+// All good: include at the top level.
23+include "something.kdl"
24+
25+layout {
26+ // NOT allowed: include inside some other section.
27+ include "other.kdl"
28+}
29+```
30+
31+### Positionality
32+
33+Includes are *positional*.
34+They will override options set *prior* to them.
35+Window rules from included files will be inserted at the position of the `include` line.
36+For example:
37+
38+```kdl
39+// colors.kdl
40+layout {
41+ border {
42+ active-color "green"
43+ }
44+}
45+
46+overview {
47+ backdrop-color "green"
48+}
49+```
50+
51+```kdl,must-fail
52+// config.kdl
53+layout {
54+ border {
55+ active-color "red"
56+ }
57+}
58+
59+// This overrides the border color and the backdrop color to green.
60+include "colors.kdl"
61+
62+// This sets the overview backdrop color to red again.
63+overview {
64+ backdrop-color "red"
65+}
66+```
67+
68+The end result:
69+
70+- the border color is green (from `colors.kdl`),
71+- the overview backdrop color is red (it was set *after* `colors.kdl`).
72+
73+Another example:
74+
75+```kdl
76+// rules.kdl
77+window-rule {
78+ match app-id="Alacritty"
79+ open-maximized false
80+}
81+```
82+
83+```kdl,must-fail
84+// config.kdl
85+window-rule {
86+ open-maximized true
87+}
88+
89+// Window rules get inserted at this position.
90+include "rules.kdl"
91+
92+window-rule {
93+ match app-id="firefox$"
94+ open-maximized true
95+}
96+```
97+
98+This is equivalent to the following config file:
99+
100+```kdl
101+window-rule {
102+ open-maximized true
103+}
104+
105+// Included from rules.kdl.
106+window-rule {
107+ match app-id="Alacritty"
108+ open-maximized false
109+}
110+
111+window-rule {
112+ match app-id="firefox$"
113+ open-maximized true
114+}
115+```
116+
117+### Merging
118+
119+Most config sections are merged between includes, meaning that you can set only a few properties, and only those properties will change.
120+
121+```kdl
122+// colors.kdl
123+layout {
124+ // Does not affect gaps, border width, etc.
125+ // Only changes colors as written.
126+ focus-ring {
127+ active-color "blue"
128+ }
129+
130+ border {
131+ active-color "green"
132+ }
133+}
134+```
135+
136+```kdl,must-fail
137+// config.kdl
138+include "colors.kdl"
139+
140+layout {
141+ // Does not set border and focus-ring colors,
142+ // so colors from colors.kdl are used.
143+ gaps 8
144+
145+ border {
146+ width 8
147+ }
148+}
149+```
150+
151+#### Multipart sections
152+
153+Multipart sections like `window-rule`, `output`, or `workspace` are inserted as is without merging:
154+
155+```kdl
156+// laptop.kdl
157+output "eDP-1" {
158+ // ...
159+}
160+```
161+
162+```kdl,must-fail
163+// config.kdl
164+output "DP-2" {
165+ // ...
166+}
167+
168+include "laptop.kdl"
169+
170+// End result: both DP-2 and eDP-1 settings.
171+```
172+
173+#### Binds
174+
175+`binds` will override previously-defined conflicting keys:
176+
177+```kdl
178+// binds.kdl
179+binds {
180+ Mod+T { spawn "alacritty"; }
181+}
182+```
183+
184+```kdl,must-fail
185+// config.kdl
186+include "binds.kdl"
187+
188+binds {
189+ // Overrides Mod+T from binds.kdl.
190+ Mod+T { spawn "foot"; }
191+}
192+```
193+
194+#### Flags
195+
196+Most flags can be disabled with `false`:
197+
198+```kdl
199+// csd.kdl
200+
201+// Write "false" to explicitly disable.
202+prefer-no-csd false
203+```
204+
205+```kdl,must-fail
206+// config.kdl
207+
208+// Enable prefer-no-csd in the main config.
209+prefer-no-csd
210+
211+// Including csd.kdl will disable it again.
212+include "csd.kdl"
213+```
214+
215+#### Non-merging sections
216+
217+Some sections where the contents represent a combined structure are not merged.
218+Examples are `struts`, `preset-column-widths`, individual subsections in `animations`, pointing device sections in `input`.
219+
220+```kdl
221+// struts.kdl
222+layout {
223+ struts {
224+ left 64
225+ right 64
226+ }
227+}
228+```
229+
230+```kdl,must-fail
231+// config.kdl
232+layout {
233+ struts {
234+ top 64
235+ bottom 64
236+ }
237+}
238+
239+include "struts.kdl"
240+
241+// Struts are not merged.
242+// End result is only left and right struts.
243+```
docs/wiki/Configuration:-Introduction.mdmodified+1 -0
@@ -13,6 +13,7 @@ You can find documentation for various sections of the config on these wiki page
13 * [`animations {}`](./Configuration:-Animations.md)13 * [`animations {}`](./Configuration:-Animations.md)
14 * [`gestures {}`](./Configuration:-Gestures.md)14 * [`gestures {}`](./Configuration:-Gestures.md)
15 * [`debug {}`](./Configuration:-Debug-Options.md)15 * [`debug {}`](./Configuration:-Debug-Options.md)
16+* [`include "other.kdl"`](./Configuration:-Include.md)
16 17
17 ### Loading18 ### Loading
18 19
docs/wiki/_Sidebar.mdmodified+1 -0
@@ -33,6 +33,7 @@
33 * [Animations](./Configuration:-Animations.md)33 * [Animations](./Configuration:-Animations.md)
34 * [Gestures](./Configuration:-Gestures.md)34 * [Gestures](./Configuration:-Gestures.md)
35 * [Debug Options](./Configuration:-Debug-Options.md)35 * [Debug Options](./Configuration:-Debug-Options.md)
36+* [Include](./Configuration:-Include.md)
36 37
37 ## Development38 ## Development
38 * [Design Principles](./Development:-Design-Principles.md)39 * [Design Principles](./Development:-Design-Principles.md)