Add geometry-corner-radius and background-effect popup rules

This commit is contained in:
Ivan Molodetskikh
2026-04-12 07:41:26 +00:00
parent 5a24aae560
commit 4d21489101
12 changed files with 222 additions and 28 deletions
+51
View File
@@ -42,6 +42,18 @@ layer-rule {
noise 0.05
saturation 3
}
popups {
opacity 0.5
geometry-corner-radius 6
background-effect {
xray true
blur true
noise 0.05
saturation 3
}
}
}
```
@@ -241,3 +253,42 @@ layer-rule {
}
}
```
#### `popups`
<sup>Since: next release</sup>
Override properties for this layer surface's pop-ups (e.g. a menu opened by clicking an item in Waybar).
The properties work the same way as the corresponding layer-rule properties, except that they apply to the layer surface's pop-ups rather than to the layer surface itself.
`opacity` is applied *on top* of the layer surface's own opacity rule, so setting both will make pop-ups more transparent than the surface.
Other properties apply independently.
> [!NOTE]
> This block affects only pop-ups created by the app via Wayland's [xdg-popup](https://wayland.app/protocols/xdg-shell#xdg_popup) (which should be most of them).
>
> Some desktop shells will emulate pop-ups by drawing something that looks like a pop-up inside a regular layer surface.
> As far as niri is concerned, those are just layer surfaces and not pop-ups, so this block won't apply to them.
>
> This block also does not affect input-method pop-ups, such as Fcitx.
```kdl
// Blur the background behind Waybar popup menus.
layer-rule {
match namespace="^waybar$"
popups {
// Match the default GTK 3 popup corner radius.
geometry-corner-radius 6
opacity 0.85
background-effect {
blur true
}
}
}
```
Keep in mind that the background effect will look right only if the pop-up is shaped like a (rounded) rectangle, and the layer surface correctly sets its Wayland geometry to exclude any shadows.
Pop-ups with custom shapes will need the app to implement the [ext-background-effect protocol](https://wayland.app/protocols/ext-background-effect-v1) to work properly.
+73
View File
@@ -107,6 +107,18 @@ window-rule {
saturation 3
}
popups {
opacity 0.5
geometry-corner-radius 15
background-effect {
xray true
blur true
noise 0.05
saturation 3
}
}
min-width 100
max-width 200
min-height 300
@@ -941,6 +953,67 @@ window-rule {
}
```
#### `popups`
<sup>Since: next release</sup>
Override properties for this window's pop-ups (menus and tooltips).
The properties work the same way as the corresponding window-rule properties, except that they apply to the window's pop-ups rather than to the window itself.
`opacity` is applied *on top* of the layer surface's own opacity rule, so setting both will make pop-ups more transparent than the surface.
Other properties apply independently.
> [!NOTE]
> This block affects only pop-ups created by the app via Wayland's [xdg-popup](https://wayland.app/protocols/xdg-shell#xdg_popup) (which should be most of them).
>
> Examples of things that look like pop-ups that won't work:
>
> - Fully emulated by the client, i.e. not a pop-up at all, the client just draws something that looks like a pop-up inside its window.
> These are common in game engines and in web apps, e.g. the right click menu in Google Docs or in Electron apps like Discord.
>
> - Uses a wl-subsurface instead of an xdg-popup.
> Common in older apps using GTK 3, notably Firefox still uses these for some menus.
> Subsurfaces are an indivisible part of a surface and they aren't usually pop-ups, so it wouldn't make sense for niri to apply these rules to them.
>
> These emulated pop-ups come with other downsides: they cannot reliably extend outside their window, and if the app tries to do that, they will be clipped by rules such as `clip-to-geometry`.
> So most modern apps will correctly use xdg-popup, which is the intended way to show pop-ups on Wayland.
>
> This block also does not affect input-method pop-ups, such as Fcitx.
>
> For pop-ups created by your desktop shell or desktop components, use the corresponding [layer rule](./Configuration:-Layer-Rules.md#popups).
```kdl
// Blur the background behind pop-up menus in Nautilus.
window-rule {
match app-id="Nautilus"
popups {
// Matches the default libadwaita pop-up corner radius.
geometry-corner-radius 15
// Note: it'll look better to set background opacity
// through your GTK theme CSS and not here.
// This is just an example that makes it look obvious.
opacity 0.5
background-effect {
blur true
}
}
}
```
Keep in mind that the background effect will look right only if the pop-up is shaped like a (rounded) rectangle, and the window correctly sets its Wayland geometry to exclude any shadows.
For example, GTK 4 pop-ups with pointing arrows (`has-arrow=true` property) are *not* rounded rectangles—the arrow sticks out—so if you enable blur, it will also stick out of the pop-up.
| Correct | Wrong |
|-----------------------------------------------------|--------------------------------------------------------------------------------|
| The pop-up is a rounded rectangle. Blur looks fine. | The pop-up is not a rounded rectangle. Blur extends above, where the arrow is. |
| ![](./img/popup-no-arrow.png) | ![](./img/popup-arrow.png) |
These pop-ups with custom shapes will need the app to implement the [ext-background-effect protocol](https://wayland.app/protocols/ext-background-effect-v1) to work properly.
#### Size Overrides
You can amend the window's minimum and maximum size in logical pixels.
+4
View File
@@ -40,6 +40,10 @@ Blur enabled via the window rule will follow the window corner radius set via [`
On the other hand, blur enabled through `ext-background-effect` will exactly follow the shape requested by the window.
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.
Windows can also blur their pop-up menus using `ext-background-effect`.
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).
See those wiki pages for examples and limitations.
Global blur settings are configured in the [`blur {}` config section](./Configuration:-Miscellaneous.md#blur) and apply to all background blur.
### Xray
+3
View File
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b5a63ea3cc2f158e175c00dd058988a2bbf676e2a2aac5c2ef1603bd983589d5
size 166777
+3
View File
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bef0c57d617916bf6014fe08e268c8201d7f6ef682e3aea3395e76116b1d0400
size 56936