From 82f8ce2fd1d0dbd60a72eee0e4ff7395c7dfdbc8 Mon Sep 17 00:00:00 2001 From: Roger Roger Date: Sat, 18 Dec 2021 11:57:55 +0100 Subject: [PATCH] Wait for children to die --- src/daemon/state.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/daemon/state.rs b/src/daemon/state.rs index 85e486c..5cba8d7 100644 --- a/src/daemon/state.rs +++ b/src/daemon/state.rs @@ -65,25 +65,28 @@ impl State { } pub fn update(&self) { - if let Action::Static(path) = &self.action { + let path = if let Action::Static(path) = &self.action { if let Some(path) = path { if std::path::Path::new(path).exists() { - info!("Changing background to {:?}", path); - Command::new("feh") - .arg("--bg-scale") - .arg(path) - .spawn() - .unwrap(); + Some(path) + } else { + None } + } else { + None } } else { let file = self.images.get(self.index).unwrap(); - info!("Changing background to {:?}", file); - Command::new("feh") + Some(file) + }; + if let Some(path) = path { + info!("Changing background to {:?}", path); + let mut process = Command::new("feh") .arg("--bg-scale") - .arg(&file) + .arg(path) .spawn() .unwrap(); + process.wait().unwrap(); } } -- 2.51.2