Crate ashpd[−][src]
Expand description
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; async fn run() -> Result<(), ashpd::Error> { let connection = zbus::azync::Connection::new_session().await?; let proxy = ScreenshotProxy::new(&connection).await?; let color = proxy.pick_color(Default::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() -> Result<(), ashpd::Error> { let connection = zbus::azync::Connection::new_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(()) }
For a tour of the various portals, see the ASHPD demo application.
Optional features
Feature | Description |
---|---|
feature_gtk3 | Implement From<Color> for gdk3::RGBA |
Provides WindowIdentifier::from_window | |
feature_gtk4 | Implement From<Color> for gdk4::RGBA |
Provides WindowIdentifier::from_window |
Re-exports
pub use enumflags2; | |
pub use zbus; | |
pub use zvariant; |
Modules
desktop | Interact with the user’s desktop such as taking a screenshot, setting a background or querying the user’s location. |
documents | Interact with the documents store or transfer files across apps. |
flatpak | Spawn commands outside the sandbox or monitor if the running application has received an update & install it. |
Enums
Error | The error type for ashpd. |
WindowIdentifier | Most portals interact with the user by showing dialogs.
These dialogs should generally be placed on top of the application window
that triggered them. To arrange this, the compositor needs to know about the
application window. Many portal requests expect a |
Functions
is_sandboxed | Check whether the application is running inside a sandbox. |