This Rust library gets and sets the desktop wallpaper/background.
The supported desktops are:
```rust use wallpaper;
fn main() { // Returns the wallpaper of the current desktop. println!("{:?}", wallpaper::get()); // Sets the wallpaper for the current desktop from a file path. wallpaper::setfrompath("/usr/share/backgrounds/gnome/adwaita-day.png").unwrap(); // Sets the wallpaper style. wallpaper::set_mode(wallpaper::Mode::Crop).unwrap(); // Returns the wallpaper of the current desktop. println!("{:?}", wallpaper::get()); } ```
If you want to set an image as background via an URL, make sure you activated the from_url
feature of the wallpaper crate on Cargo.toml:
toml
[dependencies]
wallpaper = { version = "3", features = ["from_url"] }
Then, on your main.rs:
```rust use wallpaper;
fn main() { // Returns the wallpaper of the current desktop. println!("{:?}", wallpaper::get()); // Sets the wallpaper for the current desktop from a URL. wallpaper::setfromurl("https://source.unsplash.com/random").unwrap(); // Returns the wallpaper of the current desktop. println!("{:?}", wallpaper::get()); } ```