Open Source › xdg-desktop-portal-generic

xdg-desktop-portal-generic

A complete XDG Desktop Portal backend that runs as an ordinary Wayland client. One backend, five portal interfaces, automatic protocol selection.

Open source | v2.0.4 | MIT OR Apache-2.0 | Prebuilt for x86_64 and aarch64; Rust 1.89 to build | Wayland-only (standalone Wayland client)
NEW · v2.0.4

What's new in 2.0

2.0.4: prebuilt downloads, and correct stream sizes

The first release with prebuilt, GPG-signed x86_64 and aarch64 tarballs (install). Stream sizes now go out with the D-Bus type the portal specification gives them, (ii) rather than (uu); xdg-desktop-portal looks the size up with exactly that type, so it had been getting no size for any stream, and it checks absolute pointer motion against that size. Contributed by ParticleG in pull request #2.

2.0.0: a session belongs to the application that created it

Session paths can be read by introspecting the backend, and in 1.x any peer on the bus could use one to inject input into another application's session, take its PipeWire connection, close it, or answer its pastes. Every method now checks the caller against the session's creator and refuses anyone else with AccessDenied. Clipboard transfers go only to the selection owner, restore_data is a single-use token bound to the application instead of a list of output names anyone could present, and a source picker that's cancelled, fails or selects nothing cancels the request. Started sessions also no longer expire after 10 minutes with their capture still running.

Upgrading from 1.x

Applications that saved a screen cast ask once more, because version 1 restore_data is ignored. Code that builds SessionInterface, RequestInterface, RestoreData or PendingWriteEntry itself needs the new arguments; a consumer that only embeds the backends and doesn't run PortalBackend::run is otherwise unaffected. Without a source picker the first source is still captured, as in 1.x (restored in 2.0.1), and the new XDP_GENERIC_AUTO_SELECT=none refuses such requests on a desktop where every screen cast should go through a picker.

Resizes don't stall capture

2.0.3: A mode change while a frame was pending ended every ext-image-copy-capture stream with a protocol error (seen on Hyprland 0.56). 1.2.1: The first frame after a resize arrives at once, where niri held it for 5.5 s on a still desktop.

1.3.0: capture without a PipeWire daemon

PipeWireManager::detached() serves a consumer that takes every frame in process, with no PipeWire node and no daemon connection, so capture works where the PipeWire socket can't be reached, as in a Snap.

1.2.0: zbus 6

zbus 5 is no longer maintained (RUSTSEC-2026-0370 to 0372). Code that uses this crate's zbus types needs zbus 6 too, and the minimum Rust version is 1.89.

lamco-data-control 1.0.2

A Wayland data-control clipboard client (ext-data-control-v1 and wlr-data-control-unstable-v1) with delayed rendering, no async runtime, and no dependency on D-Bus, PipeWire or an RDP stack. It can be used on its own. crates.io · docs.rs

Earlier: 0.9.0 fixed Chromium/Electron non-ASCII typing, corrected multi-monitor input targeting, and fixed a 120x-too-fast scroll wheel. Full details in the changelog.

WHAT IT IS

Portal access, without compositor buy-in

xdg-desktop-portal is the Freedesktop spec that lets sandboxed applications (Flatpak, Snap, and increasingly native Wayland apps) ask for privileged capabilities such as screen capture, remote-desktop input, clipboard access, and screenshots through a permission-mediated D-Bus interface. Most compositors ship their own backend implementation (xdg-desktop-portal-gnome, xdg-desktop-portal-kde, xdg-desktop-portal-wlr). A compositor without one cannot offer these capabilities to sandboxed apps.

xdg-desktop-portal-generic fills that gap. It gives sandboxed apps (Flatpak and Snap) and native Wayland apps screen capture, remote-desktop input, clipboard access, screenshots, and desktop settings on any compositor that speaks the standard ext or wlr Wayland protocols, with no compositor-side code and no custom traits. It detects the available protocols at startup and selects the best one per requested portal. One backend, five portal interfaces, automatic protocol selection.

PORTALS SUPPORTED

Five portal interfaces

Each portal uses the best available protocol, with an automatic fallback when the preferred path is not present.
Portal Ver Primary protocol Fallback
RemoteDesktopv2EIS (libei) bridgewlr-virtual-pointer + zwp-virtual-keyboard
ScreenCastv6ext-image-copy-capture-v1 (emits pipewire-serial)wlr-screencopy-v1
Clipboardv1ext-data-control-v1wlr-data-control-v1
Settingsv2Environment variable configGTK_THEME detection
Screenshotv2Single-frame capture to PNGNone

ext protocols are preferred over their wlr equivalents when both are present. ScreenCast supports hidden, embedded, and metadata cursor modes.

HOW IT WORKS

A standard Wayland client, three cooperating threads

The backend connects to the compositor as a standard Wayland client and runs three cooperating threads: a tokio async runtime that serves the portal D-Bus interfaces, a Wayland event loop that handles protocol dispatch and frame capture, and a PipeWire thread that delivers captured frames to the requesting app. For each portal domain it detects the available protocols at startup and selects the best one, preferring the modern ext protocols and falling back to the wlr equivalents.

Capture uses ext-image-copy-capture-v1 with a wlr-screencopy-v1 fallback and supports hidden, embedded, and metadata cursor modes. Input uses an EIS (libei) bridge with a wlr virtual pointer and keyboard fallback, plus an optional kernel uinput backend for compositors without a virtual pointer. Clipboard uses ext-data-control-v1 with a wlr-data-control-v1 fallback. The whole backend is about 16,000 lines of Rust across 38 modules, with no compositor-side code.

INSTALL & CONFIGURE

Download, install, pick it as your backend

From 2.0.4 every release ships the compiled binary, ready to run, for x86_64 and aarch64, in a GPG-signed tarball. Installing it needs no Rust toolchain and no development packages, which building from source does. The crate is also on crates.io for building from source.

Each tarball holds the binary, the three files make install puts in place (the .portal file, the D-Bus service file and the systemd user unit), an install.sh that installs them in the same places, and the README, changelog and licenses. It needs glibc 2.34 or newer and PipeWire 0.3 or 1.x: Debian 12, Ubuntu 22.04, Fedora 35, RHEL 9 and later. Checksums and signatures are on the v2.0.4 release, and the latest release always has the newest.

verify & install
# Lamco's release key (CA11F781516743D5D9A1A12F17B95B68A50CD3A7)
curl -s https://apt.lamco.ai/key.gpg | gpg --import
gpg --verify SHA256SUMS.asc SHA256SUMS
sha256sum --check --ignore-missing SHA256SUMS

tar xzf xdg-desktop-portal-generic-2.0.4-x86_64-linux-gnu.tar.gz
cd xdg-desktop-portal-generic-2.0.4-x86_64-linux-gnu
sudo ./install.sh

# Remove the same files later with:
sudo ./install.sh --uninstall

The key is also on keyserver.ubuntu.com. Don't fetch it from keys.openpgp.org: It serves this key without its user ID, so gpg can't check the signature with it.

or build from source (needs Rust and the development packages)
# Dependencies (Debian / Ubuntu), and Rust 1.89 or newer:
sudo apt install libpipewire-0.3-dev libspa-0.2-dev libwayland-dev \
    libxkbcommon-dev libclang-dev

# Build and install:
cargo build --release
sudo make install

# Installs binary, portal config, D-Bus service, systemd user unit.

There's no Flatpak, Snap or distribution package from Lamco. Arch users have a community-maintained AUR package, xdg-desktop-portal-generic. Either way, point xdg-desktop-portal at the backend:

~/.config/xdg-desktop-portal/portals.conf
[preferred]
default=gtk
org.freedesktop.impl.portal.RemoteDesktop=generic
org.freedesktop.impl.portal.ScreenCast=generic
org.freedesktop.impl.portal.Clipboard=generic
org.freedesktop.impl.portal.Settings=generic
org.freedesktop.impl.portal.Screenshot=generic

Once configured, xdg-desktop-portal auto-activates the generic backend via D-Bus when a sandboxed app requests one of the supported portals.

TUNING

Configured via environment variables

All configuration is environment-variable-based. Set it once in your compositor config or systemd override, with no config file to manage.

Appearance & accessibility

Variable Values Default
XDP_GENERIC_COLOR_SCHEME0 / 1 / 2 (detect / dark / light)0
XDP_GENERIC_ACCENT_COLORr,g,b floats0.21,0.52,0.89
XDP_GENERIC_CONTRAST0 / 10
XDP_GENERIC_REDUCED_MOTION0 / 10

Input protocol selection

Variable Values Default
XDP_GENERIC_INPUT_PROTOCOLeis / wlreis
XDP_GENERIC_INPUT_NO_FALLBACK1unset
XDP_GENERIC_EIS_SOCKETpathauto

External tools

Variable Description
XDP_GENERIC_SOURCE_PICKERExternal tool for ScreenCast source selection UI. Use fzf, rofi, or anything that speaks stdin/stdout
XDP_GENERIC_AUTO_SELECTWhat a ScreenCast request does with no source picker set. Unset, it captures the first source; none cancels the request. Read once at startup, like the picker
XDP_GENERIC_COLOR_PICKERExternal tool for Screenshot color picking
FIT

Where it fits

Built for Wayland compositors that do not ship their own portal backend.

xdg-desktop-portal-generic is built for Wayland compositors that do not ship their own portal backend: COSMIC, niri, Jay, and other Smithay-based compositors. Because it speaks the standard ext and wlr Wayland protocols, it also runs on wlroots compositors that expose those protocols. GNOME and KDE ship their own portal backends, so those desktops use theirs.

Built for

  • COSMIC ↑, System76's desktop environment
  • niri ↑, a scrollable-tiling Wayland compositor
  • Jay ↑, a tiling Wayland compositor
  • Other Smithay-based compositors, and wlroots compositors that expose the ext or wlr protocols

Runtime needs

  • A Wayland session exposing the ext or wlr protocols
  • PipeWire (libpipewire 0.3.64 or newer for the pipewire-serial value; older PipeWire works and omits that one property)
  • The xdg-desktop-portal frontend