3 stable releases

2.0.0 Nov 23, 2022
1.0.1 Nov 22, 2022

#23 in #sets

Download history 4/week @ 2024-01-02 43/week @ 2024-01-30 3/week @ 2024-02-13 13/week @ 2024-02-20 82/week @ 2024-02-27 10/week @ 2024-03-05 15/week @ 2024-03-12 11/week @ 2024-03-19 58/week @ 2024-03-26 63/week @ 2024-04-02 7/week @ 2024-04-09 82/week @ 2024-04-16

212 downloads per month
Used in timewall

Unlicense

22KB
531 lines

wallpape.rs 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 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());
}

Dependencies

~0.3–43MB
~597K SLoC