From 558576911fb14ee0d67b09764479047494da7c5c Mon Sep 17 00:00:00 2001 From: 0xk1f0 Date: Sat, 1 Apr 2023 23:39:11 +0200 Subject: [PATCH] handle force flag correctly and naming --- src/outputs.rs | 2 +- src/splitter.rs | 32 +++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/outputs.rs b/src/outputs.rs index c9735e3..397cabd 100644 --- a/src/outputs.rs +++ b/src/outputs.rs @@ -21,7 +21,7 @@ struct ListOutputs { } impl Monitor { - pub fn new_from_hyprland() -> Result, String> { + pub fn new() -> Result, String> { // new vector for result imgs let mut result: Vec = Vec::new(); diff --git a/src/splitter.rs b/src/splitter.rs index 22c3c35..14d28c0 100644 --- a/src/splitter.rs +++ b/src/splitter.rs @@ -38,7 +38,7 @@ impl Splitter { )?; // fetch monitors - self.monitors = Monitor::new_from_hyprland().map_err( + self.monitors = Monitor::new().map_err( |err| err.to_string() )?; @@ -76,12 +76,9 @@ impl Splitter { //check wpaper config hash if ! config.force_resplit { - if let true = wpaperd.check_existing().map_err( + if let false = wpaperd.check_existing().map_err( |err| err.to_string() )? { - // match, don't rebuild - } - else { // we need to rebuild self.result_papers = self.perform_split( img, @@ -91,17 +88,30 @@ impl Splitter { |err| err.to_string() )?; - // also config wpaperd.build(&self.result_papers).map_err( |err| err.to_string() )?; - - // finally, run wrapper - cmd_wrapper().map_err( - |err| err.to_string() - )?; } + } else { + // we need to rebuild + self.result_papers = self.perform_split( + img, + config, + format!("{}/.cache/",var("HOME").unwrap()) + ).map_err( + |err| err.to_string() + )?; + + wpaperd.build(&self.result_papers).map_err( + |err| err.to_string() + )?; } + + // finally, run wrapper + cmd_wrapper().map_err( + |err| err.to_string() + )?; + // no wpaperd to worry about, just split } else { // just split