From 799e98655ec23ec12146a42d7fcd81a74f55fe3f Mon Sep 17 00:00:00 2001 From: KhomyaK_HTF Date: Tue, 28 Mar 2023 10:55:27 +0200 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D0=BB(=D0=B0)=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20'src?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main.rs diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..4ebc421 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,33 @@ +use std::time::{Duration, Instant}; +use std::thread::sleep; +use std::process::Command; +use std::fs; +use download_rs::async_download::Download; +use wallpaper; + +fn main() { + fs::create_dir_all("/tmp/i3-unspl").unwrap(); + + let _hd = "https://source.unsplash.com/random/1280x720/?backgrounds/"; + let _fhd = "https://source.unsplash.com/random/1920x1080/?backgrounds/"; + let _thd = "https://source.unsplash.com/random/3440x1440/?backgrounds/"; + let _uhd = "https://source.unsplash.com/random/4096x2160/?backgrounds/"; + + let name = "/tmp/i3-unspl/bg.png"; + + loop { + fs::remove_file("/tmp/i3-unspl/bg.png"); + + let down = Download::new(_thd, Some(name),None); + match down.download() { + Ok(_) => println!("Изображение успешно скачано!"), + Err(_e) => println!("Не удалось скачать изображение :("), + } + + wallpaper::set_from_path("/tmp/i3-unspl/bg.png"); + wallpaper::set_mode(wallpaper::Mode::Fit); + + let _a = Instant::now(); + sleep(Duration::new(3600, 3600)); + } +}