diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-23 14:38:07 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-23 15:45:44 +0400 |
| commit | b7ed2fb82a19afe73e3e51ef2331ac6ad9c175a0 (patch) | |
| tree | 8757c39889958bd6a8f87ac9089d8e5a7fd43a76 /niri-config | |
| parent | f3f02aca2058dd7adc4d75707ded2b5d8887a258 (diff) | |
| download | niri-b7ed2fb82a19afe73e3e51ef2331ac6ad9c175a0.tar.gz niri-b7ed2fb82a19afe73e3e51ef2331ac6ad9c175a0.tar.bz2 niri-b7ed2fb82a19afe73e3e51ef2331ac6ad9c175a0.zip | |
Add is-active window rule matcher
Diffstat (limited to 'niri-config')
| -rw-r--r-- | niri-config/src/lib.rs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index 4e43d795..01cdba70 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -699,17 +699,21 @@ pub struct WindowRule { pub draw_border_with_background: Option<bool>, } +// Remember to update the PartialEq impl when adding fields! #[derive(knuffel::Decode, Debug, Default, Clone)] pub struct Match { #[knuffel(property, str)] pub app_id: Option<Regex>, #[knuffel(property, str)] pub title: Option<Regex>, + #[knuffel(property)] + pub is_active: Option<bool>, } impl PartialEq for Match { fn eq(&self, other: &Self) -> bool { - self.app_id.as_ref().map(Regex::as_str) == other.app_id.as_ref().map(Regex::as_str) + self.is_active == other.is_active + && self.app_id.as_ref().map(Regex::as_str) == other.app_id.as_ref().map(Regex::as_str) && self.title.as_ref().map(Regex::as_str) == other.title.as_ref().map(Regex::as_str) } } @@ -1762,6 +1766,7 @@ mod tests { window-rule { match app-id=".*alacritty" exclude title="~" + exclude is-active=true open-on-output "eDP-1" open-maximized true @@ -1947,11 +1952,20 @@ mod tests { matches: vec![Match { app_id: Some(Regex::new(".*alacritty").unwrap()), title: None, + is_active: None, }], - excludes: vec![Match { - app_id: None, - title: Some(Regex::new("~").unwrap()), - }], + excludes: vec![ + Match { + app_id: None, + title: Some(Regex::new("~").unwrap()), + is_active: None, + }, + Match { + app_id: None, + title: None, + is_active: Some(true), + }, + ], open_on_output: Some("eDP-1".to_owned()), open_maximized: Some(true), open_fullscreen: Some(false), |
