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