nomeata / arbtt

arbtt, the automatic rule-based time-tracker
http://arbtt.nomeata.de/
GNU General Public License v2.0
317 stars 36 forks source link

specify rule matching (if several rules apply) #45

Open pas-calc opened 3 years ago

pas-calc commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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?