Checks: make check, make race, make mocks-check, staticcheck; screencast e2e against real PipeWire (pw-dump: xBGR_210LE / smpte2084 / bt2020).
Before merge: purego-pipewire is pinned to a pseudo-version of purego-pipewire!4; merge it, tag v0.4.1, bump go.mod.
Not verified yet: real Sunshine + Moonlight HDR on the Shield.
@@ -10,7 +10,8 @@ NeferWL supports `zwlr_screencopy_manager_v1` (used by `grim`) and `ext_image_co
10
10
11
11
With ext-image-copy-capture, a client can capture an output, a window, a workspace (even off screen, without bars) or a region of an output. The workspace and region sources use the NeferWL protocol in `internal/adapters/wayland/imagecapture/`.
12
12
13
-
- Captures are 8-bit sRGB. HDR content is tone-mapped.
13
+
- Screenshots and recordings over these protocols are 8-bit sRGB. HDR content is tone-mapped. Screen sharing through the [portal](#portals) keeps HDR.
14
+
-`zwlr_screencopy_manager_v1` offers shared-memory buffers and, when the GPU can write them, linux-dmabuf buffers (XRGB8888 or ARGB8888), so a recorder can keep frames on the GPU.
14
15
- The cursor is never included.
15
16
- GPUs without Vulkan sync-file export (such as lavapipe) cannot capture.
16
17
-`neferwl_capture_exclusion_manager_v1` lets a recorder keep its own HUD out of its frames.
@@ -25,7 +26,8 @@ grim -o tv tv.png
25
26
```
26
27
27
28
Select `tv` in an OBS output-capture source or use `wayvnc -o tv`. The same
28
-
allowlist, portal and lock-security restrictions apply; virtual outputs are SDR.
29
+
allowlist, portal and lock-security restrictions apply. A virtual output with
30
+
`output.tv.hdr = on` is shared over the portal in HDR, like a physical one.
29
31
30
32
## The indicator
31
33
@@ -78,12 +80,24 @@ The allowlist stops unknown programs, not a program running as you that drives a
78
80
NeferWL serves the GNOME ScreenCast, DisplayConfig, Introspect and Screenshot D-Bus interfaces, so `xdg-desktop-portal-gnome` provides screen sharing and screenshots.
79
81
80
82
- **Screen sharing** in browsers and apps: install `xdg-desktop-portal-gnome` and run PipeWire. The portal dialog lists monitors and windows with their titles; the stream is a PipeWire video node. Without PipeWire, the ScreenCast interface is not offered.
83
+
- **GPU buffers only**: the stream's buffers are DMA-BUFs the GPU allocates (DRM format modifiers), and every frame is copied into them on the GPU, synchronised through the buffers' implicit fences. No frame goes through CPU memory and no shared-memory (memfd) buffer is offered: a program that cannot take DMA-BUF frames (or a GPU that cannot export them) gets no stream, and the cast ends with a `dmabuf` reason in the log. OBS, browsers, Sunshine and GStreamer's `pipewiresrc` take DMA-BUF. `wlr-screencopy` clients such as grim still get shared-memory frames.
81
84
- **Screenshots** through the portal, interactive or not: install [nefercap](https://github.com/bnema/nefercap), which writes the PNG.
82
85
- A cast keeps the indicator on until it ends. It ends when the session locks, the output or window goes away, the client stops it or disconnects, or NeferWL loses the D-Bus connection. When the receiving program stops reading, the stream pauses (no frames are rendered) and the cast stays open for the next reader, as in GNOME.
83
-
- Unsupported: area and virtual casts, and the "Select area" and "Window" choices of the screenshot dialog.
86
+
- **HDR**: sharing an output that shows HDR offers 10-bit PQ first (`xBGR_210LE`, BT.2020 primaries, SMPTE 2084, full-range RGB), with no tone mapping, and 8-bit sRGB (`BGRx`, `BGRA`) as the fallback for programs that do not take it. When the output turns HDR on or off, the stream renegotiates on the same PipeWire node: the receiving program keeps its stream. Window casts are 8-bit sRGB.
87
+
- Unsupported: area casts and casts of a monitor the cast itself creates (`RecordVirtual`; config-declared virtual outputs are shared like any output), and the "Select area" and "Window" choices of the screenshot dialog.
84
88
85
89
The packaged `neferwl-portals.conf` routes `ScreenCast` and `Screenshot` to the gnome portal.
86
90
87
91
The D-Bus interfaces are served on the session bus when NeferWL runs on a hardware session. With `--backend=headless`, pass `-dbus` to serve them. Names already owned (by a GNOME session) are skipped.
88
92
89
93
Screenshots through the portal are taken without asking, for any program running as you whose executable is on the allowlist. The indicator still flashes.
94
+
95
+
### Sunshine
96
+
97
+
[Sunshine](https://github.com/LizardByte/Sunshine) streams an HDR output through the portal. Set its capture method in `sunshine.conf`:
98
+
99
+
```ini
100
+
capture = portal
101
+
```
102
+
103
+
Pick the output in the portal dialog, for example a virtual `tv` with `output.tv.hdr = on`.
@@ -10,7 +10,8 @@ NeferWL supports `zwlr_screencopy_manager_v1` (used by `grim`) and `ext_image_co
10
10
11
With ext-image-copy-capture, a client can capture an output, a window, a workspace (even off screen, without bars) or a region of an output. The workspace and region sources use the NeferWL protocol in `internal/adapters/wayland/imagecapture/`.
11
With ext-image-copy-capture, a client can capture an output, a window, a workspace (even off screen, without bars) or a region of an output. The workspace and region sources use the NeferWL protocol in `internal/adapters/wayland/imagecapture/`.
12
12
13
-
- Captures are 8-bit sRGB. HDR content is tone-mapped.
13
+
- Screenshots and recordings over these protocols are 8-bit sRGB. HDR content is tone-mapped. Screen sharing through the [portal](#portals) keeps HDR.
14
+
-`zwlr_screencopy_manager_v1` offers shared-memory buffers and, when the GPU can write them, linux-dmabuf buffers (XRGB8888 or ARGB8888), so a recorder can keep frames on the GPU.
14
- The cursor is never included.
15
- The cursor is never included.
15
- GPUs without Vulkan sync-file export (such as lavapipe) cannot capture.
16
- GPUs without Vulkan sync-file export (such as lavapipe) cannot capture.
16
-`neferwl_capture_exclusion_manager_v1` lets a recorder keep its own HUD out of its frames.
17
-`neferwl_capture_exclusion_manager_v1` lets a recorder keep its own HUD out of its frames.
@@ -25,7 +26,8 @@ grim -o tv tv.png
25
```
26
```
26
27
27
Select `tv` in an OBS output-capture source or use `wayvnc -o tv`. The same
28
Select `tv` in an OBS output-capture source or use `wayvnc -o tv`. The same
28
-
allowlist, portal and lock-security restrictions apply; virtual outputs are SDR.
29
+
allowlist, portal and lock-security restrictions apply. A virtual output with
30
+
`output.tv.hdr = on` is shared over the portal in HDR, like a physical one.
29
31
30
## The indicator
32
## The indicator
31
33
@@ -78,12 +80,24 @@ The allowlist stops unknown programs, not a program running as you that drives a
78
NeferWL serves the GNOME ScreenCast, DisplayConfig, Introspect and Screenshot D-Bus interfaces, so `xdg-desktop-portal-gnome` provides screen sharing and screenshots.
80
NeferWL serves the GNOME ScreenCast, DisplayConfig, Introspect and Screenshot D-Bus interfaces, so `xdg-desktop-portal-gnome` provides screen sharing and screenshots.
79
81
80
- **Screen sharing** in browsers and apps: install `xdg-desktop-portal-gnome` and run PipeWire. The portal dialog lists monitors and windows with their titles; the stream is a PipeWire video node. Without PipeWire, the ScreenCast interface is not offered.
82
- **Screen sharing** in browsers and apps: install `xdg-desktop-portal-gnome` and run PipeWire. The portal dialog lists monitors and windows with their titles; the stream is a PipeWire video node. Without PipeWire, the ScreenCast interface is not offered.
83
+
- **GPU buffers only**: the stream's buffers are DMA-BUFs the GPU allocates (DRM format modifiers), and every frame is copied into them on the GPU, synchronised through the buffers' implicit fences. No frame goes through CPU memory and no shared-memory (memfd) buffer is offered: a program that cannot take DMA-BUF frames (or a GPU that cannot export them) gets no stream, and the cast ends with a `dmabuf` reason in the log. OBS, browsers, Sunshine and GStreamer's `pipewiresrc` take DMA-BUF. `wlr-screencopy` clients such as grim still get shared-memory frames.
81
- **Screenshots** through the portal, interactive or not: install [nefercap](https://github.com/bnema/nefercap), which writes the PNG.
84
- **Screenshots** through the portal, interactive or not: install [nefercap](https://github.com/bnema/nefercap), which writes the PNG.
82
- A cast keeps the indicator on until it ends. It ends when the session locks, the output or window goes away, the client stops it or disconnects, or NeferWL loses the D-Bus connection. When the receiving program stops reading, the stream pauses (no frames are rendered) and the cast stays open for the next reader, as in GNOME.
85
- A cast keeps the indicator on until it ends. It ends when the session locks, the output or window goes away, the client stops it or disconnects, or NeferWL loses the D-Bus connection. When the receiving program stops reading, the stream pauses (no frames are rendered) and the cast stays open for the next reader, as in GNOME.
83
-
- Unsupported: area and virtual casts, and the "Select area" and "Window" choices of the screenshot dialog.
86
+
- **HDR**: sharing an output that shows HDR offers 10-bit PQ first (`xBGR_210LE`, BT.2020 primaries, SMPTE 2084, full-range RGB), with no tone mapping, and 8-bit sRGB (`BGRx`, `BGRA`) as the fallback for programs that do not take it. When the output turns HDR on or off, the stream renegotiates on the same PipeWire node: the receiving program keeps its stream. Window casts are 8-bit sRGB.
87
+
- Unsupported: area casts and casts of a monitor the cast itself creates (`RecordVirtual`; config-declared virtual outputs are shared like any output), and the "Select area" and "Window" choices of the screenshot dialog.
84
88
85
The packaged `neferwl-portals.conf` routes `ScreenCast` and `Screenshot` to the gnome portal.
89
The packaged `neferwl-portals.conf` routes `ScreenCast` and `Screenshot` to the gnome portal.
86
90
87
The D-Bus interfaces are served on the session bus when NeferWL runs on a hardware session. With `--backend=headless`, pass `-dbus` to serve them. Names already owned (by a GNOME session) are skipped.
91
The D-Bus interfaces are served on the session bus when NeferWL runs on a hardware session. With `--backend=headless`, pass `-dbus` to serve them. Names already owned (by a GNOME session) are skipped.
88
92
89
Screenshots through the portal are taken without asking, for any program running as you whose executable is on the allowlist. The indicator still flashes.
93
Screenshots through the portal are taken without asking, for any program running as you whose executable is on the allowlist. The indicator still flashes.
94
+
95
+
### Sunshine
96
+
97
+
[Sunshine](https://github.com/LizardByte/Sunshine) streams an HDR output through the portal. Set its capture method in `sunshine.conf`:
98
+
99
+
```ini
100
+
capture = portal
101
+
```
102
+
103
+
Pick the output in the portal dialog, for example a virtual `tv` with `output.tv.hdr = on`.
Mdocs/config.md+25-6
@@ -85,8 +85,9 @@ See [examples/config](../examples/config) for every key with its default.
| `output.<name>.hdr` | `off` | [HDR](#hdr) on capable displays; ignored with a warning on virtual outputs, as are `.sdr-expand`, `.sdr-expand-intensity`, `.sdr-expand-peak` and `.sdr-decode` (always SDR) |
88
+
| `output.<name>.hdr` | `off` | [HDR](#hdr) on capable displays and on virtual outputs |
89
89
| `output.<name>.sdr-brightness` | `203` | Brightness of SDR content in HDR, in nits (80–1000) |
90
+
| `output.<name>.keep-focus` | `off` | Keeps an X11 window on this output X11-active while a native window has the keyboard; see [Virtual outputs](#virtual-outputs) |
| `render.device` | automatic | [GPU](#gpus) that renders; `NEFERWL_RENDER_DEVICE` overrides it (restart required) |
@@ -166,6 +167,7 @@ output.<name>.primary = off
166
167
output.<name>.offset = 0
167
168
output.<name>.hdr = off
168
169
output.<name>.sdr-brightness = 203
170
+
output.<name>.keep-focus = off
169
171
output.<name>.sdr-expand = auto
170
172
output.<name>.sdr-expand-intensity = 0.5
171
173
output.<name>.sdr-expand-peak = 0
@@ -176,7 +178,7 @@ Outputs are arranged automatically unless `.right-of`, `.left-of`, `.above` or `
176
178
177
179
## Window rules
178
180
179
-
Rules place an app's windows when they first open. A rule matches its app ID and, when set, its title. A title rule's output/workspace placement also applies when a later title first matches, at most once per rule per window. This later move never changes floating state or column width. When the focused window moves, it stays the focused window on the destination output, even an isolated one, and that output becomes focused (not while the source output's overview is open); otherwise focus and view are unchanged. With `output.<name>.input` bindings, input from an unbound device returns focus to the last unbound output. SDR expansion settings follow the current title match.
181
+
Rules place an app's windows when they first open. A window a rule opens on another output, even an isolated one, takes the focus there and that output becomes focused, as it would have taken the focus on the focused output; a window that would open in the background (behind another app's fullscreen window, during overview or lock) stays unfocused. A rule matches its app ID and, when set, its title. A title rule's output/workspace placement also applies when a later title first matches, at most once per rule per window. This later move never changes floating state or column width. When the focused window moves, it stays the focused window on the destination output, even an isolated one, and that output becomes focused (not while the source output's overview is open); otherwise focus and view are unchanged. With `output.<name>.input` bindings, input from an unbound device returns focus to the last unbound output. SDR expansion settings follow the current title match.
180
182
181
183
| Key | Meaning |
182
184
|---|---|
@@ -205,7 +207,7 @@ rule.calc.floating = on
205
207
```
206
208
207
209
- Every matching rule applies, in file order; later rules win.
208
-
- A rule never moves your focus or view.
210
+
- A rule never moves your focus or view, except a new window or a focused window it sends to another output (above).
209
211
- Proton games (X11) use `steam_app_<id>` as app ID, taken from `WM_CLASS`.
210
212
- An X11 window that opens exactly on one output's area opens on that output, unless a rule sets `output`.
211
213
- A rule can float a Proton game: `rule.games.app-id = steam_app_\d+` with `rule.games.floating = on`. Without a rule, X11 games tile until they ask for fullscreen.
@@ -213,7 +215,7 @@ rule.calc.floating = on
213
215
214
216
## Virtual outputs
215
217
216
-
Declare an SDR output in the config; it exists while its entry remains:
218
+
Declare a virtual output in the config; it exists while its entry remains:
| `output.<name>.hdr` | `off` | [HDR](#hdr) on capable displays; ignored with a warning on virtual outputs, as are `.sdr-expand`, `.sdr-expand-intensity`, `.sdr-expand-peak` and `.sdr-decode` (always SDR) |
88
+
| `output.<name>.hdr` | `off` | [HDR](#hdr) on capable displays and on virtual outputs |
89
| `output.<name>.sdr-brightness` | `203` | Brightness of SDR content in HDR, in nits (80–1000) |
89
| `output.<name>.sdr-brightness` | `203` | Brightness of SDR content in HDR, in nits (80–1000) |
90
+
| `output.<name>.keep-focus` | `off` | Keeps an X11 window on this output X11-active while a native window has the keyboard; see [Virtual outputs](#virtual-outputs) |
| `render.device` | automatic | [GPU](#gpus) that renders; `NEFERWL_RENDER_DEVICE` overrides it (restart required) |
93
| `render.device` | automatic | [GPU](#gpus) that renders; `NEFERWL_RENDER_DEVICE` overrides it (restart required) |
@@ -166,6 +167,7 @@ output.<name>.primary = off
166
output.<name>.offset = 0
167
output.<name>.offset = 0
167
output.<name>.hdr = off
168
output.<name>.hdr = off
168
output.<name>.sdr-brightness = 203
169
output.<name>.sdr-brightness = 203
170
+
output.<name>.keep-focus = off
169
output.<name>.sdr-expand = auto
171
output.<name>.sdr-expand = auto
170
output.<name>.sdr-expand-intensity = 0.5
172
output.<name>.sdr-expand-intensity = 0.5
171
output.<name>.sdr-expand-peak = 0
173
output.<name>.sdr-expand-peak = 0
@@ -176,7 +178,7 @@ Outputs are arranged automatically unless `.right-of`, `.left-of`, `.above` or `
176
178
177
## Window rules
179
## Window rules
178
180
179
-
Rules place an app's windows when they first open. A rule matches its app ID and, when set, its title. A title rule's output/workspace placement also applies when a later title first matches, at most once per rule per window. This later move never changes floating state or column width. When the focused window moves, it stays the focused window on the destination output, even an isolated one, and that output becomes focused (not while the source output's overview is open); otherwise focus and view are unchanged. With `output.<name>.input` bindings, input from an unbound device returns focus to the last unbound output. SDR expansion settings follow the current title match.
181
+
Rules place an app's windows when they first open. A window a rule opens on another output, even an isolated one, takes the focus there and that output becomes focused, as it would have taken the focus on the focused output; a window that would open in the background (behind another app's fullscreen window, during overview or lock) stays unfocused. A rule matches its app ID and, when set, its title. A title rule's output/workspace placement also applies when a later title first matches, at most once per rule per window. This later move never changes floating state or column width. When the focused window moves, it stays the focused window on the destination output, even an isolated one, and that output becomes focused (not while the source output's overview is open); otherwise focus and view are unchanged. With `output.<name>.input` bindings, input from an unbound device returns focus to the last unbound output. SDR expansion settings follow the current title match.
180
182
181
| Key | Meaning |
183
| Key | Meaning |
182
|---|---|
184
|---|---|
@@ -205,7 +207,7 @@ rule.calc.floating = on
205
```
207
```
206
208
207
- Every matching rule applies, in file order; later rules win.
209
- Every matching rule applies, in file order; later rules win.
208
-
- A rule never moves your focus or view.
210
+
- A rule never moves your focus or view, except a new window or a focused window it sends to another output (above).
209
- Proton games (X11) use `steam_app_<id>` as app ID, taken from `WM_CLASS`.
211
- Proton games (X11) use `steam_app_<id>` as app ID, taken from `WM_CLASS`.
210
- An X11 window that opens exactly on one output's area opens on that output, unless a rule sets `output`.
212
- An X11 window that opens exactly on one output's area opens on that output, unless a rule sets `output`.
211
- A rule can float a Proton game: `rule.games.app-id = steam_app_\d+` with `rule.games.floating = on`. Without a rule, X11 games tile until they ask for fullscreen.
213
- A rule can float a Proton game: `rule.games.app-id = steam_app_\d+` with `rule.games.floating = on`. Without a rule, X11 games tile until they ask for fullscreen.
@@ -213,7 +215,7 @@ rule.calc.floating = on
213
215
214
## Virtual outputs
216
## Virtual outputs
215
217
216
-
Declare an SDR output in the config; it exists while its entry remains:
218
+
Declare a virtual output in the config; it exists while its entry remains:
@@ -197,6 +196,8 @@ func (o *Output) updateExpansionPeak(peak float64) {
197
196
}
198
197
199
198
// applyExpansionPeak runs on the output owner, alongside lifecycle reporting.
199
+
//
200
+
//hexcheck:ignore suspicious-business-logic-in-adapter stores the owner-delivered peak and republishes caps; resolution policy is domain.NewOutputHDRCaps
200
201
func (o *Output) applyExpansionPeak(peak float64) {
@@ -197,6 +196,8 @@ func (o *Output) updateExpansionPeak(peak float64) {
197
}
196
}
198
197
199
// applyExpansionPeak runs on the output owner, alongside lifecycle reporting.
198
// applyExpansionPeak runs on the output owner, alongside lifecycle reporting.
199
+
//
200
+
//hexcheck:ignore suspicious-business-logic-in-adapter stores the owner-delivered peak and republishes caps; resolution policy is domain.NewOutputHDRCaps
200
func (o *Output) applyExpansionPeak(peak float64) {
201
func (o *Output) applyExpansionPeak(peak float64) {
201
if peak == o.hdr.settings.ExpansionPeakNits {
202
if peak == o.hdr.settings.ExpansionPeakNits {
202
return
203
return
Minternal/adapters/drm/hdr_caps_test.go+5-5
@@ -10,14 +10,14 @@ import (
10
10
11
11
func TestHDRCapabilityCaps(t *testing.T) {
12
12
c := hdrCapability{Capable: true, HDRMetadata: HDRMetadata{MaxLuminance: 604, MaxFrameAverage: 277}}