BrainBlasted/ashpd

A Rust wrapper around XDG portals DBus interfaces.

★ 0Forks 0GitHub ↗Compare

Project website ↗

README

ASHPD

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

use ashpd::desktop::screenshot::{Color, PickColorOptions, ScreenshotProxy};
use ashpd::{RequestProxy, Response, WindowIdentifier};
use zbus::fdo::Result;

fn main() -> Result<()> {
    let connection = zbus::Connection::new_session()?;
    let proxy = ScreenshotProxy::new(&connection)?;
    
    let request_handle = proxy.pick_color(
            WindowIdentifier::default(),
            PickColorOptions::default()
    )?;
   
    let request = RequestProxy::new(&connection, &request_handle)?;
    request.on_response(|response: Response<Color>| {
        if let Ok(color) = response {
            println!("({}, {}, {})", color.red(), color.green(), color.blue());
        }
    })?;
   
    Ok(())
}

Optional features

Feature Description
feature_gtk Implement Into<gdk::RGBA> for Color
Implement From<gtk::Window> for WindowIdentifier

Contributors

bilelmoussaouiHofer-Julian

Issues