17 releases

Uses new Rust 2021

0.3.2 May 1, 2022
0.3.0 Mar 19, 2022
0.2.0-alpha-5 Oct 22, 2021
0.2.0-alpha-2 Jul 12, 2021
0.1.0 Sep 14, 2020

#25 in GUI

Download history 2444/week @ 2022-03-08 2535/week @ 2022-03-15 2973/week @ 2022-03-22 1987/week @ 2022-03-29 1875/week @ 2022-04-05 1467/week @ 2022-04-12 1708/week @ 2022-04-19 1369/week @ 2022-04-26 1615/week @ 2022-05-03 1747/week @ 2022-05-10 1491/week @ 2022-05-17 1296/week @ 2022-05-24 1197/week @ 2022-05-31 1292/week @ 2022-06-07 1480/week @ 2022-06-14 1363/week @ 2022-06-21

5,513 downloads per month
Used in 8 crates (3 directly)

MIT license

330KB
5.5K SLoC

ASHPD

docs crates.io CI

ASHPD, acronym of Aperture Science Handheld Portal Device is a Rust & zbus wrapper of the XDG portals DBus interfaces. The library aims to provide an easy way to interact with the various portals defined per the specifications. It provides an alternative to the C library https://github.com/flatpak/libportal

Examples

Ask the compositor to pick a color

use ashpd::desktop::screenshot::ScreenshotProxy;
use ashpd::WindowIdentifier;

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

    let color = proxy.pick_color(&WindowIdentifier::default()).await?;
    println!("({}, {}, {})", color.red(), color.green(), color.blue());
    Ok(())
}

Start a PipeWire stream from the user's camera

use ashpd::desktop::camera::CameraProxy;

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

    if proxy.is_camera_present().await? {
        proxy.access_camera().await?;
        let remote_fd = proxy.open_pipe_wire_remote().await?;
        // pass the remote fd to GStreamer for example
    }
    Ok(())
}

Optional features

Feature Description
log Record various debug information using the tracing library
tokio_runtime Enable tokio runtime on zbus dependency
feature_gtk3 Implement From<Color> for gdk3::RGBA
Provides WindowIdentifier::from_window that takes a IsA<gdk3::Window>
feature_gtk4 Implement From<Color> for gdk4::RGBA
Provides WindowIdentifier::from_native that takes a IsA<gtk4::Native>
feature_pipewire Provides ashpd::desktop::camera::pipewire_node_id that helps you retrieve the PipeWire Node ID to use with the file descriptor returned by the camera portal
raw_handle Provides WindowIdentifier::from_raw_handle and WindowIdentifier::as_raw_handle for raw-window-handle crate
wayland Provides WindowIdentifier::from_wayland for wayland-client crate

Demo

The library comes with a demo built using the GTK 4 Rust bindings and previews most of the portals. It is meant as a test case for the portals (from a distributor perspective) and as a way for the developers to see which portals exists and how to integrate them into their application using ASHPD.

Dependencies

~7–16MB
~323K SLoC