source: examples/owlconf.simple @ e6449bc

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since e6449bc was 2b14303, checked in by Erik Nygren <nygren@mit.edu>, 21 years ago
* Updated owlconf.simple to handle outgoing message formatting.
  • Property mode set to 100644
File size: 9.9 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    ## 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.
150sub 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
161sub 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    $owl::recipient=~s/\@ATHENA\.MIT\.EDU$//;
168    $owl::recipient=~s/\@local-realm$//;
169
170    ## Format ping, login, and mail messages.
171    ## uc(foo) upcases the string and "eq" does string comparison.
172    if (uc($owl::opcode) eq "PING") {
173        return("\@bold(PING) from \@bold($owl::sender)\n");
174    } elsif (uc($owl::class) eq "LOGIN") {
175        if (uc($owl::opcode) eq "USER_LOGIN") {
176            $out="\@bold(LOGIN)";
177        } elsif (uc($owl::opcode) eq "USER_LOGOUT") {
178            $out="\@bold(LOGOUT)";
179        } else {
180            $out="\@bold(UNKNOWN)";
181        }
182        $out.=" for \@bold($owl::sender) at $fields[0] on $fields[2]\n";
183        return($out);
184    } elsif (uc($owl::class) eq "MAIL" and uc($owl::instance) eq "INBOX") {
185        $out = "\@bold(MAIL) ";
186        if ($owl::msg =~ /^From:\s+(.+)\s*$/m) { $out .= "From $1 "; }
187        if ($owl::msg =~ /^To:\s+(.+)\s*$/m) { $out .= "To $1 "; }
188        if ($owl::msg =~ /^Subject:\s+(.+)\s*$/m) { $out .= "Subject $1 "; }
189        return($out."\n");
190    }
191
192    ## The remainder formats normal messages (eg, to classes and instances).
193    ## Outgoing messages have different headers than incoming messages.
194    ## Note that:
195    ##   $out .= "foo";  appends "foo" to the end of the variable $out.
196    ##   lc(bar) will convert bar to lowercase.   
197    ##   "ne" does "not equal" for string comparison.
198    ##   sprintf fills in the %s's with the arguments later on the line.
199    ##   "foo"."bar" will append the two strings together.
200
201
202    if ($owl::direction eq "out") {
203        # Outgoing messages
204
205        $out .= sprintf "[outgoing to %s] / %s", $owl::recipient, $owl::time;
206        if ($owl::opcode ne "") {$out.=" op:$owl::opcode";}
207        $out.="\n";
208        $out.= "  \@bold($owl::sender)> ";
209        if ($owl::zsig ne "") {
210            my $zsig = $owl::zsig;
211            $zsig =~ s/(\n.*)+$/ [...]/;
212            if (length($zsig)+5+length($owl::sender) > 70) {
213                $out.="# ...";
214            } else {
215                $out.="# $zsig";
216            }
217        }
218    } else {
219        # Incoming messages
220
221        $out .= sprintf "[mit,%s,%s] / %s / %s", lc($owl::class), 
222                        lc($owl::instance), $owl::time, lc($owl::host);
223        if ($owl::opcode ne "") {$out.=" op:$owl::opcode";}
224        $out.="\n";
225        $out.= "  \@bold($owl::sender)> ";
226        if ($owl::zsig ne "") {
227            my $zsig = $owl::zsig;
228            $zsig =~ s/(\n.*)+$/ [...]/;
229            if (length($zsig)+5+length($owl::sender) > 70) {
230                $out.="# ...";
231            } else {
232                $out.="# $zsig";
233            }
234        }
235    }
236    $out.="\n";         
237
238    # This indents the body of the message and then appends it on.
239    $tmp=$owl::msg;
240    $tmp=~s/^/    /g;
241    $tmp=~s/\n/\n    /g;
242    $out.=$tmp;
243
244    # This makes personal messages bold.
245    if (uc($owl::class) eq "MESSAGE" &&
246        uc($owl::instance) eq "PERSONAL" &&
247       $owl::direction eq "in") {
248        $out="\@bold{".$out."}";
249    }
250
251    # Finally, this appends a newline and returns the formatted message.
252    return($out."\n");
253}
254
255## This is run when a message is received, and after
256## it has been added to the message list.
257## In most cases you won't need anything here.
258sub owl::receive_msg() {
259   
260    ## If this is uncommented, it would mark all messages
261    ## with opcode "PING" for immediate deletion:
262    #
263    # if (uc($owl::opcode) eq "PING") {
264    #    owl::command("delete -id $owl::id");
265    # }
266
267    ## If this is uncommented, it would mark all messages
268    ## with class "LOGIN" for immediate deletion:
269    #
270    # if (uc($owl::login) eq "LOGIN") {
271    #    owl::command("delete -id $owl::id");
272    # }
273
274    return 1;
275}
Note: See TracBrowser for help on using the repository browser.