wallpaper 3.2.0

Gets and sets the desktop wallpaper/background.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use crate::Result;
use std::fs::File;

pub fn download_image(url: &str) -> Result<String> {
    let cache_dir = dirs::cache_dir().ok_or("no cache dir")?;
    let file_path = cache_dir.join("wallpaper");

    let mut file = File::create(&file_path)?;
    reqwest::blocking::get(url)?.copy_to(&mut file)?;

    Ok(file_path.to_str().to_owned().ok_or("no file path")?.into())
}