#desktop #wallpaper #background

wallpaper

Gets and sets the desktop wallpaper/background

8 stable releases

3.2.0 Jul 9, 2021
3.1.1 Jul 6, 2021
3.1.0 Jun 30, 2021
2.0.1 Jan 31, 2019
1.0.0 Jul 18, 2018

#6 in #background

Download history 127/week @ 2022-10-12 179/week @ 2022-10-19 399/week @ 2022-10-26 322/week @ 2022-11-02 287/week @ 2022-11-09 310/week @ 2022-11-16 266/week @ 2022-11-23 225/week @ 2022-11-30 256/week @ 2022-12-07 190/week @ 2022-12-14 167/week @ 2022-12-21 170/week @ 2022-12-28 77/week @ 2023-01-04 169/week @ 2023-01-11 258/week @ 2023-01-18 227/week @ 2023-01-25

813 downloads per month
Used in 7 crates (6 directly)

Unlicense

20KB
528 lines

wallpaper crate docs

This Rust library gets and sets the desktop wallpaper/background.

The supported desktops are:

  • Windows
  • macOS
  • GNOME
  • KDE
  • Cinnamon
  • Unity
  • Budgie
  • XFCE
  • LXDE
  • MATE
  • Deepin
  • Most Wayland compositors (set only, requires swaybg)
  • i3 (set only, requires feh)

Examples

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::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]
wallpaper = { version = "3", features = ["from_url"] }

Then, on your main.rs:

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::set_from_url("https://source.unsplash.com/random").unwrap();
    // Returns the wallpaper of the current desktop.
    println!("{:?}", wallpaper::get());
}

Dependencies

~0–7.5MB
~134K SLoC