wallpaper_rs

Trait Desktop

Source
pub trait Desktop: Sized {
    // Required methods
    fn new() -> Result<Self, Box<dyn Error>>;
    fn set_wallpaper(&self, path: &str) -> Result<(), Box<dyn Error>>;
    fn get_wallpaper(&self) -> Result<PathBuf, Box<dyn Error>>;
}
Expand description

A trait implemented by desktop environments. It allows setting or getting a wallpaper.

On platforms where only one desktop environment exists (e.g. Windows, macOS), this can be implemented with a zero-sized type. On Linux, it is an enum.

Required Methods§

Source

fn new() -> Result<Self, Box<dyn Error>>

Creates a new instance of this desktop.

On Linux, this function detects the desktop environment. It panics if the desktop environment is unsupported. It returns an error if the desktop environment couldn’t be determined (i.e., the XDG_CURRENT_DESKTOP environment variable isn’t set).

Source

fn set_wallpaper(&self, path: &str) -> Result<(), Box<dyn Error>>

Sets the wallpaper for all computer screens to the specified file path.

The file should be an image file supported by the patform, e.g. a JPEG.

Source

fn get_wallpaper(&self) -> Result<PathBuf, Box<dyn Error>>

Returns the file path to the image used as the wallpaper.

If different screens have different wallpapers, only one of them is returned; the behavior depends on the platform and desktop environment.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§