2

I'm new to this so bear with me but I'm trying to do a rule that splits out my time on Firefox tabs using arbtt v0.7 in categorize.cfg:

-- Firefox
current window ($program == "Navigator") ==>
  if $title =~ /^(.*) - (.*@.*) - .* Mail - Mozilla Firefox$/ then tag Email:$2-$1 else
  if $title =~ /^(.*) - Calendar - Mozilla Firefox$/          then tag Calendar:$1 else
  if $title =~ /^(.*) - Mozilla Firefox$/                     then tag Firefox:$1  else
                                                                   tag Firefox,

But I get:

Parser error: "/home/rich/.arbtt/categorize.cfg" (line 29, column 3): unexpected "i" expecting "else"

I have also tried another approach with more success:

current window ( $program == "Navigator" && $title =~ /^(.*) - (.*@.*) - .* Mail - Mozilla Firefox$/ )
  ==> tag Email:$2-$1,
current window ( $program == "Navigator" && $title =~ /^(.*) - Calendar - Mozilla Firefox$/ )
  ==> tag Calendar:$1,
current window ( $program == "Navigator" && $title =~ /^((?!.*\b(Calendar|Mail)\b)) - Mozilla Firefox$/ )
  ==> tag Firefox:$1,

But the last clause doesn't return any results; the first two clauses do.

Cheers, Rich

muhmuhten
  • 3,313
  • 1
  • 20
  • 26
racitup
  • 416
  • 4
  • 11
  • Bugs filed at https://bitbucket.org/nomeata/arbtt/issue/4/parsing-of-if-then-else-fails and https://bitbucket.org/nomeata/arbtt/issue/5/parsing-of-fails – Joachim Breitner Jan 07 '14 at 14:28
  • Hmm, now it’s two questions, isn’t it? I’m not sure if all these regex features are supported by the underlying library ([pcre-light](http://hackage.haskell.org/package/pcre-light)). – Joachim Breitner Jan 07 '14 at 18:42
  • Ah, shouldn’t it be `/^(?!.*\b(Calendar|Mail)\b)(.*) - Mozilla Firefox$/` – `(?!...)` is a zero-width pattern... But I’m quite ashamed that the variant with `;` does not work. Maybe this needs to be moved to the arbtt mailinglist or bug tracker. – Joachim Breitner Jan 07 '14 at 18:43
  • @Joachim Thanks Joachim, that fixes the third clause. If you put it in your answer I will mark this as answered, but now you _just_ have to fix the bugs ;) – racitup Jan 07 '14 at 23:18
  • I’ll fix them before the next release for sure. – Joachim Breitner Jan 08 '14 at 09:12

1 Answers1

1

It looks like a bug in arbtt; I agree that your code looks correct.

But anyways, it might be more idiomatic to use the ; operator, which means “Try the first thing, and if it does not assign a tag, try the second thing”:

current window ($program == "Navigator") ==> 
  { $title =~ /^(.*) - (.*@.*) - .* Mail - Mozilla Firefox$/ ==> tag Email:$2-$1;;
    $title =~ /^(.*) - Calendar - Mozilla Firefox$/          ==> tag Calendar:$1;
    $title =~ /^(.*) - Mozilla Firefox$/                     ==> tag Firefox:$1;
    tag Firefox },

(The ;; is because of another bug in the parser – guess that part hasn’t been used a lot yet.)

In your second attempt, there is simply a problem with the regex: It should be /^(?!.*\b(Calendar|Mail)\b)(.*) - Mozilla Firefox$/(?!...) is a zero-width pattern.

Joachim Breitner
  • 25,395
  • 6
  • 78
  • 139
  • Thanks for the answer. Although the parser accepts it I don't get any matching entries. I'm editting above with another approach that almost works. – racitup Jan 07 '14 at 18:01