Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specify rule matching (if several rules apply) #45

Open
pas-calc opened this issue Jan 29, 2021 · 2 comments
Open

specify rule matching (if several rules apply) #45

pas-calc opened this issue Jan 29, 2021 · 2 comments

Comments

@pas-calc
Copy link

In the docs there is written

If the tag has a category, it will only be assigned if no other tag of that category has been assigned.

However it is important that these sum up to 100% , and the question occurs how does this work precisely?
The answer is that the first rule that applies , then stops
(acutally it does not stop evaluating, since other Category could be assigned later, but not to the same category, it is not overwritten, but the other way round! - first match applies)

Working example:
version1:

current window $program == ["Navigator", "chromium"] ==> tag Graph:browsing,
current window $title =~ /(?i).*Radio.*/ ==> tag Graph:radio,

version2: (the two lines interchanged)

current window $title =~ /(?i).*Radio.*/ ==> tag Graph:radio,
current window $program == ["Navigator", "chromium"] ==> tag Graph:browsing,

Running arbtt-stats in each case , one obtains:
ad1) no radio (because I only listened to radio via webradio using browser)
ad2) radio, and browsing (which is not radio) , this is of course in realworld application the preferred solution, always set this browser related line last

see also:
related issue on bitbucket
user guide docs

@nomeata
Copy link
Owner

nomeata commented Jan 30, 2021

The behavior your describe is expected, so I am not sure what this issue is about. Do you want confirmation that this is indendet behaviour, suggest better documentation, or do you suggest that the behaviour changes?

@pas-calc
Copy link
Author

pas-calc commented Jan 30, 2021

suggest better documentation

This, because it was not clear for me, so I tried it out and the example above is proof of concept. Maybe just add this to the docs that the first match per category is the one that is used. (so put general rules after specific ones whereby the last rules are for thos that were not detected before)

A useful example (at least for me to detect whether I use E-Mail actively or just in the background), the order matters

current window $title =~ [/.*Thunderbird.*/, /.*Outlook.*/, /.*GMX.*/, /.*Webmail.*/] ==> tag Mail:aktiv,
any window $title =~ [/.*Thunderbird.*/, /.*Outlook.*/, /.*GMX.*/, /.*Webmail.*/] ==> tag Mail:inaktiv,

Then analyze using
arbtt-stats -c "Mail" --for-each=day -m0

Is there the possibility to define a variable for pattern matching?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants