wiki: Document window rules
Browse files at this commitd4b271fead08e6932ad3df281564066ae997c9e6Parent: de6685f7 changed files +281 -0
- .gitattributes +1 -0
- wiki/Configuration:-Window-Rules.md +267 -0
- wiki/_Sidebar.md +1 -0
- wiki/img/block-out-from-screencast.png +3 -0
- wiki/img/opacity-popup.png +3 -0
- wiki/img/simple-egl-border-with-background.png +3 -0
- wiki/img/simple-egl-border-without-background.png +3 -0
.gitattributesadded+1 -0
| @@ -0,0 +1 @@ | |||
| 1 | +*.png filter=lfs diff=lfs merge=lfs -text | ||
wiki/Configuration:-Window-Rules.mdadded+267 -0
| @@ -0,0 +1,267 @@ | |||
| 1 | +### Overview | ||
| 2 | + | ||
| 3 | +Window rules let you adjust behavior for individual windows. | ||
| 4 | +They have `match` and `exclude` directives that control which windows the rule should apply to, and a number of properties that you can set. | ||
| 5 | + | ||
| 6 | +Window rules are processed in order of appearance in the config file. | ||
| 7 | +This means that you can put more generic rules first, then override them for specific windows later. | ||
| 8 | +For example: | ||
| 9 | + | ||
| 10 | +``` | ||
| 11 | +// Set open-maximized to true for all windows. | ||
| 12 | +window-rule { | ||
| 13 | + open-maximized true | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +// Then, for Alacritty, set open-maximized back to false. | ||
| 17 | +window-rule { | ||
| 18 | + match app-id="Alacritty" | ||
| 19 | + open-maximized false | ||
| 20 | +} | ||
| 21 | +``` | ||
| 22 | + | ||
| 23 | +Here are all matchers and properties that a window rule could have: | ||
| 24 | + | ||
| 25 | +``` | ||
| 26 | +window-rule { | ||
| 27 | + match title="Firefox" | ||
| 28 | + match app-id="Alacritty" | ||
| 29 | + match is-active=true | ||
| 30 | + match is-focused=false | ||
| 31 | + | ||
| 32 | + // Properties that apply once upon window opening. | ||
| 33 | + default-column-width { proportion 0.75; } | ||
| 34 | + open-on-output "eDP-1" | ||
| 35 | + open-maximized true | ||
| 36 | + open-fullscreen true | ||
| 37 | + | ||
| 38 | + // Properties that apply continuously. | ||
| 39 | + draw-border-with-background false | ||
| 40 | + opacity 0.5 | ||
| 41 | + block-out-from "screencast" | ||
| 42 | + // block-out-from "screen-capture" | ||
| 43 | + | ||
| 44 | + min-width 100 | ||
| 45 | + max-width 200 | ||
| 46 | + min-height 300 | ||
| 47 | + max-height 300 | ||
| 48 | +} | ||
| 49 | +``` | ||
| 50 | + | ||
| 51 | +### Window Matching | ||
| 52 | + | ||
| 53 | +Each window rule can have several `match` and `exclude` directives. | ||
| 54 | +In order for the rule to apply, a window needs to match *any* of the `match` directives, and *none* of the `exclude` directives. | ||
| 55 | + | ||
| 56 | +``` | ||
| 57 | +window-rule { | ||
| 58 | + // Match all Telegram windows... | ||
| 59 | + match app-id=r#"^org\.telegram\.desktop$"# | ||
| 60 | + | ||
| 61 | + // ...except the media viewer window. | ||
| 62 | + exclude title="^Media viewer$" | ||
| 63 | + | ||
| 64 | + // Properties to apply. | ||
| 65 | + open-on-output "HDMI-A-1" | ||
| 66 | +} | ||
| 67 | +``` | ||
| 68 | + | ||
| 69 | +Match and exclude directives have the same syntax. | ||
| 70 | +Here is what you can match on. | ||
| 71 | + | ||
| 72 | +#### `title` and `app-id | ||
| 73 | + | ||
| 74 | +These are regular expressions that should match anywhere in the window title and app ID respectively. | ||
| 75 | + | ||
| 76 | +``` | ||
| 77 | +window-rule { | ||
| 78 | + match title="Mozilla Firefox" | ||
| 79 | + match app-id="Alacritty" | ||
| 80 | +} | ||
| 81 | +``` | ||
| 82 | + | ||
| 83 | +Raw KDL strings can be helpful for writing out regular expressions: | ||
| 84 | + | ||
| 85 | +``` | ||
| 86 | +window-rule { | ||
| 87 | + exclude app-id=r#"^org\.keepassxc\.KeePassXC$"# | ||
| 88 | +} | ||
| 89 | +``` | ||
| 90 | + | ||
| 91 | +#### `is-active` | ||
| 92 | + | ||
| 93 | +Can be `true` or `false`. | ||
| 94 | +Matches active windows (same windows that have the active border / focus ring color). | ||
| 95 | + | ||
| 96 | +Every workspace on the focused monitor will have one active window. | ||
| 97 | +This means that you will usually have multiple active windows (one per workspace), and when you switch between workspaces, you can see two active windows at once. | ||
| 98 | + | ||
| 99 | +``` | ||
| 100 | +window-rule { | ||
| 101 | + match is-active=true | ||
| 102 | +} | ||
| 103 | +``` | ||
| 104 | + | ||
| 105 | +#### `is-focused` | ||
| 106 | + | ||
| 107 | +Can be `true` or `false`. | ||
| 108 | +Matches the window that has the keyboard focus. | ||
| 109 | + | ||
| 110 | +Contrary to `is-active`, there can only be a single focused window. | ||
| 111 | +Also, when opening a layer-shell application launcher or pop-up menu, the keyboard focus goes to layer-shell. | ||
| 112 | +While layer-shell has the keyboard focus, windows will not match this rule. | ||
| 113 | + | ||
| 114 | +### Window Opening Properties | ||
| 115 | + | ||
| 116 | +These properties apply once, when a window first opens. | ||
| 117 | + | ||
| 118 | +To be precise, they apply at the point when niri sends the initial configure request to the window. | ||
| 119 | + | ||
| 120 | +#### `default-column-width` | ||
| 121 | + | ||
| 122 | +Set the default width for the new window. | ||
| 123 | + | ||
| 124 | +``` | ||
| 125 | +window-rule { | ||
| 126 | + default-column-width { proportion 0.75; } | ||
| 127 | +} | ||
| 128 | +``` | ||
| 129 | + | ||
| 130 | +#### `open-on-output` | ||
| 131 | + | ||
| 132 | +Make the window open on a specific output. | ||
| 133 | + | ||
| 134 | +If such an output does not exist, the window will open on the currently focused output as usual. | ||
| 135 | + | ||
| 136 | +If the window opens on an output that is not currently focused, the window will not be automatically focused. | ||
| 137 | + | ||
| 138 | +``` | ||
| 139 | +window-rule { | ||
| 140 | + open-on-output "eDP-1" | ||
| 141 | +} | ||
| 142 | +``` | ||
| 143 | + | ||
| 144 | +#### `open-maximized` | ||
| 145 | + | ||
| 146 | +Make the window open as a maximized column. | ||
| 147 | + | ||
| 148 | +``` | ||
| 149 | +window-rule { | ||
| 150 | + open-maximized true | ||
| 151 | +} | ||
| 152 | +``` | ||
| 153 | + | ||
| 154 | +#### `open-fullscreen` | ||
| 155 | + | ||
| 156 | +Make the window open fullscreen. | ||
| 157 | + | ||
| 158 | +``` | ||
| 159 | +window-rule { | ||
| 160 | + open-fullscreen true | ||
| 161 | +} | ||
| 162 | +``` | ||
| 163 | + | ||
| 164 | +You can also set this to `false` to *prevent* a window from opening fullscreen. | ||
| 165 | + | ||
| 166 | +``` | ||
| 167 | +window-rule { | ||
| 168 | + open-fullscreen false | ||
| 169 | +} | ||
| 170 | +``` | ||
| 171 | + | ||
| 172 | +### Dynamic Properties | ||
| 173 | + | ||
| 174 | +These properties apply continuously to open windows. | ||
| 175 | + | ||
| 176 | +#### `block-out-from` | ||
| 177 | + | ||
| 178 | +You can block out windows from xdg-desktop-portal screencasts. | ||
| 179 | +They will be replaced with solid black rectangles. | ||
| 180 | + | ||
| 181 | +This can be useful for password managers or messenger windows, etc. | ||
| 182 | + | ||
| 183 | + | ||
| 184 | + | ||
| 185 | +To preview and set up this rule, check the `preview-render` option in the debug section of the config. | ||
| 186 | + | ||
| 187 | +> [!CAUTION] | ||
| 188 | +> The window is **not** blocked out from third-party screenshot tools. | ||
| 189 | +> If you open some screenshot tool with preview while screencasting, blocked out windows **will be visible** on the screencast. | ||
| 190 | + | ||
| 191 | +The built-in screenshot UI is not affected though, you can use it safely, and windows will remain blocked out even when screencasting it. | ||
| 192 | + | ||
| 193 | +``` | ||
| 194 | +window-rule { | ||
| 195 | + block-out-from "screencast" | ||
| 196 | +} | ||
| 197 | +``` | ||
| 198 | + | ||
| 199 | +Alternatively, you can block out the window out of *all* screen captures, including third-party screenshot tools. | ||
| 200 | +This way you avoid accidentally showing the window on a screencast when opening a third-party screenshot preview. | ||
| 201 | + | ||
| 202 | +This setting will still let you use the interactive built-in screenshot UI, but it will block out the window from the fully automatic screenshot actions, such as `screenshot-screen` and `screenshot-window`. | ||
| 203 | +The reasoning is that with an interactive selection, you can make sure that you avoid screenshotting sensitive content. | ||
| 204 | + | ||
| 205 | +``` | ||
| 206 | +window-rule { | ||
| 207 | + block-out-from "screen-capture" | ||
| 208 | +} | ||
| 209 | +``` | ||
| 210 | + | ||
| 211 | +#### `opacity` | ||
| 212 | + | ||
| 213 | +Sets the opacity of the window. | ||
| 214 | +`0.0` is fully transparent, `1.0` is fully opaque. | ||
| 215 | +This is applied on top of the window's own opacity, so semitransparent windows will become even more transparent. | ||
| 216 | + | ||
| 217 | +Opacity is applied to every surface of the window individually, so subsurfaces and pop-up menus will show window content behind them. | ||
| 218 | + | ||
| 219 | + | ||
| 220 | + | ||
| 221 | +Also, focus ring and border with background will show through semitransparent windows (see `prefer-no-csd` and the `draw-border-with-background` window rule below). | ||
| 222 | + | ||
| 223 | +``` | ||
| 224 | +window-rule { | ||
| 225 | + opacity 0.9 | ||
| 226 | +} | ||
| 227 | +``` | ||
| 228 | + | ||
| 229 | +#### `draw-border-with-background` | ||
| 230 | + | ||
| 231 | +Override whether the border and the focus ring draw with a background. | ||
| 232 | + | ||
| 233 | +Set this to `true` to draw them as solid colored rectangles even for windows which agreed to omit their client-side decorations. | ||
| 234 | +Set this to `false` to draw them as borders around the window even for windows which use client-side decorations. | ||
| 235 | + | ||
| 236 | +This property can be useful for rectangular windows that do not support the xdg-decoration protocol. | ||
| 237 | + | ||
| 238 | +| With Background | Without Background | | ||
| 239 | +| --------------- | ------------------ | | ||
| 240 | +|  |  | | ||
| 241 | + | ||
| 242 | +``` | ||
| 243 | +window-rule { | ||
| 244 | + draw-border-with-background false | ||
| 245 | +} | ||
| 246 | +``` | ||
| 247 | + | ||
| 248 | +#### Size Overrides | ||
| 249 | + | ||
| 250 | +You can amend the window's minimum and maximum size in logical pixels. | ||
| 251 | + | ||
| 252 | +Keep in mind that the window itself always has a final say in its size. | ||
| 253 | +These values instruct niri to never ask the window to be smaller than the minimum you set, or to be bigger than the maximum you set. | ||
| 254 | + | ||
| 255 | +> [!NOTE] | ||
| 256 | +> `max-height` will only apply to automatically-sized windows if it is equal to `min-height`. | ||
| 257 | +> Either set it equal to `min-height`, or change the window height manually after opening it with `set-window-height`. | ||
| 258 | +> | ||
| 259 | +> This is a limitation of niri's window height distribution algorithm. | ||
| 260 | + | ||
| 261 | +``` | ||
| 262 | +window-rule { | ||
| 263 | + min-width 100 | ||
| 264 | + max-width 200 | ||
| 265 | + min-height 300 | ||
| 266 | + max-height 300 | ||
| 267 | +} | ||
wiki/_Sidebar.mdmodified+1 -0
| @@ -8,6 +8,7 @@ | |||
| 8 | ## Configuration | 8 | ## Configuration |
| 9 | * [Overview](https://github.com/YaLTeR/niri/wiki/Configuration:-Overview) | 9 | * [Overview](https://github.com/YaLTeR/niri/wiki/Configuration:-Overview) |
| 10 | * [Input](https://github.com/YaLTeR/niri/wiki/Configuration:-Input) | 10 | * [Input](https://github.com/YaLTeR/niri/wiki/Configuration:-Input) |
| 11 | +* [Window Rules](https://github.com/YaLTeR/niri/wiki/Configuration:-Window-Rules) | ||
| 11 | 12 | ||
| 12 | ## Development | 13 | ## Development |
| 13 | * [Design Principles](https://github.com/YaLTeR/niri/wiki/Design-Principles) | 14 | * [Design Principles](https://github.com/YaLTeR/niri/wiki/Design-Principles) |
wiki/img/block-out-from-screencast.pngadded+3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | +version https://git-lfs.github.com/spec/v1 | ||
| 2 | +oid sha256:c1e4e6809fff666c324a6e19bc888fe8cbafb5d159cea36703e7020510c53a52 | ||
| 3 | +size 669362 | ||
wiki/img/opacity-popup.pngadded+3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | +version https://git-lfs.github.com/spec/v1 | ||
| 2 | +oid sha256:d1e456ff87be58fcda542473dcbb5c5d63bef4f95b7e71bc1790de5e012f640d | ||
| 3 | +size 15837 | ||
wiki/img/simple-egl-border-with-background.pngadded+3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | +version https://git-lfs.github.com/spec/v1 | ||
| 2 | +oid sha256:db034a4d42c382df3ff8aab1178f1978e1d7a20ff2318145c28a7f87e710eeaa | ||
| 3 | +size 4999 | ||
wiki/img/simple-egl-border-without-background.pngadded+3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | +version https://git-lfs.github.com/spec/v1 | ||
| 2 | +oid sha256:2623c4f1b11d82b0588893c87908b14337f42bd2ee328d17d1db74acf9c7bd17 | ||
| 3 | +size 15729 | ||