arbtt icon indicating copy to clipboard operation
arbtt copied to clipboard

specify rule matching (if several rules apply)

Open pas-calc opened this issue 5 years ago • 2 comments

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

pas-calc avatar Jan 29 '21 17:01 pas-calc

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?

nomeata avatar Jan 30 '21 10:01 nomeata

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?

pas-calc avatar Jan 30 '21 16:01 pas-calc