Skip to content

Commit

Permalink
fix problems with restoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nnyyxxxx committed Oct 18, 2024
1 parent 4e70c3d commit 5bf2f89
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit 5bf2f89

Please sign in to comment.