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 | ### Overview |
| 2 | |
| 3 | <sup>Since: 26.04</sup> |
| 4 | |
| 5 | You can apply background effects to windows and layer-shell surfaces. |
| 6 | These include blur, xray, saturation, and noise. |
| 7 | They can be enabled in the `background-effect {}` section of [window](./Configuration:-Window-Rules.md#background-effect) or [layer](./Configuration:-Layer-Rules.md#background-effect) rules. |
| 8 | |
| 9 |  |
| 10 | |
| 11 | The window needs to be semitransparent for you to see the background effect (otherwise it's fully covered by the opaque window). |
| 12 | Focus ring and border can also cover the background effect, see [this FAQ entry](./FAQ.md#why-are-transparent-windows-tinted-why-is-the-borderfocus-ring-showing-up-through-semitransparent-windows) for how to change this. |
| 13 | |
| 14 | ### Blur |
| 15 | |
| 16 | Windows and layer surfaces can request their background to be blurred via the [`ext-background-effect` protocol](https://wayland.app/protocols/ext-background-effect-v1). |
| 17 | In this case, the application will usually offer some "background blur" setting that you'll need to enable in its configuration. |
| 18 | |
| 19 | You can also enable blur on the niri side with the `blur true` background effect window rule: |
| 20 | |
| 21 | ```kdl |
| 22 | // Enable blur behind the Alacritty terminal. |
| 23 | window-rule { |
| 24 | match app-id="^Alacritty$" |
| 25 | |
| 26 | background-effect { |
| 27 | blur true |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | // Enable blur behind the fuzzel launcher. |
| 32 | layer-rule { |
| 33 | match namespace="^launcher$" |
| 34 | |
| 35 | background-effect { |
| 36 | blur true |
| 37 | } |
| 38 | } |
| 39 | ``` |
| 40 | |
| 41 | Blur enabled via the window rule will follow the window corner radius set via [`geometry-corner-radius`](./Configuration:-Window-Rules.md#geometry-corner-radius). |
| 42 | On the other hand, blur enabled through `ext-background-effect` will exactly follow the shape requested by the window. |
| 43 | If the window or layer has clientside rounded corners or other complex shape, it should set a corresponding blur shape through `ext-background-effect`, then it will get correctly shaped background blur without any manual niri configuration. |
| 44 | |
| 45 | Windows can also blur their pop-up menus using `ext-background-effect`. |
| 46 | On the niri side, you can do it with a `popups` block inside [`window-rule`](./Configuration:-Window-Rules.md#popups) and [`layer-rule`](./Configuration:-Layer-Rules.md#popups). |
| 47 | See those wiki pages for examples and limitations. |
| 48 | |
| 49 | Global blur settings are configured in the [`blur {}` config section](./Configuration:-Miscellaneous.md#blur) and apply to all background blur. |
| 50 | |
| 51 | ### Xray |
| 52 | |
| 53 | Xray makes the window background "see through" to your wallpaper, ignoring any other windows below. |
| 54 | You can enable it with `xray true` background effect [window](./Configuration:-Window-Rules.md#background-effect) or [layer](./Configuration:-Layer-Rules.md#background-effect) rule. |
| 55 | |
| 56 | Xray is automatically enabled by default if any other background effect (like blur) is active. |
| 57 | This is because it's much more efficient: with xray active, niri only needs to blur the background once, and then can reuse this blurred version with no extra work (since the wallpaper changes very rarely). |
| 58 | |
| 59 | If you have an animated wallpaper, xray will still have to recompute blur every frame, but that happens once and shared among all windows, rather than recomputed separately for each window. |
| 60 | |
| 61 | #### Non-xray effects (experimental) |
| 62 | |
| 63 | You can disable xray with `xray false` background effect window rule. |
| 64 | This gives you the normal kind of blur where everything below a window is blurred. |
| 65 | Keep in mind that non-xray blur and other non-xray effects are more expensive as niri has to recompute them any time you move the window, or the contents underneath change. |
| 66 | |
| 67 | > [!WARNING] |
| 68 | > Non-xray effects are currently experimental because they have some known limitations. |
| 69 | > |
| 70 | > - They disappear during window open/close animations and while dragging a tiled window. |
| 71 | > Fixing this requires a refactor to the niri rendering code to defer offscreen rendering, and possibly other refactors. |
| 72 | |
| 73 | ### Implementation notes |
| 74 | |
| 75 | The `ext-background-effect` protocol supports any wl_surface. |
| 76 | We currently implement it only for toplevels, layer surfaces, and pop-ups, which should cover the vast majority of what's actually used by applications. |
| 77 | |
| 78 | For pop-ups, effects default to *non-xray* because pop-ups generally appear on top of windows. |
| 79 | |
| 80 | In particular, the following surface types don't support `ext-background-effect`. |
| 81 | They can be implemented as the need arises. |
| 82 | |
| 83 | - Subsurfaces. Would require implementing `clip-to-geometry` support for background effects. |
| 84 | - Lock surfaces. Not useful as it would just show our red locked session background. |
| 85 | - Cursor and drag-and-drop icon. |
| 86 | The main challenge here will be screencasts where the cursor is rendered separately. |
| 87 | This is problematic because non-xray effects require rendering the whole scene in one go rather than separately. |