source: examples/owlconf.simple @ 8e9acd2

debianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 8e9acd2 was 4f15e8e, checked in by Anders Kaseorg <andersk@mit.edu>, 16 years ago
Rip out the webbrowser variable.
  • Property mode set to 100644
File size: 9.7 KB
Line 
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, $owl::direction,
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".
46sub 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    ## Default message to send when zaway is on (toggle with 'A')
97    # owl::command('set -q zaway_msg_default "Not here now..."');
98
99    ## Default zephyr signature.
100    # owl::command('set -q zsig "meep"');
101
102    ## Program to generate a zsig.
103    # owl::command('set -q zsigproc "/mit/foo/bin/randzsig"');
104
105
106    ################################################################
107    ## The following create filters.  Filters can be used to select
108    ## on multiple zephyrs for operations.  With 'views' you can
109    ## look at only the zephyrs matching a particular filter.
110    ## Use the 'view <filtername>' command or the 'v' key to switch views.
111    ## The 'V' key will switch you back to your 'view_home' view.
112    ## The M-D key will delete all messages in the current view
113    ##
114    ##
115    ## The filter command creates a filter with the specified name,
116    ## or if one already exists it is replaced.  Example filter
117    ## syntax would be:                                       
118    ##
119    ##    filter myfilter -c red ( class ^foobar$ ) or ( class ^quux$ and instance ^bar$ )
120    ##
121    ## Valid matching fields are class, instance, recipient, sender, opcode
122    ## and realm.  Valid operations are 'and', 'or' and 'not'.  Spaces must be
123    ## present before and after parenthesis.  If the optional color argument
124    ## is used it specifies the color that messages matching this filter
125    ## should be displayed in.  Do 'show colors' to see the available colors.
126    ##
127    ################################################################
128
129    ## This would create a shortcut to only show personal messages
130    ## with filter 'me' and to color them yellow.
131    ## Replace myusername with yours.
132    # owl::command('filter me -c yellow recipient myusername');
133
134    ## This would create a 'quiet' filter to not show messages
135    ## on noisy classes and instances.
136    # owl::command('filter quiet not ( class ^foo|bar|quux$ or instance ( ^baaz$ ) ');
137
138    ## The 'trash' filter is used when you press 'T' to mark things
139    ## for autodeletion.
140    # owl::command('filter trash class ^mail$ or opcode ^ping$ or type ^admin$ or class ^login$');   
141
142}
143
144## This is run when owl exits.  Currently this does nothing.
145sub owl::shutdown {
146}
147
148## This is run to format the contents of the message.
149## It returns a string which is a formatted message.
150## The following variables will be set each time before this is run:
151##
152##     $owl::class, $owl::instance, $owl::recipient,
153##     $owl::sender, $owl::opcode, $owl::zsig,
154##     $owl::msg, $owl::time, $owl::host, @owl::fields, $owl::id
155
156sub owl::format_msg {
157    my $out, $tmp;
158
159    ## Strip out noise from the sender string.
160    $owl::sender=~s/\@ATHENA\.MIT\.EDU$//;
161    $owl::sender=~s/\@local-realm$//;
162    $owl::recipient=~s/\@ATHENA\.MIT\.EDU$//;
163    $owl::recipient=~s/\@local-realm$//;
164
165    ## Format ping, login, and mail messages.
166    ## uc(foo) upcases the string and "eq" does string comparison.
167    if (uc($owl::opcode) eq "PING") {
168        return("\@bold(PING) from \@bold($owl::sender)\n");
169    } elsif (uc($owl::class) eq "LOGIN") {
170        if (uc($owl::opcode) eq "USER_LOGIN") {
171            $out="\@bold(LOGIN)";
172        } elsif (uc($owl::opcode) eq "USER_LOGOUT") {
173            $out="\@bold(LOGOUT)";
174        } else {
175            $out="\@bold(UNKNOWN)";
176        }
177        $out.=" for \@bold($owl::sender) at $fields[0] on $fields[2]\n";
178        return($out);
179    } elsif (uc($owl::class) eq "MAIL" and uc($owl::instance) eq "INBOX") {
180        $out = "\@bold(MAIL) ";
181        if ($owl::msg =~ /^From:\s+(.+)\s*$/m) { $out .= "From $1 "; }
182        if ($owl::msg =~ /^To:\s+(.+)\s*$/m) { $out .= "To $1 "; }
183        if ($owl::msg =~ /^Subject:\s+(.+)\s*$/m) { $out .= "Subject $1 "; }
184        return($out."\n");
185    }
186
187    ## The remainder formats normal messages (eg, to classes and instances).
188    ## Outgoing messages have different headers than incoming messages.
189    ## Note that:
190    ##   $out .= "foo";  appends "foo" to the end of the variable $out.
191    ##   lc(bar) will convert bar to lowercase.   
192    ##   "ne" does "not equal" for string comparison.
193    ##   sprintf fills in the %s's with the arguments later on the line.
194    ##   "foo"."bar" will append the two strings together.
195
196
197    if ($owl::direction eq "out") {
198        # Outgoing messages
199
200        $out .= sprintf "[outgoing to %s] / %s", $owl::recipient, $owl::time;
201        if ($owl::opcode ne "") {$out.=" op:$owl::opcode";}
202        $out.="\n";
203        $out.= "  \@bold($owl::sender)> ";
204        if ($owl::zsig ne "") {
205            my $zsig = $owl::zsig;
206            $zsig =~ s/(\n.*)+$/ [...]/;
207            if (length($zsig)+5+length($owl::sender) > 70) {
208                $out.="# ...";
209            } else {
210                $out.="# $zsig";
211            }
212        }
213    } else {
214        # Incoming messages
215
216        $out .= sprintf "[mit,%s,%s] / %s / %s", lc($owl::class), 
217                        lc($owl::instance), $owl::time, lc($owl::host);
218        if ($owl::opcode ne "") {$out.=" op:$owl::opcode";}
219        $out.="\n";
220        $out.= "  \@bold($owl::sender)> ";
221        if ($owl::zsig ne "") {
222            my $zsig = $owl::zsig;
223            $zsig =~ s/(\n.*)+$/ [...]/;
224            if (length($zsig)+5+length($owl::sender) > 70) {
225                $out.="# ...";
226            } else {
227                $out.="# $zsig";
228            }
229        }
230    }
231    $out.="\n";         
232
233    # This indents the body of the message and then appends it on.
234    $tmp=$owl::msg;
235    $tmp=~s/^/    /g;
236    $tmp=~s/\n/\n    /g;
237    $out.=$tmp;
238
239    # This makes personal messages bold.
240    if (uc($owl::class) eq "MESSAGE" &&
241        uc($owl::instance) eq "PERSONAL" &&
242       $owl::direction eq "in") {
243        $out="\@bold{".$out."}";
244    }
245
246    # Finally, this appends a newline and returns the formatted message.
247    return($out."\n");
248}
249
250## This is run when a message is received, and after
251## it has been added to the message list.
252## In most cases you won't need anything here.
253sub owl::receive_msg() {
254   
255    ## If this is uncommented, it would mark all messages
256    ## with opcode "PING" for immediate deletion:
257    #
258    # if (uc($owl::opcode) eq "PING") {
259    #    owl::command("delete -id $owl::id");
260    # }
261
262    ## If this is uncommented, it would mark all messages
263    ## with class "LOGIN" for immediate deletion:
264    #
265    # if (uc($owl::login) eq "LOGIN") {
266    #    owl::command("delete -id $owl::id");
267    # }
268
269    return 1;
270}
Note: See TracBrowser for help on using the repository browser.