logo
Expand description

Start a screencast session and get the PipeWire remote of it.

Examples

How to create a screen cast session & start it. The portal is currently useless without PipeWire & Rust support.

use ashpd::desktop::screencast::{CursorMode, PersistMode, ScreenCastProxy, SourceType};
use ashpd::WindowIdentifier;
use enumflags2::BitFlags;

async fn run() -> ashpd::Result<()> {
    let connection = zbus::Connection::session().await?;
    let proxy = ScreenCastProxy::new(&connection).await?;

    let session = proxy.create_session().await?;

    proxy
        .select_sources(
            &session,
            BitFlags::from(CursorMode::Metadata),
            SourceType::Monitor | SourceType::Window,
            true,
            None,
            PersistMode::DoNot,
        )
        .await?;

    let (streams, token) = proxy.start(&session, &WindowIdentifier::default()).await?;

    streams.iter().for_each(|stream| {
        println!("node id: {}", stream.pipe_wire_node_id());
        println!("size: {:?}", stream.size());
        println!("position: {:?}", stream.position());
    });
    Ok(())
}

Structs

The interface lets sandboxed applications create screen cast sessions.

A PipeWire stream.

Enums

A bit flag for the possible cursor modes.

A bit flag for the available sources to record.