GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: add `not_equals` and `not_regex` match types (#798)
Raul20265d5d4e1cf92
diff --git a/packages/wm/src/user_config.rs b/packages/wm/src/user_config.rsindex e0dbc2f6..3a156f60 100644--- a/packages/wm/src/user_config.rs+++ b/packages/wm/src/user_config.rs@@ -597,6 +597,8 @@ pub enum MatchType {Equals { equals: String },Includes { includes: String },Regex { regex: String },+ NotEquals { not_equals: String },+ NotRegex { not_regex: String },}impl MatchType {@@ -608,6 +610,10 @@ impl MatchType {MatchType::Regex { regex } => regex::Regex::new(regex).map(|re| re.is_match(value)).unwrap_or(false),+ MatchType::NotEquals { not_equals } => value != not_equals,+ MatchType::NotRegex { not_regex } => regex::Regex::new(not_regex)+ .map(|re| !re.is_match(value))+ .unwrap_or(false),}}}diff --git a/packages/wm/src/wm_state.rs b/packages/wm/src/wm_state.rsindex 88599a31..45f0c865 100644--- a/packages/wm/src/wm_state.rs+++ b/packages/wm/src/wm_state.rs@@ -326,7 +326,9 @@ impl WmState {.context("Failed to get index of given workspace.")?;let prev_active_workspace = active_workspaces.get(- origin_index.checked_sub(1).unwrap_or(active_workspaces.len() - 1),+ origin_index+ .checked_sub(1)+ .unwrap_or(active_workspaces.len() - 1),);(@@ -335,42 +337,48 @@ impl WmState {)}WorkspaceTarget::Next => {- let workspaces = &config.value.workspaces;+ let workspaces = &config.value.workspaces;let origin_name = origin_workspace.config().name.clone();- let origin_index = workspaces.iter()- .position(|workspace| workspace.name == origin_name)- .context("Failed to get index of given workspace.")?;-+ let origin_index = workspaces+ .iter()+ .position(|workspace| workspace.name == origin_name)+ .context("Failed to get index of given workspace.")?;+let next_workspace_config = workspaces- .get(origin_index + 1)- .or_else(|| workspaces.first());-- let next_workspace_name = next_workspace_config.map(|config| config.name.clone());+ .get(origin_index + 1)+ .or_else(|| workspaces.first());++ let next_workspace_name =+ next_workspace_config.map(|config| config.name.clone());+let next_workspace = next_workspace_name- .as_ref()- .and_then(|name| self.workspace_by_name(name));-+ .as_ref()+ .and_then(|name| self.workspace_by_name(name));+(next_workspace_name, next_workspace)}WorkspaceTarget::Previous => {- let workspaces = &config.value.workspaces;+ let workspaces = &config.value.workspaces;let origin_name = origin_workspace.config().name.clone();- let origin_index = workspaces.iter()- .position(|workspace| workspace.name == origin_name)- .context("Failed to get index of given workspace.")?;-+ let origin_index = workspaces+ .iter()+ .position(|workspace| workspace.name == origin_name)+ .context("Failed to get index of given workspace.")?;+let previous_workspace_config = workspaces.get(- origin_index.checked_sub(1).unwrap_or(workspaces.len() - 1),- );-- let previous_workspace_name = previous_workspace_config.map(|config| config.name.clone());+ origin_index.checked_sub(1).unwrap_or(workspaces.len() - 1),+ );++ let previous_workspace_name =+ previous_workspace_config.map(|config| config.name.clone());+let previous_workspace = previous_workspace_name- .as_ref()- .and_then(|name| self.workspace_by_name(name));-+ .as_ref()+ .and_then(|name| self.workspace_by_name(name));+(previous_workspace_name, previous_workspace)}-+WorkspaceTarget::Direction(direction) => {let origin_monitor =origin_workspace.monitor().context("No focused monitor.")?;