mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-05-02 08:54:18 +02:00
fix(wm): add regex ws rule matching support
This commit ensures that enforce_workspace_rules() will try to match exact exe names, classes and titles, and then against any potential regexes that may have been used as keys to index matching rules against the current window's exe, title and class. Support for other matchers isn't implemented yet. Not sure it's worth adding while using a HashMap to store the workspace rules, probably need to rethink the data structure first.
This commit is contained in:
@@ -16,6 +16,7 @@ use hotwatch::notify::ErrorKind as NotifyErrorKind;
|
|||||||
use hotwatch::EventKind;
|
use hotwatch::EventKind;
|
||||||
use hotwatch::Hotwatch;
|
use hotwatch::Hotwatch;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use regex::Regex;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
@@ -600,11 +601,36 @@ impl WindowManager {
|
|||||||
// And all the visible windows (at the top of a container)
|
// And all the visible windows (at the top of a container)
|
||||||
for window in workspace.visible_windows().into_iter().flatten() {
|
for window in workspace.visible_windows().into_iter().flatten() {
|
||||||
let mut already_moved_window_handles = self.already_moved_window_handles.lock();
|
let mut already_moved_window_handles = self.already_moved_window_handles.lock();
|
||||||
|
let exe_name = window.exe()?;
|
||||||
|
let title = window.title()?;
|
||||||
|
let class = window.class()?;
|
||||||
|
|
||||||
let mut found_workspace_rule = workspace_rules.get(&window.exe()?);
|
let mut found_workspace_rule = workspace_rules.get(&exe_name);
|
||||||
|
|
||||||
if found_workspace_rule.is_none() {
|
if found_workspace_rule.is_none() {
|
||||||
found_workspace_rule = workspace_rules.get(&window.title()?);
|
found_workspace_rule = workspace_rules.get(&title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if found_workspace_rule.is_none() {
|
||||||
|
found_workspace_rule = workspace_rules.get(&class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if found_workspace_rule.is_none() {
|
||||||
|
for (k, v) in workspace_rules.iter() {
|
||||||
|
if let Ok(re) = Regex::new(k) {
|
||||||
|
if re.is_match(&exe_name) {
|
||||||
|
found_workspace_rule = Some(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
if re.is_match(&title) {
|
||||||
|
found_workspace_rule = Some(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
if re.is_match(&class) {
|
||||||
|
found_workspace_rule = Some(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the executable names or titles of any of those windows are in our rules map
|
// If the executable names or titles of any of those windows are in our rules map
|
||||||
|
|||||||
Reference in New Issue
Block a user