From 449eaa6ed20784fbc8343ad537ed1dd4e9aed47e Mon Sep 17 00:00:00 2001 From: FieldofClay <7278759+FieldofClay@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:12:33 +1000 Subject: [PATCH] correctly handle workspaces with no clients in advanced mode, fixes #13 --- src/main.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0c07108..4004b15 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,17 +72,17 @@ fn print_all() -> Result<()> { HyprError::NotOkDispatch("No active workspace found".to_string()) })?; - let client = Clients::get()? - .find(|c| c.address == workspace.last_window) - .ok_or_else(|| { - log::warn!("Unable to get last window"); - HyprError::NotOkDispatch("Unable to get last window".to_string()) - })?; + let client = Clients::get()?.find(|c| c.address == workspace.last_window); + + let (title, initial_title) = match client { + Some(c) => (c.title, c.initial_title), + None => (String::new(), String::new()), + }; let mc: MonitorCustom = MonitorCustom { name: monitor.name, - title: client.title, - initial_title: client.initial_title, + title: title, + initial_title: initial_title, }; out_monitors.push(mc); }