Module ashpd::desktop::dynamic_launcher
source · Expand description
Install launchers like Web Application from your browser or Steam.
§Examples
use std::io::Read;
use ashpd::{
desktop::{
dynamic_launcher::{DynamicLauncherProxy, PrepareInstallOptions},
Icon,
},
WindowIdentifier,
};
async fn run() -> ashpd::Result<()> {
let proxy = DynamicLauncherProxy::new().await?;
let filename = "/home/bilalelmoussaoui/Projects/ashpd/ashpd-demo/data/icons/com.belmoussaoui.ashpd.demo.svg";
let mut f = std::fs::File::open(&filename).expect("no file found");
let metadata = std::fs::metadata(&filename).expect("unable to read metadata");
let mut buffer = vec![0; metadata.len() as usize];
f.read(&mut buffer).expect("buffer overflow");
let icon = Icon::Bytes(buffer);
let response = proxy
.prepare_install(
&WindowIdentifier::default(),
"SomeApp",
icon,
PrepareInstallOptions::default()
)
.await?
.response()?;
let token = response.token();
// Name and Icon will be overwritten from what we provided above
// Exec will be overridden to call `flatpak run our-app` if the application is sandboxed
let desktop_entry = r#"
[Desktop Entry]
Comment=My Web App
Type=Application
"#;
proxy
.install(&token, "some_file.desktop", desktop_entry)
.await?;
proxy.uninstall("some_file.desktop").await?;
Ok(())
}
Structs§
- The interface lets sandboxed applications install launchers like Web Application from your browser or Steam.
- Options to pass to
DynamicLauncherProxy::launch
- The icon of the launcher.
- Options to pass to
DynamicLauncherProxy::prepare_install
- A response of
DynamicLauncherProxy::prepare_install
- Wrong type of
crate::desktop::Icon
was used.
Enums§
- The icon format.
- The type of the launcher.