logo
Expand description

Set a wallpaper on lockscreen, background or both.

Examples

Sets a wallpaper from a file:

 use ashpd::desktop::wallpaper::{self, SetOn};
 use ashpd::WindowIdentifier;
 use std::fs::File;

 async fn run() -> ashpd::Result<()> {
     let file = File::open("/home/bilelmoussaoui/adwaita-day.jpg").unwrap();
     wallpaper::set_from_file(&WindowIdentifier::default(), &file, true, SetOn::Both).await?;
     Ok(())
 }

Or by using the Proxy directly

use ashpd::desktop::wallpaper::{SetOn, WallpaperProxy};
use ashpd::WindowIdentifier;
use std::fs::File;

async fn run() -> ashpd::Result<()> {
    let wallpaper = File::open("/home/bilelmoussaoui/adwaita-day.jpg").unwrap();

    let connection = zbus::Connection::session().await?;
    let proxy = WallpaperProxy::new(&connection).await?;
    proxy
        .set_wallpaper_file(&WindowIdentifier::default(), &wallpaper, true, SetOn::Both)
        .await?;
    Ok(())
}

Sets a wallpaper from a URI:

 use ashpd::desktop::wallpaper::{self, SetOn};
 use ashpd::WindowIdentifier;

 async fn run() -> ashpd::Result<()> {
     let uri = "file:///home/bilelmoussaoui/Downloads/adwaita-night.jpg";
     wallpaper::set_from_uri(&WindowIdentifier::default(), &uri, true, SetOn::Both).await?;
     Ok(())
 }

Or by using the Proxy directly

use ashpd::desktop::wallpaper::{SetOn, WallpaperProxy};
use ashpd::WindowIdentifier;

async fn run() -> ashpd::Result<()> {
    let connection = zbus::Connection::session().await?;
    let proxy = WallpaperProxy::new(&connection).await?;
    proxy
        .set_wallpaper_uri(
            &WindowIdentifier::default(),
            "file:///home/bilelmoussaoui/Downloads/adwaita-night.jpg",
            true,
            SetOn::Both,
        )
        .await?;
    Ok(())
}

Structs

The interface lets sandboxed applications set the user’s desktop background picture.

Enums

Where to set the wallpaper on.

Functions