2024-11-14 11:33:08 +03:00
### Overview
2025-01-10 15:38:03 +03:00
<sup>Since: 25.01</sup>
2024-11-21 14:54:43 +03:00
2024-11-14 11:33:08 +03:00
Layer rules let you adjust behavior for individual layer-shell surfaces.
They have `match` and `exclude` directives that control which layer-shell surfaces the rule should apply to, and a number of properties that you can set.
Layer rules are processed and work very similarly to window rules, just with different matchers and properties.
2025-03-15 16:42:05 +01:00
Please read the [window rules wiki page ](./Configuration:-Window-Rules.md ) to learn how matching works.
2024-11-14 11:33:08 +03:00
Here are all matchers and properties that a layer rule could have:
``` kdl
layer-rule {
match namespace= " waybar "
match at-startup= true
// Properties that apply continuously.
opacity 0.5
block-out-from " screencast "
// block-out-from "screen-capture"
2025-01-21 09:40:00 +03:00
shadow {
on
// off
softness 40
spread 5
offset x= 0 y= 5
draw-behind-window true
color " #00000064 "
// inactive-color "#00000064"
}
geometry-corner-radius 12
2025-05-06 16:51:18 +03:00
place-within-backdrop true
2025-05-12 08:16:01 +03:00
baba-is-float true
2024-11-14 11:33:08 +03:00
}
```
### Layer Surface Matching
Let's look at the matchers in more detail.
#### `namespace`
This is a regular expression that should match anywhere in the surface namespace.
You can read about the supported regular expression syntax [here ](https://docs.rs/regex/latest/regex/#syntax ).
``` kdl
// Match surfaces with namespace containing "waybar",
layer-rule {
match namespace= " waybar "
}
```
You can find the namespaces of all open layer-shell surfaces by running `niri msg layers` .
#### `at-startup`
Can be `true` or `false` .
Matches during the first 60 seconds after starting niri.
``` kdl
// Show layer-shell surfaces with 0.5 opacity at niri startup, but not afterwards.
layer-rule {
match at-startup= true
opacity 0.5
}
```
### Dynamic Properties
These properties apply continuously to open layer-shell surfaces.
#### `block-out-from`
You can block out surfaces from xdg-desktop-portal screencasts or all screen captures.
They will be replaced with solid black rectangles.
This can be useful for notifications.
2025-03-15 16:42:05 +01:00
The same caveats and instructions apply as for the [`block-out-from` window rule ](./Configuration:-Window-Rules.md#block-out-from ), so check the documentation there.
2024-11-14 11:33:08 +03:00

``` kdl
// Block out mako notifications from screencasts.
layer-rule {
match namespace= " ^notifications$ "
block-out-from " screencast "
}
```
#### `opacity`
Set the opacity of the surface.
`0.0` is fully transparent, `1.0` is fully opaque.
This is applied on top of the surface's own opacity, so semitransparent surfaces will become even more transparent.
Opacity is applied to every child of the layer-shell surface individually, so subsurfaces and pop-up menus will show window content behind them.
``` kdl
// Make fuzzel semitransparent.
layer-rule {
match namespace= " ^launcher$ "
opacity 0.95
}
```
2025-01-21 09:40:00 +03:00
#### `shadow`
2025-02-21 09:03:36 +03:00
<sup>Since: 25.02</sup>
2025-01-21 09:40:00 +03:00
Override the shadow options for the surface.
2025-03-15 16:42:05 +01:00
These rules have the same options as the normal [`shadow` config in the layout section ](./Configuration:-Layout.md#shadow ), so check the documentation there.
2025-01-21 09:40:00 +03:00
Unlike window shadows, layer surface shadows always need to be enabled with a layer rule.
That is, enabling shadows in the layout config section won't automatically enable them for layer surfaces.
> [!NOTE]
> Layer surfaces have no way to tell niri about their *visual geometry*.
> For example, if a layer surface includes some invisible margins (like mako), niri has no way of knowing that, and will draw the shadow behind the entire surface, including the invisible margins.
>
> So to use niri shadows, you'll need to configure layer-shell clients to remove their own margins or shadows.
``` kdl
// Add a shadow for fuzzel.
layer-rule {
match namespace= " ^launcher$ "
2025-05-06 16:51:18 +03:00
2025-01-21 09:40:00 +03:00
shadow {
on
}
// Fuzzel defaults to 10 px rounded corners.
geometry-corner-radius 10
}
```
#### `geometry-corner-radius`
2025-02-21 09:03:36 +03:00
<sup>Since: 25.02</sup>
2025-01-21 09:40:00 +03:00
Set the corner radius of the surface.
This setting will only affect the shadow—it will round its corners to match the geometry corner radius.
``` kdl
layer-rule {
2025-05-06 16:51:18 +03:00
match namespace= " ^launcher$ "
2025-01-21 09:40:00 +03:00
geometry-corner-radius 12
}
```
2025-05-06 16:51:18 +03:00
#### `place-within-backdrop`
2025-05-17 13:48:29 +03:00
<sup>Since: 25.05</sup>
2025-05-06 16:51:18 +03:00
Set to `true` to place the surface into the backdrop visible in the [Overview ](./Overview.md ) and between workspaces.
This will only work for * background * layer surfaces that ignore exclusive zones (typical for wallpaper tools).
2025-05-06 17:40:38 +03:00
Layers within the backdrop will ignore all input.
2025-05-06 16:51:18 +03:00
``` kdl
// Put swaybg inside the overview backdrop.
layer-rule {
match namespace= " ^wallpaper$ "
place-within-backdrop true
}
```
2025-05-12 08:16:01 +03:00
#### `baba-is-float`
2025-05-17 13:48:29 +03:00
<sup>Since: 25.05</sup>
2025-05-12 08:16:01 +03:00
Make your layer surfaces FLOAT up and down.
This is a natural extension of the [April Fools' 2025 feature ](./Configuration:-Window-Rules.md#baba-is-float ).
``` kdl
// Make fuzzel FLOAT.
layer-rule {
match namespace= " ^launcher$ "
baba-is-float true
}
```