[1770f30] | 1 | ### The owlconf config file -*- perl -*- |
---|
| 2 | |
---|
| 3 | ### !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!! |
---|
| 4 | ### This is an example file intended to demonstrate how to use |
---|
| 5 | ### various features of owl. Some of the key bindings, in particular, |
---|
| 6 | ### are more for examples than things you may actually want to use. |
---|
| 7 | ### Make sure to read through it first and understand it before just using it. |
---|
| 8 | ### Don't blame me if anything in here ends up vaporizing your dog. |
---|
| 9 | ### !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!! |
---|
| 10 | |
---|
| 11 | ### |
---|
| 12 | ### This file is interpreted by the perl interpreter. |
---|
| 13 | ### If you wish to execute an owl command use the |
---|
| 14 | ### function owl::command(). i.e. |
---|
| 15 | ### |
---|
| 16 | ### owl::command("set zsigproc /mit/kretch/bin/getzsig"); |
---|
| 17 | ### |
---|
| 18 | ### will set the owl variable zsigproc. Subroutines created with |
---|
| 19 | ### the names below will be executed at the specified times: |
---|
| 20 | ### |
---|
| 21 | ### subroutine name properties |
---|
| 22 | ### --------------- ---------- |
---|
| 23 | ### owl::startup() run when owl first starts |
---|
| 24 | ### owl::shutdown() run when owl exits |
---|
| 25 | ### owl::format_msg() run when a new message arrives, the return |
---|
| 26 | ### value is used to display the message on the |
---|
| 27 | ### screen |
---|
| 28 | ### owl::receive_msg() run when a message is received, and after |
---|
| 29 | ### it has been added to the message list |
---|
| 30 | ### |
---|
| 31 | ### |
---|
| 32 | ### The following variables will be set each time a message is recevied |
---|
| 33 | ### and when owl::format_msg() and owl::receive_msg() are run. |
---|
| 34 | ### |
---|
[2b14303] | 35 | ### $owl::class, $owl::instance, $owl::recipient, $owl::direction, |
---|
[1770f30] | 36 | ### $owl::sender, $owl::opcode, $owl::zsig, |
---|
| 37 | ### $owl::msg, $owl::time, $owl::host, @owl::fields, $owl::id |
---|
| 38 | ### |
---|
| 39 | |
---|
| 40 | # NOTE: Lines beginning with a "#" are perl comments. |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | # This subroutine is run whenever owl starts up. |
---|
| 44 | # The owl::command("foo") lines execute the owl command "foo". |
---|
| 45 | sub owl::startup { |
---|
| 46 | |
---|
| 47 | ################################################################ |
---|
| 48 | ## The following set the values of variables. |
---|
| 49 | ## Doing "help" will show you more about each variable. |
---|
| 50 | ## These lines will set things to the default. |
---|
| 51 | ## You can uncomment them and then change the value to get |
---|
| 52 | ## a different behavior (remove the "#" to an alternate value). |
---|
| 53 | ################################################################ |
---|
| 54 | |
---|
| 55 | ## Set this to off to disable the terminal bell. |
---|
| 56 | # owl::command('set -q bell on'); |
---|
| 57 | |
---|
| 58 | ## Set this to off to disable the terminal bell on personal zephyrs. |
---|
| 59 | # owl::command('set -q personalbell off'); |
---|
| 60 | |
---|
| 61 | ## Set this to on to enable logging of personal zephyrs |
---|
| 62 | # owl::command('set -q logging off'); |
---|
| 63 | |
---|
| 64 | ## This directory must exist and is where personal zephyrs are logged. |
---|
| 65 | ## By default, this is the ~/zlog/personal/ directory |
---|
| 66 | # owl::command('set -q logpath '.$ENV{'HOME'}.'/zlog/personal/'); |
---|
| 67 | |
---|
| 68 | ## Set this to on to enable logging of classes |
---|
| 69 | # owl::command('set -q classlogging off'); |
---|
| 70 | |
---|
| 71 | ## This directory must exist and is where class zephyrs are logged. |
---|
| 72 | ## By default, this is the ~/zlog/class/ directory |
---|
| 73 | # owl::command('set -q classlogpath '.$ENV{'HOME'}.'/zlog/class/'); |
---|
| 74 | |
---|
| 75 | ## If set to on, this will make is so that C-d doesn't |
---|
| 76 | ## send zephyrs by accident. |
---|
| 77 | # owl::command('set -q disable-ctrl-d off'); |
---|
| 78 | |
---|
| 79 | ## If set to on, outgoing messages will be displayed. |
---|
| 80 | # owl::command('set -q displayoutgoing on'); |
---|
| 81 | |
---|
| 82 | ## Displays received pings? |
---|
| 83 | # owl::command('set -q rxping off'); |
---|
| 84 | |
---|
| 85 | ## Send pings? |
---|
| 86 | # owl::command('set -q txping on'); |
---|
| 87 | |
---|
| 88 | ## Size of typing window at the bottom of the screen |
---|
| 89 | # owl::command('set -q typewinsize 8'); |
---|
| 90 | |
---|
| 91 | ## Which view to switch to after the 'V' or 'X' commands. |
---|
| 92 | # owl::command('set -q view_home all'); |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | ## Default message to send when zaway is on (toggle with 'A') |
---|
| 96 | # owl::command('set -q zaway_msg_default "Not here now..."'); |
---|
| 97 | |
---|
| 98 | ## Default zephyr signature. |
---|
| 99 | # owl::command('set -q zsig "meep"'); |
---|
| 100 | |
---|
| 101 | ## Program to generate a zsig. |
---|
| 102 | # owl::command('set -q zsigproc "/mit/foo/bin/randzsig"'); |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | ################################################################ |
---|
| 106 | ## The following create filters. Filters can be used to select |
---|
| 107 | ## on multiple zephyrs for operations. With 'views' you can |
---|
| 108 | ## look at only the zephyrs matching a particular filter. |
---|
| 109 | ## Use the 'view <filtername>' command or the 'v' key to switch views. |
---|
| 110 | ## The 'V' key will switch you back to your 'view_home' view. |
---|
| 111 | ## The M-D key will delete all messages in the current view |
---|
| 112 | ## |
---|
| 113 | ## |
---|
| 114 | ## The filter command creates a filter with the specified name, |
---|
| 115 | ## or if one already exists it is replaced. Example filter |
---|
| 116 | ## syntax would be: |
---|
| 117 | ## |
---|
| 118 | ## filter myfilter -c red ( class ^foobar$ ) or ( class ^quux$ and instance ^bar$ ) |
---|
| 119 | ## |
---|
| 120 | ## Valid matching fields are class, instance, recipient, sender, opcode |
---|
| 121 | ## and realm. Valid operations are 'and', 'or' and 'not'. Spaces must be |
---|
| 122 | ## present before and after parenthesis. If the optional color argument |
---|
| 123 | ## is used it specifies the color that messages matching this filter |
---|
| 124 | ## should be displayed in. Do 'show colors' to see the available colors. |
---|
| 125 | ## |
---|
| 126 | ################################################################ |
---|
| 127 | |
---|
| 128 | ## This would create a shortcut to only show personal messages |
---|
| 129 | ## with filter 'me' and to color them yellow. |
---|
| 130 | ## Replace myusername with yours. |
---|
| 131 | # owl::command('filter me -c yellow recipient myusername'); |
---|
| 132 | |
---|
| 133 | ## This would create a 'quiet' filter to not show messages |
---|
| 134 | ## on noisy classes and instances. |
---|
| 135 | # owl::command('filter quiet not ( class ^foo|bar|quux$ or instance ( ^baaz$ ) '); |
---|
| 136 | |
---|
| 137 | ## The 'trash' filter is used when you press 'T' to mark things |
---|
| 138 | ## for autodeletion. |
---|
| 139 | # owl::command('filter trash class ^mail$ or opcode ^ping$ or type ^admin$ or class ^login$'); |
---|
| 140 | |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | ## This is run when owl exits. Currently this does nothing. |
---|
| 144 | sub owl::shutdown { |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | ## This is run to format the contents of the message. |
---|
| 148 | ## It returns a string which is a formatted message. |
---|
| 149 | ## The following variables will be set each time before this is run: |
---|
| 150 | ## |
---|
| 151 | ## $owl::class, $owl::instance, $owl::recipient, |
---|
| 152 | ## $owl::sender, $owl::opcode, $owl::zsig, |
---|
| 153 | ## $owl::msg, $owl::time, $owl::host, @owl::fields, $owl::id |
---|
| 154 | |
---|
| 155 | sub owl::format_msg { |
---|
| 156 | my $out, $tmp; |
---|
| 157 | |
---|
| 158 | ## Strip out noise from the sender string. |
---|
| 159 | $owl::sender=~s/\@ATHENA\.MIT\.EDU$//; |
---|
| 160 | $owl::sender=~s/\@local-realm$//; |
---|
[2b14303] | 161 | $owl::recipient=~s/\@ATHENA\.MIT\.EDU$//; |
---|
| 162 | $owl::recipient=~s/\@local-realm$//; |
---|
[1770f30] | 163 | |
---|
| 164 | ## Format ping, login, and mail messages. |
---|
| 165 | ## uc(foo) upcases the string and "eq" does string comparison. |
---|
| 166 | if (uc($owl::opcode) eq "PING") { |
---|
| 167 | return("\@bold(PING) from \@bold($owl::sender)\n"); |
---|
| 168 | } elsif (uc($owl::class) eq "LOGIN") { |
---|
| 169 | if (uc($owl::opcode) eq "USER_LOGIN") { |
---|
| 170 | $out="\@bold(LOGIN)"; |
---|
| 171 | } elsif (uc($owl::opcode) eq "USER_LOGOUT") { |
---|
| 172 | $out="\@bold(LOGOUT)"; |
---|
| 173 | } else { |
---|
| 174 | $out="\@bold(UNKNOWN)"; |
---|
| 175 | } |
---|
| 176 | $out.=" for \@bold($owl::sender) at $fields[0] on $fields[2]\n"; |
---|
| 177 | return($out); |
---|
| 178 | } elsif (uc($owl::class) eq "MAIL" and uc($owl::instance) eq "INBOX") { |
---|
| 179 | $out = "\@bold(MAIL) "; |
---|
| 180 | if ($owl::msg =~ /^From:\s+(.+)\s*$/m) { $out .= "From $1 "; } |
---|
| 181 | if ($owl::msg =~ /^To:\s+(.+)\s*$/m) { $out .= "To $1 "; } |
---|
| 182 | if ($owl::msg =~ /^Subject:\s+(.+)\s*$/m) { $out .= "Subject $1 "; } |
---|
| 183 | return($out."\n"); |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | ## The remainder formats normal messages (eg, to classes and instances). |
---|
[2b14303] | 187 | ## Outgoing messages have different headers than incoming messages. |
---|
[1770f30] | 188 | ## Note that: |
---|
| 189 | ## $out .= "foo"; appends "foo" to the end of the variable $out. |
---|
| 190 | ## lc(bar) will convert bar to lowercase. |
---|
| 191 | ## "ne" does "not equal" for string comparison. |
---|
| 192 | ## sprintf fills in the %s's with the arguments later on the line. |
---|
| 193 | ## "foo"."bar" will append the two strings together. |
---|
| 194 | |
---|
[2b14303] | 195 | |
---|
| 196 | if ($owl::direction eq "out") { |
---|
| 197 | # Outgoing messages |
---|
| 198 | |
---|
| 199 | $out .= sprintf "[outgoing to %s] / %s", $owl::recipient, $owl::time; |
---|
| 200 | if ($owl::opcode ne "") {$out.=" op:$owl::opcode";} |
---|
| 201 | $out.="\n"; |
---|
| 202 | $out.= " \@bold($owl::sender)> "; |
---|
| 203 | if ($owl::zsig ne "") { |
---|
| 204 | my $zsig = $owl::zsig; |
---|
| 205 | $zsig =~ s/(\n.*)+$/ [...]/; |
---|
| 206 | if (length($zsig)+5+length($owl::sender) > 70) { |
---|
| 207 | $out.="# ..."; |
---|
| 208 | } else { |
---|
| 209 | $out.="# $zsig"; |
---|
| 210 | } |
---|
| 211 | } |
---|
| 212 | } else { |
---|
| 213 | # Incoming messages |
---|
| 214 | |
---|
| 215 | $out .= sprintf "[mit,%s,%s] / %s / %s", lc($owl::class), |
---|
| 216 | lc($owl::instance), $owl::time, lc($owl::host); |
---|
| 217 | if ($owl::opcode ne "") {$out.=" op:$owl::opcode";} |
---|
| 218 | $out.="\n"; |
---|
| 219 | $out.= " \@bold($owl::sender)> "; |
---|
| 220 | if ($owl::zsig ne "") { |
---|
| 221 | my $zsig = $owl::zsig; |
---|
| 222 | $zsig =~ s/(\n.*)+$/ [...]/; |
---|
| 223 | if (length($zsig)+5+length($owl::sender) > 70) { |
---|
| 224 | $out.="# ..."; |
---|
| 225 | } else { |
---|
| 226 | $out.="# $zsig"; |
---|
| 227 | } |
---|
[1770f30] | 228 | } |
---|
| 229 | } |
---|
| 230 | $out.="\n"; |
---|
| 231 | |
---|
| 232 | # This indents the body of the message and then appends it on. |
---|
| 233 | $tmp=$owl::msg; |
---|
| 234 | $tmp=~s/^/ /g; |
---|
| 235 | $tmp=~s/\n/\n /g; |
---|
| 236 | $out.=$tmp; |
---|
| 237 | |
---|
| 238 | # This makes personal messages bold. |
---|
| 239 | if (uc($owl::class) eq "MESSAGE" && |
---|
[2b14303] | 240 | uc($owl::instance) eq "PERSONAL" && |
---|
| 241 | $owl::direction eq "in") { |
---|
[1770f30] | 242 | $out="\@bold{".$out."}"; |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | # Finally, this appends a newline and returns the formatted message. |
---|
| 246 | return($out."\n"); |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | ## This is run when a message is received, and after |
---|
| 250 | ## it has been added to the message list. |
---|
| 251 | ## In most cases you won't need anything here. |
---|
| 252 | sub owl::receive_msg() { |
---|
| 253 | |
---|
| 254 | ## If this is uncommented, it would mark all messages |
---|
| 255 | ## with opcode "PING" for immediate deletion: |
---|
| 256 | # |
---|
| 257 | # if (uc($owl::opcode) eq "PING") { |
---|
| 258 | # owl::command("delete -id $owl::id"); |
---|
| 259 | # } |
---|
| 260 | |
---|
| 261 | ## If this is uncommented, it would mark all messages |
---|
| 262 | ## with class "LOGIN" for immediate deletion: |
---|
| 263 | # |
---|
| 264 | # if (uc($owl::login) eq "LOGIN") { |
---|
| 265 | # owl::command("delete -id $owl::id"); |
---|
| 266 | # } |
---|
| 267 | |
---|
| 268 | return 1; |
---|
| 269 | } |
---|