An XDG Desktop Portal ScreenCast backend for niri, with GTK4 display/window selection and PipeWire integration.
It implements org.freedesktop.impl.portal.ScreenCast and can replace
xdg-desktop-portal-gnome for screen sharing while keeping other portal
interfaces on the user's existing backends.
paru -S niri-screenshare
# or: yay -S niri-screenshareThe AUR package installs the prebuilt Linux x86_64 binary from GitHub Releases. Rust and Cargo are not required, and installation does not compile the application. The package includes the portal, D-Bus and systemd integration files. Runtime dependencies are still installed by the package manager.
Prebuilt Linux x86_64 archives and SHA-256 checksums are available on the GitHub Releases page. Manual installation requires installing the matching portal, D-Bus and systemd integration files from the release's source tree as well as the binary. For Arch Linux, the AUR package handles this automatically.
The default picker build requires the gtk4 and libadwaita system packages.
Build without the picker via cargo build --release --no-default-features.
git clone https://github.com/pantarune/niri-screenshare
cd niri-screenshare
cargo build --release
sudo cp target/release/niri-screenshare /usr/lib/
sudo cp data/niri.portal /usr/share/xdg-desktop-portal/portals/
sudo cp data/org.freedesktop.impl.portal.desktop.niri.service /usr/share/dbus-1/services/
cp data/niri-screenshare.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now niri-screenshare.serviceNo manual config is normally needed. On first service start the backend adds only
org.freedesktop.impl.portal.ScreenCast=niri to the user's portal preferences;
it does not replace the default backend for unrelated portal interfaces.
picker mode (default) — a GTK4 dialog with Displays / Windows tabs appears when an app requests screen sharing (OBS, Discord, Firefox, etc.). The requested XDG source types are respected, and the user must explicitly approve sharing even when only one capture target is available.
Set NIRI_SCREENSHARE_NO_PICKER=1 to skip the dialog. Pickerless mode currently
auto-selects the focused output and therefore supports monitor capture only; it
does not claim to implement niri's synthetic Dynamic Cast Target.
Dynamic casting requires the app to request window sources, as with the dynamic
target in the GNOME picker. Select or switch the target with
niri msg action set-dynamic-cast-window or
niri msg action set-dynamic-cast-monitor. clear-dynamic-cast-target blanks
the stream. All dynamic streams share one target. Each new stream waits for a
fresh selection.
NixOS users can set services.niri-screenshare.dynamicCast = true.
Set NIRI_SCREENSHARE_DYNAMIC_CAST_AUTO_SELECT_MONITOR=1 to start dynamic casts
on the focused monitor. Each new share also switches existing dynamic streams
to that monitor. On NixOS, set
services.niri-screenshare.dynamicCastAutoSelectMonitor = true.
| build | behavior |
|---|---|
default |
GTK4 picker dialog for requested displays/windows |
--no-default-features |
pickerless focused-output capture |
| variable | effect |
|---|---|
NIRI_SCREENSHARE_NO_PICKER=1 |
skip picker and auto-select the focused output |
NIRI_SCREENSHARE_DYNAMIC_CAST=1 |
bypass picker and use Niri's Dynamic Cast Target |
NIRI_BIN=/path/to/niri |
override niri binary path (for NixOS etc.) |
NIRI_SOCKET=/path/to/socket |
explicitly select the niri IPC socket |
If more than one niri IPC socket exists and none can be matched to
WAYLAND_DISPLAY, the backend refuses to guess; set NIRI_SOCKET explicitly.
Open the picker dialog standalone without starting a portal session:
niri-screenshare --debug-pickerRun basic environment checks:
niri-screenshare checkThe portal daemon reads $XDG_CONFIG_HOME/xdg-desktop-portal/portals.conf
(or ~/.config/xdg-desktop-portal/portals.conf when XDG_CONFIG_HOME is unset)
to decide which backend to use. niri-screenshare adds its ScreenCast preference
without changing unrelated defaults. Override it by editing that file before
starting the service.
app → xdg-desktop-portal → niri-screenshare → Mutter.ScreenCast → PipeWire
- an app calls
CreateSessionandSelectSourceson the portal frontend - xdg-desktop-portal forwards the request to niri-screenshare
- niri-screenshare filters targets to the requested source types and asks for consent
- the app calls
Start; niri-screenshare asks niri to start the selected stream - the PipeWire node id is returned to xdg-desktop-portal
- xdg-desktop-portal exposes the appropriate PipeWire remote to the app
Pending calls export org.freedesktop.impl.portal.Request. An application's
Request.Close cancels its chooser or in-flight capture startup, including when
cancellation arrives immediately after the request. Clicking Cancel in the
chooser also returns the portal's cancelled response.
Failed starts are cleaned up and may be retried. Closing a portal session stops
the corresponding compositor screencast session. If the compositor ends the
session, for example when a captured window closes, the backend emits
org.freedesktop.impl.portal.Session.Closed and removes the session object.
Session objects expose the standard version property.
- runtime:
xdg-desktop-portal,pipewire,niri,gtk4,libadwaita - build from source only: Rust/Cargo,
gtk4,libadwaita
The AUR binary package does not require the Rust toolchain. GTK4/libadwaita
are not needed by a --no-default-features source build.
The test suite also requires dbus-daemon. Its lifecycle regression tests create
private buses and a controlled compositor service; they do not use the desktop's
session bus or start a real screen capture.
picker doesn't appear — the AUR prebuilt binary includes the picker.
For source builds, make sure you built with default features
(cargo build --release). Ensure NIRI_SCREENSHARE_NO_PICKER is unset. Check the service log:
journalctl --user -u niri-screenshare -n 20obs/discord shows "no capture sources" — verify the portal backend is registered:
busctl list | grep niriIf nothing shows, restart the service:
systemctl --user restart niri-screenshareportal daemon crashes on screenshare — some xdg-desktop-portal 1.22.1
builds have a bug in session initialization. Upgrading or reinstalling usually
fixes it.
- Ly-sec — GTK4 picker, cancel fix, NixOS packaging