niri
Clone
https://git.tahinli.com/Tahinli/niri.git
0 watching·0 forks·Rust·GPL-3.0·12.1 MiB·9d8f4f8·Ivan Molodetskikh·1 month ago·2997 commits
| 1 | ### Per-Section Documentation |
| 2 | |
| 3 | You 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 | |
| 21 | Niri will load configuration from `$XDG_CONFIG_HOME/niri/config.kdl` or `~/.config/niri/config.kdl`, falling back to `/etc/niri/config.kdl`. |
| 22 | If 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. |
| 23 | Please use the default configuration file as the starting point for your custom configuration. |
| 24 | |
| 25 | The configuration is live-reloaded. |
| 26 | Simply edit and save the config file, and your changes will be applied. |
| 27 | This includes key bindings, output settings like mode, window rules, and everything else. |
| 28 | |
| 29 | You can run `niri validate` to parse the config and see any errors. |
| 30 | |
| 31 | To use a different config file path, pass it in the `--config` or `-c` argument to `niri`. |
| 32 | |
| 33 | You can also set `$NIRI_CONFIG` to the path of the config file. |
| 34 | `--config` always takes precedence. |
| 35 | If `--config` or `$NIRI_CONFIG` doesn't point to a real file, the config will not be loaded. |
| 36 | If `$NIRI_CONFIG` is set to an empty string, it is ignored and the default config location is used instead. |
| 37 | |
| 38 | ### Syntax |
| 39 | |
| 40 | The config is written in [KDL]. |
| 41 | |
| 42 | #### Comments |
| 43 | |
| 44 | Lines starting with `//` are comments; they are ignored. |
| 45 | |
| 46 | Also, 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 | |
| 59 | Toggle options in niri are commonly represented as flags. |
| 60 | Writing out the flag enables it, and omitting it or commenting it out disables it. |
| 61 | For example: |
| 62 | |
| 63 | ```kdl |
| 64 | // "Focus follows mouse" is enabled. |
| 65 | input { |
| 66 | focus-follows-mouse |
| 67 | |
| 68 | // Other settings... |
| 69 | } |
| 70 | ``` |
| 71 | |
| 72 | ```kdl |
| 73 | // "Focus follows mouse" is disabled. |
| 74 | input { |
| 75 | // focus-follows-mouse |
| 76 | |
| 77 | // Other settings... |
| 78 | } |
| 79 | ``` |
| 80 | |
| 81 | #### Sections |
| 82 | |
| 83 | Most sections cannot be repeated. For example: |
| 84 | |
| 85 | ```kdl |
| 86 | // This is valid: every section appears once. |
| 87 | input { |
| 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. |
| 100 | input { |
| 101 | keyboard { |
| 102 | // ... |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | input { |
| 107 | touchpad { |
| 108 | // ... |
| 109 | } |
| 110 | } |
| 111 | ``` |
| 112 | |
| 113 | Exceptions are, for example, sections that configure different devices by name: |
| 114 | |
| 115 | <!-- NOTE: this may break in the future --> |
| 116 | ```kdl |
| 117 | output "eDP-1" { |
| 118 | // ... |
| 119 | } |
| 120 | |
| 121 | // This is valid: this section configures a different output. |
| 122 | output "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. |
| 128 | output "eDP-1" { |
| 129 | // ... |
| 130 | } |
| 131 | ``` |
| 132 | |
| 133 | ### Defaults |
| 134 | |
| 135 | Omitting most of the sections of the config file will leave you with the default values for that section. |
| 136 | A 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 | |
| 140 | As 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 | |
| 143 | Exceptions can be made for parsing bugs. |
| 144 | For 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). |
| 145 | A patch release changed niri from silently accepting this to causing a parsing failure. |
| 146 | This 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 | |
| 148 | Keep in mind that the breaking change policy applies only to niri releases. |
| 149 | Commits between releases can and do occasionally break the config as new features are ironed out. |
| 150 | However, I do try to limit these, since several people are running git builds. |
| 151 | |
| 152 | [KDL]: https://kdl.dev/ |