From 5bf2f8934a247336bf6cad7b12a8238ce1b6d404 Mon Sep 17 00:00:00 2001 From: nyx Date: Fri, 18 Oct 2024 02:35:00 -0400 Subject: [PATCH] fix problems with restoring --- src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index fd0d8ee..1ff4383 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,9 +31,6 @@ struct Cli { fn main() { let cli = Cli::parse(); - let rt = Runtime::new().expect("Failed to create Tokio runtime"); - let _guard = rt.enter(); - if cli.restore { restore_last_wallpaper(); return; @@ -271,7 +268,16 @@ async fn drop_all_wallpapers(backend: WallpaperBackend) { fn restore_last_wallpaper() { if let Some(last_wallpaper) = gui::load_last_wallpaper() { - set_wallpaper(last_wallpaper); + let rt = Runtime::new().expect("Failed to create Tokio runtime"); + match rt.block_on(set_wallpaper_internal(&last_wallpaper)) { + Ok(_) => { + println!("Wallpaper restored successfully"); + gui::save_last_wallpaper(&last_wallpaper); + } + Err(e) => { + eprintln!("Error restoring wallpaper: {}", e); + } + } } else { eprintln!("No last wallpaper found to restore"); }