| Crates.io | wallpape-rs |
| lib.rs | wallpape-rs |
| version | 2.0.0 |
| created_at | 2022-11-22 18:40:52.950129+00 |
| updated_at | 2022-11-23 11:12:46.296483+00 |
| description | Gets and sets the desktop wallpaper/background. |
| homepage | |
| repository | https://github.com/johannesibk/wallpape.rs |
| max_upload_size | |
| id | 721064 |
| size | 22,756 |
This Rust library gets and sets the desktop wallpaper/background.
The supported desktops are:
use wallpape_rs as 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::set_from_path("/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:
[dependencies]
wallpape-rs = { version = "1.0.0", features = ["from_url"] }
Then, on your main.rs:
use wallpape_rs as wallpaper;
fn main() {
// Returns the wallpaper of the current desktop.
println!("{:?}", wallpaper::get());
// Sets the wallpaper for the current desktop from a URL.
wallpaper::set_from_url("https://source.unsplash.com/random").unwrap();
// Returns the wallpaper of the current desktop.
println!("{:?}", wallpaper::get());
}