diff --git a/komorebi-bar/src/komorebi.rs b/komorebi-bar/src/komorebi.rs index 963d5f50..c3467e55 100644 --- a/komorebi-bar/src/komorebi.rs +++ b/komorebi-bar/src/komorebi.rs @@ -128,13 +128,15 @@ impl BarWidget for Komorebi { if self.workspaces.enable { let mut update = None; - for (i, ws) in komorebi_notification_state.workspaces.iter().enumerate() { - if ui - .add(SelectableLabel::new( - komorebi_notification_state.selected_workspace.eq(ws), - ws.to_string(), - )) - .clicked() + for (i, (ws, should_show)) in komorebi_notification_state.workspaces.iter().enumerate() + { + if *should_show + && ui + .add(SelectableLabel::new( + komorebi_notification_state.selected_workspace.eq(ws), + ws.to_string(), + )) + .clicked() { update = Some(ws.to_string()); let mut proceed = true; @@ -400,7 +402,7 @@ fn img_to_texture(ctx: &Context, rgba_image: &RgbaImage) -> TextureHandle { #[derive(Clone, Debug)] pub struct KomorebiNotificationState { - pub workspaces: Vec, + pub workspaces: Vec<(String, bool)>, pub selected_workspace: String, pub focused_container_information: (Vec, Vec>, usize), pub layout: KomorebiLayout, @@ -485,16 +487,16 @@ impl KomorebiNotificationState { .unwrap_or_else(|| format!("{}", focused_workspace_idx + 1)); for (i, ws) in monitor.workspaces().iter().enumerate() { - let should_add = if self.hide_empty_workspaces { + let should_show = if self.hide_empty_workspaces { focused_workspace_idx == i || !ws.containers().is_empty() } else { true }; - if should_add { - workspaces - .push(ws.name().to_owned().unwrap_or_else(|| format!("{}", i + 1))); - } + workspaces.push(( + ws.name().to_owned().unwrap_or_else(|| format!("{}", i + 1)), + should_show, + )); } self.workspaces = workspaces;