| 1 | ### The owlconf config file -*- perl -*- |
|---|
| 2 | ### $Id$ |
|---|
| 3 | ### |
|---|
| 4 | ### This file is interpreted by the perl interpreter. |
|---|
| 5 | ### If you wish to execute an owl command use the |
|---|
| 6 | ### function owl::command(). i.e. |
|---|
| 7 | ### |
|---|
| 8 | ### owl::command("set zsigproc /mit/kretch/bin/getzsig"); |
|---|
| 9 | ### |
|---|
| 10 | ### will set the owl variable zsigproc. Subroutines created with |
|---|
| 11 | ### the names below will be executed at the specified times: |
|---|
| 12 | ### |
|---|
| 13 | ### subroutine name properties |
|---|
| 14 | ### --------------- ---------- |
|---|
| 15 | ### owl::startup() run when owl first starts |
|---|
| 16 | ### owl::shutdown() run when owl exits |
|---|
| 17 | ### owl::format_msg() run when a new message arrives, the return |
|---|
| 18 | ### value is used to display the message on the |
|---|
| 19 | ### screen |
|---|
| 20 | ### owl::receive_msg() run when a message is received, and after |
|---|
| 21 | ### it has been added to the message list |
|---|
| 22 | ### |
|---|
| 23 | ### |
|---|
| 24 | ### The following variables will be set each time a message is recevied: |
|---|
| 25 | ### |
|---|
| 26 | ### $owl::class, $owl::instance, $owl::recipient, |
|---|
| 27 | ### $owl::sender, $owl::opcode, $owl::zsig, |
|---|
| 28 | ### $owl::msg, $owl::time, $owl::host, @owl::fields, $owl::id |
|---|
| 29 | ### |
|---|
| 30 | |
|---|
| 31 | # tokens for sepbar are: |
|---|
| 32 | # .username = ping |
|---|
| 33 | # >username = login |
|---|
| 34 | # <username = logout |
|---|
| 35 | # :username = personal message |
|---|
| 36 | # M = mail received |
|---|
| 37 | my @sepbartokens = (); |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | # adds a sepbartoken and also updates the appendtosepbar variable |
|---|
| 41 | sub sepbartokens_add { |
|---|
| 42 | my ($token) = @_; |
|---|
| 43 | $token =~ s/"//g; # " |
|---|
| 44 | unshift @sepbartokens, $token; |
|---|
| 45 | pop @sepbartokens if (@sepbartokens > 80); |
|---|
| 46 | sepbartokens_set(); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | # trims a sepbartoken from the list also updates the appendtosepbar variable |
|---|
| 50 | sub sepbartokens_trim { |
|---|
| 51 | my ($token) = @_; |
|---|
| 52 | @sepbartokens = map { if ($_ ne $token) { $_; } else { (); } } @sepbartokens; |
|---|
| 53 | sepbartokens_set(); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | # trims a sepbartoken from the list also updates the appendtosepbar variable |
|---|
| 57 | sub sepbartokens_set { |
|---|
| 58 | owl::command(sprintf "set -q appendtosepbar \"%s\"", (join " ", @sepbartokens)); |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | sub owl::startup { |
|---|
| 62 | owl::command("set -q logging off"); |
|---|
| 63 | owl::command("set -q zsigproc /home/nygren/bin/owlzsigs"); |
|---|
| 64 | owl::command("set -q startuplogin off"); |
|---|
| 65 | owl::command("set -q shutdownlogout off"); |
|---|
| 66 | #owl::command("set personalbell on"); |
|---|
| 67 | owl::command("set -q rxping on"); |
|---|
| 68 | owl::command("set -q typewinsize 5"); |
|---|
| 69 | if ($ENV{"DISPLAY"} eq ":0") { |
|---|
| 70 | owl::command("set -q webbrowser galeon"); |
|---|
| 71 | } |
|---|
| 72 | owl::command("filter me recipient ".$ENV{"USER"}); |
|---|
| 73 | owl::command("filter help class help"); |
|---|
| 74 | owl::command("filter quiet not ( class ^greed|geek|help|login$ or instance white-magic )"); |
|---|
| 75 | |
|---|
| 76 | owl::command("alias z zwrite"); |
|---|
| 77 | owl::command("alias zc zwrite -c"); |
|---|
| 78 | |
|---|
| 79 | owl::command("bindkey editmulti \"C-c C-c\" command editmulti:done"); |
|---|
| 80 | owl::command("bindkey recv M-k command ( smartnarrow ; delete view )"); |
|---|
| 81 | owl::command("bindkey recv M-l command ( expunge ; view all )"); |
|---|
| 82 | owl::command("bindkey recv M-K command ( smartnarrow ; delete view ; expunge ; view all )"); |
|---|
| 83 | owl::command(q(bindkey edit M-s command perl owl::command("edit:insert-text <".("scritch"x int(1+rand(5))).">"))); |
|---|
| 84 | |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | sub owl::shutdown { |
|---|
| 88 | # not doing anything at the moment... |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | # run to format a message |
|---|
| 92 | sub owl::format_msg { |
|---|
| 93 | my $out, $tmp; |
|---|
| 94 | |
|---|
| 95 | $owl::sender=~s/\@ATHENA\.MIT\.EDU$//; |
|---|
| 96 | $owl::sender=~s/\@local-realm$//; |
|---|
| 97 | |
|---|
| 98 | if (uc($owl::opcode) eq "PING") { |
|---|
| 99 | return("\@bold(PING) from \@bold($owl::sender)\n"); |
|---|
| 100 | } elsif (uc($owl::class) eq "LOGIN") { |
|---|
| 101 | if (uc($owl::opcode) eq "USER_LOGIN") { |
|---|
| 102 | $out="\@bold(LOGIN)"; |
|---|
| 103 | } elsif (uc($owl::opcode) eq "USER_LOGOUT") { |
|---|
| 104 | $out="\@bold(LOGOUT)"; |
|---|
| 105 | } else { |
|---|
| 106 | $out="\@bold(UNKNOWN)"; |
|---|
| 107 | } |
|---|
| 108 | $out.=" for \@bold($owl::sender) at $fields[0] on $fields[2]\n"; |
|---|
| 109 | return($out); |
|---|
| 110 | } elsif (uc($owl::class) eq "MAIL" and uc($owl::instance) eq "INBOX") { |
|---|
| 111 | $out = "\@bold(MAIL) "; |
|---|
| 112 | if ($owl::msg =~ /^From:\s+(.+)\s*$/m) { $out .= "From $1 "; } |
|---|
| 113 | if ($owl::msg =~ /^To:\s+(.+)\s*$/m) { $out .= "To $1 "; } |
|---|
| 114 | if ($owl::msg =~ /^Subject:\s+(.+)\s*$/m) { $out .= "Subject $1 "; } |
|---|
| 115 | return($out."\n"); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | $out = sprintf "[mit,%s,%s] / %s / %s", lc($owl::class), |
|---|
| 119 | lc($owl::instance), $owl::time, lc($owl::host); |
|---|
| 120 | if ($owl::opcode ne "") {$out.=" op:$owl::opcode";} |
|---|
| 121 | $out.="\n"; |
|---|
| 122 | $out.= " \@bold($owl::sender)> "; |
|---|
| 123 | if ($owl::zsig ne "") { |
|---|
| 124 | my $zsig = $owl::zsig; |
|---|
| 125 | $zsig =~ s/(\n.*)+$/ [...]/; |
|---|
| 126 | if (length($zsig)+5+length($owl::sender) > 70) { |
|---|
| 127 | $out.="# ..."; |
|---|
| 128 | } else { |
|---|
| 129 | $out.="# $zsig"; |
|---|
| 130 | } |
|---|
| 131 | } |
|---|
| 132 | $out.="\n"; |
|---|
| 133 | |
|---|
| 134 | # indent it |
|---|
| 135 | $tmp=$owl::msg; |
|---|
| 136 | $tmp=~s/^/ /g; |
|---|
| 137 | $tmp=~s/\n/\n /g; |
|---|
| 138 | $out.=$tmp; |
|---|
| 139 | |
|---|
| 140 | # make personal messages bold |
|---|
| 141 | if (uc($owl::class) eq "MESSAGE" && |
|---|
| 142 | uc($owl::instance) eq "PERSONAL") { |
|---|
| 143 | $out="\@bold{".$out."}"; |
|---|
| 144 | } |
|---|
| 145 | |
|---|
| 146 | return($out."\n"); |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | # run when a message is received, and after |
|---|
| 150 | # it has been added to the message list. |
|---|
| 151 | sub owl::receive_msg() { |
|---|
| 152 | my $out, $tmp; |
|---|
| 153 | |
|---|
| 154 | $owl::sender=~s/\@ATHENA\.MIT\.EDU$//; |
|---|
| 155 | $owl::sender=~s/\@local-realm$//; |
|---|
| 156 | |
|---|
| 157 | if (uc($owl::opcode) eq "PING") { |
|---|
| 158 | sepbartokens_add(".$owl::sender"); |
|---|
| 159 | owl::command("delete -id $owl::id"); |
|---|
| 160 | } elsif (uc($owl::class) eq "LOGIN") { |
|---|
| 161 | owl::command("delete -id $owl::id"); |
|---|
| 162 | if (uc($owl::opcode) eq "USER_LOGIN") { |
|---|
| 163 | sepbartokens_add(">$owl::sender"); |
|---|
| 164 | sepbartokens_trim("<$owl::sender"); |
|---|
| 165 | } elsif (uc($owl::opcode) eq "USER_LOGOUT") { |
|---|
| 166 | sepbartokens_add("<$owl::sender"); |
|---|
| 167 | sepbartokens_trim(">$owl::sender"); |
|---|
| 168 | } |
|---|
| 169 | } elsif (uc($owl::class) eq "MAIL") { |
|---|
| 170 | owl::command("delete -id $owl::id"); |
|---|
| 171 | sepbartokens_add("M"); |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | # make personal messages bold |
|---|
| 176 | if (uc($owl::class) eq "MESSAGE" && |
|---|
| 177 | uc($owl::instance) eq "PERSONAL") { |
|---|
| 178 | sepbartokens_trim(".$owl::sender"); |
|---|
| 179 | sepbartokens_add(":$owl::sender"); |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | return 1; |
|---|
| 183 | } |
|---|