Expand description
Open a file or a directory.
Examples
Open a file
use ashpd::desktop::open_uri;
use ashpd::WindowIdentifier;
use std::fs::File;
async fn run() -> ashpd::Result<()> {
let file = File::open("/home/bilelmoussaoui/adwaita-day.jpg").unwrap();
open_uri::open_file(&WindowIdentifier::default(), &file, false, true).await?;
Ok(())
}
Or by using the Proxy directly
use ashpd::desktop::open_uri::OpenURIProxy;
use ashpd::WindowIdentifier;
use std::fs::File;
async fn run() -> ashpd::Result<()> {
let file = File::open("/home/bilelmoussaoui/Downloads/adwaita-night.jpg").unwrap();
let connection = zbus::Connection::session().await?;
let proxy = OpenURIProxy::new(&connection).await?;
proxy.open_file(&WindowIdentifier::default(), &file, false, true).await?;
Ok(())
}
Open a directory
use ashpd::desktop::open_uri;
use ashpd::WindowIdentifier;
use std::fs::File;
async fn run() -> ashpd::Result<()> {
let directory = File::open("/home/bilelmoussaoui/Downloads").unwrap();
open_uri::open_directory(&WindowIdentifier::default(), &directory).await?;
Ok(())
}
Or by using the Proxy directly
use ashpd::desktop::open_uri::OpenURIProxy;
use ashpd::WindowIdentifier;
use std::fs::File;
async fn run() -> ashpd::Result<()> {
let directory = File::open("/home/bilelmoussaoui/Downloads").unwrap();
let connection = zbus::Connection::session().await?;
let proxy = OpenURIProxy::new(&connection).await?;
proxy.open_directory(&WindowIdentifier::default(), &directory).await?;
Ok(())
}
Open a file from a URI
use ashpd::desktop::open_uri;
use ashpd::WindowIdentifier;
async fn run() -> ashpd::Result<()> {
let uri = "file:///home/bilelmoussaoui/Downloads/adwaita-night.jpg";
open_uri::open_uri(&WindowIdentifier::default(), uri, false, true).await?;
Ok(())
}
Or by using the Proxy directly
use ashpd::desktop::open_uri::OpenURIProxy;
use ashpd::WindowIdentifier;
async fn run() -> ashpd::Result<()> {
let connection = zbus::Connection::session().await?;
let proxy = OpenURIProxy::new(&connection).await?;
let uri = "https://github.com/bilelmoussaoui/ashpd";
proxy.open_uri(&WindowIdentifier::default(), uri, false, true).await?;
Ok(())
}
Structs
The interface lets sandboxed applications open URIs (e.g. a http: link to the applications homepage) under the control of the user.
Functions
A handy wrapper around OpenURIProxy::open_directory
.
A handy wrapper around OpenURIProxy::open_file
.
A handy wrapper around OpenURIProxy::open_uri
.