kernc / xsuspender

:eyes: :computer: :zzz: :battery: Save battery by auto-suspending unfocused X11 applications.

Home Page:https://kernc.github.io/xsuspender/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make window matchers accept regex pattern

offlinehacker opened this issue · comments

Issue

Currently window matchers only accept exact match. So that means if window class is chromium-browser, match_wm_class_contains = chromium would only match chromium window class and not chromium-browser class. I assume it's the same for other matchers.

Solution

Implement additional matchers (or change existing ones to match by regex). Example:

[Chromium]
suspend_delay = 10
match_wm_class_contains_pattern = (chormium|chromium-browser)
suspend_subtree_pattern = chromium
commented

Currently, they are contains matchers, not exact matchers.
So chromium matches chromium-browser.

xsuspender/src/rule.c

Lines 65 to 70 in 74e2835

// If all provided matching specifiers match
if (str_contains (wm_class_group, rule->needle_wm_class_group) &&
str_contains (wm_class, rule->needle_wm_class) &&
str_contains (wm_name, rule->needle_wm_name)) {
return rule;
}

But if regexes are implemented as part of #3, I'm probably 👍 for this as well.

Hmm interesting, i dunno why chromium does not work for me, only after i changed to chromium-browser it started to work, will investigate.