diff --git a/komorebi-core/src/config_generation.rs b/komorebi-core/src/config_generation.rs index b02a683a..90cc1e79 100644 --- a/komorebi-core/src/config_generation.rs +++ b/komorebi-core/src/config_generation.rs @@ -75,6 +75,10 @@ pub enum MatchingStrategy { EndsWith, Contains, Regex, + DoesNotEndWith, + DoesNotStartWith, + DoesNotEqual, + DoesNotContain, } #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 846404a7..3d3c3be4 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -548,7 +548,6 @@ pub fn should_act( should_act } -#[allow(clippy::cognitive_complexity, clippy::too_many_lines)] pub fn should_act_individual( title: &str, exe_name: &str, @@ -607,6 +606,28 @@ pub fn should_act_individual( } } }, + Some(MatchingStrategy::DoesNotEqual) => match identifier.kind { + ApplicationIdentifier::Title => { + if !title.eq(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + if !class.eq(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Exe => { + if !exe_name.eq(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if !path.eq(&identifier.id) { + should_act = true; + } + } + }, Some(MatchingStrategy::StartsWith) => match identifier.kind { ApplicationIdentifier::Title => { if title.starts_with(&identifier.id) { @@ -629,6 +650,28 @@ pub fn should_act_individual( } } }, + Some(MatchingStrategy::DoesNotStartWith) => match identifier.kind { + ApplicationIdentifier::Title => { + if !title.starts_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + if !class.starts_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Exe => { + if !exe_name.starts_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if !path.starts_with(&identifier.id) { + should_act = true; + } + } + }, Some(MatchingStrategy::EndsWith) => match identifier.kind { ApplicationIdentifier::Title => { if title.ends_with(&identifier.id) { @@ -651,6 +694,28 @@ pub fn should_act_individual( } } }, + Some(MatchingStrategy::DoesNotEndWith) => match identifier.kind { + ApplicationIdentifier::Title => { + if !title.ends_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + if !class.ends_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Exe => { + if !exe_name.ends_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if !path.ends_with(&identifier.id) { + should_act = true; + } + } + }, Some(MatchingStrategy::Contains) => match identifier.kind { ApplicationIdentifier::Title => { if title.contains(&identifier.id) { @@ -673,6 +738,28 @@ pub fn should_act_individual( } } }, + Some(MatchingStrategy::DoesNotContain) => match identifier.kind { + ApplicationIdentifier::Title => { + if !title.contains(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + if !class.contains(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Exe => { + if !exe_name.contains(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if !path.contains(&identifier.id) { + should_act = true; + } + } + }, Some(MatchingStrategy::Regex) => match identifier.kind { ApplicationIdentifier::Title => { if let Some(re) = regex_identifiers.get(&identifier.id) {