Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bilelmoussaoui/ashpd
A Rust wrapper around XDG portals DBus interfaces
https://github.com/bilelmoussaoui/ashpd
flatpak libportal portals rust wrapper xdg zbus
Last synced: 7 days ago
JSON representation
A Rust wrapper around XDG portals DBus interfaces
- Host: GitHub
- URL: https://github.com/bilelmoussaoui/ashpd
- Owner: bilelmoussaoui
- License: mit
- Created: 2020-08-22T11:49:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-25T23:31:04.000Z (9 months ago)
- Last Synced: 2024-04-14T12:48:04.270Z (9 months ago)
- Topics: flatpak, libportal, portals, rust, wrapper, xdg, zbus
- Language: Rust
- Homepage: https://bilelmoussaoui.github.io/ashpd/ashpd/
- Size: 2.15 MB
- Stars: 214
- Watchers: 4
- Forks: 39
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ASHPD
[![docs](https://docs.rs/ashpd/badge.svg)](https://docs.rs/ashpd/) [![crates.io](https://img.shields.io/crates/v/ashpd)](https://crates.io/crates/ashpd) ![CI](https://github.com/bilelmoussaoui/ashpd/workflows/CI/badge.svg)
ASHPD, acronym of Aperture Science Handheld Portal Device is a Rust & [zbus](https://gitlab.freedesktop.org/dbus/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](https://flatpak.github.io/xdg-desktop-portal/docs/).
It provides an alternative to the C library [https://github.com/flatpak/libportal](https://github.com/flatpak/libportal)## Examples
Ask the compositor to pick a color
```rust,no_run
use ashpd::desktop::Color;async fn run() -> ashpd::Result<()> {
let color = Color::pick().send().await?.response()?;
println!("({}, {}, {})", color.red(), color.green(), color.blue());
Ok(())
}
```Start a PipeWire stream from the user's camera
```rust,no_run
use ashpd::desktop::camera::Camera;pub async fn run() -> ashpd::Result<()> {
let camera = Camera::new().await?;
if camera.is_present().await? {
camera.request_access().await?;
let remote_fd = camera.open_pipe_wire_remote().await?;
// pass the remote fd to GStreamer for example
}
Ok(())
}
```## Optional features
| Feature | Description | Default |
| --- | ----------- | ------- |
| tracing | Record various debug information using the `tracing` library | No |
| tokio | Enable tokio runtime on zbus dependency | Yes |
| async-std | Enable the use of the async-std runtime | No |
| backend | *unstable* Enables APIs useful for writing portals implementations | No |
| glib | Make all the enums derive `glib::Enum`. Flags are not supported yet | No |
| gtk4 | Implement `From` for [`gdk4::RGBA`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gdk4/struct.RGBA.html) Provides `WindowIdentifier::from_native` that takes a [`IsA`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.Native.html) | No |
| gtk4_wayland |Provides `WindowIdentifier::from_native` that takes a [`IsA`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.Native.html) with Wayland backend support only | No |
| gtk4_x11 |Provides `WindowIdentifier::from_native` that takes a [`IsA`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.Native.html) with X11 backend support only | No |
| pipewire | Provides `ashpd::desktop::camera::pipewire_streams` that helps you retrieve the various camera streams associated with the retrieved file descriptor| No |
| raw_handle | Provides `WindowIdentifier::from_raw_handle` and `WindowIdentifier::as_raw_handle` for [raw-window-handle](https://lib.rs/crates/raw-window-handle) crate | No |
| wayland | Provides `WindowIdentifier::from_wayland` for [wayland-client](https://lib.rs/crates/wayland-client) crate | No |
| backend | Enables portal backend implementation supoport | No |## Demo
The library comes with a [demo](./ashpd-demo) built using the [GTK 4 Rust bindings](https://gtk-rs.org/gtk4-rs) 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.