Open SourceLamco Wayland › Portal

lamco-portal

High-level XDG Desktop Portal bindings for Wayland screen capture and input control

v0.4.0 · MIT/Apache-2.0

The sanctioned Wayland capture path

Wayland intentionally has no equivalent of XShmGetImage — capturing another surface requires going through the xdg-desktop-portal, which prompts the user for consent and returns a PipeWire file descriptor. lamco-portal is a thin, async-first Rust layer over that flow: you get a PortalManager, request a session, and the user’s compositor handles the permission dialog.

What’s inside

Screen capture

Monitor or window content via PipeWire streams

Input injection

Keyboard and mouse events into the user’s session

Clipboard integration

Portal-based clipboard for remote desktop scenarios

Multi-monitor

Multiple displays handled simultaneously

Flexible configuration

Builder pattern or struct-literal style

Typed errors

Match and handle specific failure conditions

Quick start

Cargo.toml
[dependencies]
lamco-portal = "0.4"
tokio = { version = "1", features = ["full"] }
basic usage
use lamco_portal::{PortalManager, PortalConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create portal manager with default config
    let manager = PortalManager::with_default().await?;

    // Create session (triggers permission dialog on the compositor)
    let session = manager.create_session("my-session".to_string(), None).await?;

    // Access PipeWire FD for video capture
    let fd = session.pipewire_fd();
    let streams = session.streams();

    println!("Capturing {} streams on PipeWire FD {}", streams.len(), fd);

    // Inject mouse movement
    manager.remote_desktop()
        .notify_pointer_motion_absolute(
            session.ashpd_session(),
            0,      // stream index
            100.0,  // x position
            200.0,  // y position
        )
        .await?;

    Ok(())
}

Feature flags

Feature Description
(default)Basic portal functionality — screencast, remote desktop, clipboard
dbus-clipboardD-Bus clipboard bridge for GNOME (works around missing SelectionOwnerChanged signals)
clipboard-sinkClipboardSink trait implementation for lamco-clipboard-core integration