File: owlconf.simple

package info (click to toggle)
owl 2.2.2-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,208 kB
  • ctags: 3,600
  • sloc: ansic: 36,373; perl: 242; makefile: 93; sh: 43
file content (270 lines) | stat: -rw-r--r-- 9,943 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
### The owlconf config file   -*- perl -*-  
###  $Id: owlconf.simple,v 1.3 2009/03/28 21:01:35 kretch Exp $

### !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!!
### This is an example file intended to demonstrate how to use 
### various features of owl.  Some of the key bindings, in particular,
### are more for examples than things you may actually want to use.
### Make sure to read through it first and understand it before just using it.
### Don't blame me if anything in here ends up vaporizing your dog.
### !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!!

###
### This file is interpreted by the perl interpreter.
### If you wish to execute an owl command use the
### function owl::command().  i.e.
###
###      owl::command("set zsigproc /mit/kretch/bin/getzsig");
###
### will set the owl variable zsigproc.  Subroutines created with
### the names below will be executed at the specified times:
###
###     subroutine name    properties
###     ---------------    ----------
###     owl::startup()     run when owl first starts
###     owl::shutdown()    run when owl exits
###     owl::format_msg()  run when a new message arrives, the return
###                           value is used to display the message on the
###                           screen
###     owl::receive_msg() run when a message is received, and after
###	  	           it has been added to the message list
###
###
### The following variables will be set each time a message is recevied
### and when owl::format_msg() and owl::receive_msg() are run.
###
###     $owl::class, $owl::instance, $owl::recipient, $owl::direction,
###     $owl::sender, $owl::opcode, $owl::zsig,
###     $owl::msg, $owl::time, $owl::host, @owl::fields, $owl::id
###    

# NOTE: Lines beginning with a "#" are perl comments.


# This subroutine is run whenever owl starts up.
# The owl::command("foo") lines execute the owl command "foo".
sub owl::startup {

    ################################################################
    ## The following set the values of variables.
    ## Doing "help" will show you more about each variable.
    ## These lines will set things to the default.
    ## You can uncomment them and then change the value to get 
    ## a different behavior (remove the "#" to an alternate value).
    ################################################################

    ## Set this to off to disable the terminal bell.
    # owl::command('set -q bell on');

    ## Set this to off to disable the terminal bell on personal zephyrs.
    # owl::command('set -q personalbell off');

    ## Set this to on to enable logging of personal zephyrs
    # owl::command('set -q logging off');  

    ## This directory must exist and is where personal zephyrs are logged.
    ## By default, this is the ~/zlog/personal/ directory
    # owl::command('set -q logpath '.$ENV{'HOME'}.'/zlog/personal/');

    ## Set this to on to enable logging of classes
    # owl::command('set -q classlogging off');  

    ## This directory must exist and is where class zephyrs are logged.
    ## By default, this is the ~/zlog/class/ directory
    # owl::command('set -q classlogpath '.$ENV{'HOME'}.'/zlog/class/');

    ## If set to on, this will make is so that C-d doesn't
    ## send zephyrs by accident.
    # owl::command('set -q disable-ctrl-d off');

    ## If set to on, outgoing messages will be displayed.
    # owl::command('set -q displayoutgoing on');

    ## Displays received pings?
    # owl::command('set -q rxping off');

    ## Send pings?
    # owl::command('set -q txping on');

    ## Size of typing window at the bottom of the screen
    # owl::command('set -q typewinsize 8');

    ## Which view to switch to after the 'V' or 'X' commands.
    # owl::command('set -q view_home all');


    ## Default message to send when zaway is on (toggle with 'A')
    # owl::command('set -q zaway_msg_default "Not here now..."');

    ## Default zephyr signature.
    # owl::command('set -q zsig "meep"');

    ## Program to generate a zsig.
    # owl::command('set -q zsigproc "/mit/foo/bin/randzsig"');


    ################################################################
    ## The following create filters.  Filters can be used to select
    ## on multiple zephyrs for operations.  With 'views' you can 
    ## look at only the zephyrs matching a particular filter.
    ## Use the 'view <filtername>' command or the 'v' key to switch views.
    ## The 'V' key will switch you back to your 'view_home' view.
    ## The M-D key will delete all messages in the current view
    ##
    ##
    ## The filter command creates a filter with the specified name,
    ## or if one already exists it is replaced.  Example filter
    ## syntax would be:                                        
    ##
    ##    filter myfilter -c red ( class ^foobar$ ) or ( class ^quux$ and instance ^bar$ )
    ##
    ## Valid matching fields are class, instance, recipient, sender, opcode
    ## and realm.  Valid operations are 'and', 'or' and 'not'.  Spaces must be
    ## present before and after parenthesis.  If the optional color argument
    ## is used it specifies the color that messages matching this filter
    ## should be displayed in.  Do 'show colors' to see the available colors.
    ## 
    ################################################################

    ## This would create a shortcut to only show personal messages
    ## with filter 'me' and to color them yellow.
    ## Replace myusername with yours.
    # owl::command('filter me -c yellow recipient myusername');

    ## This would create a 'quiet' filter to not show messages
    ## on noisy classes and instances.
    # owl::command('filter quiet not ( class ^foo|bar|quux$ or instance ( ^baaz$ ) ');

    ## The 'trash' filter is used when you press 'T' to mark things
    ## for autodeletion.
    # owl::command('filter trash class ^mail$ or opcode ^ping$ or type ^admin$ or class ^login$');   

}

## This is run when owl exits.  Currently this does nothing.
sub owl::shutdown {
}

## This is run to format the contents of the message.
## It returns a string which is a formatted message.
## The following variables will be set each time before this is run:
##
##     $owl::class, $owl::instance, $owl::recipient,
##     $owl::sender, $owl::opcode, $owl::zsig,
##     $owl::msg, $owl::time, $owl::host, @owl::fields, $owl::id

sub owl::format_msg {
    my $out, $tmp;

    ## Strip out noise from the sender string.
    $owl::sender=~s/\@ATHENA\.MIT\.EDU$//;
    $owl::sender=~s/\@local-realm$//;
    $owl::recipient=~s/\@ATHENA\.MIT\.EDU$//;
    $owl::recipient=~s/\@local-realm$//;

    ## Format ping, login, and mail messages.
    ## uc(foo) upcases the string and "eq" does string comparison.
    if (uc($owl::opcode) eq "PING") {
	return("\@bold(PING) from \@bold($owl::sender)\n");
    } elsif (uc($owl::class) eq "LOGIN") {
	if (uc($owl::opcode) eq "USER_LOGIN") {
	    $out="\@bold(LOGIN)";
	} elsif (uc($owl::opcode) eq "USER_LOGOUT") {
	    $out="\@bold(LOGOUT)";
	} else {
	    $out="\@bold(UNKNOWN)";
	}
	$out.=" for \@bold($owl::sender) at $fields[0] on $fields[2]\n";
	return($out);
    } elsif (uc($owl::class) eq "MAIL" and uc($owl::instance) eq "INBOX") {
	$out = "\@bold(MAIL) ";
	if ($owl::msg =~ /^From:\s+(.+)\s*$/m) { $out .= "From $1 "; }
	if ($owl::msg =~ /^To:\s+(.+)\s*$/m) { $out .= "To $1 "; }
	if ($owl::msg =~ /^Subject:\s+(.+)\s*$/m) { $out .= "Subject $1 "; }
	return($out."\n");
    }

    ## The remainder formats normal messages (eg, to classes and instances).
    ## Outgoing messages have different headers than incoming messages.
    ## Note that:
    ##   $out .= "foo";  appends "foo" to the end of the variable $out.
    ##   lc(bar) will convert bar to lowercase.    
    ##   "ne" does "not equal" for string comparison.
    ##   sprintf fills in the %s's with the arguments later on the line.
    ##   "foo"."bar" will append the two strings together.


    if ($owl::direction eq "out") {
	# Outgoing messages

	$out .= sprintf "[outgoing to %s] / %s", $owl::recipient, $owl::time;
	if ($owl::opcode ne "") {$out.=" op:$owl::opcode";}
	$out.="\n";
	$out.= "  \@bold($owl::sender)> ";
	if ($owl::zsig ne "") {
	    my $zsig = $owl::zsig;
	    $zsig =~ s/(\n.*)+$/ [...]/;
	    if (length($zsig)+5+length($owl::sender) > 70) {
		$out.="# ...";
	    } else {
		$out.="# $zsig";
	    }
	}
    } else {
	# Incoming messages

	$out .= sprintf "[mit,%s,%s] / %s / %s", lc($owl::class), 
	                lc($owl::instance), $owl::time, lc($owl::host);
	if ($owl::opcode ne "") {$out.=" op:$owl::opcode";}
	$out.="\n";
	$out.= "  \@bold($owl::sender)> ";
	if ($owl::zsig ne "") {
	    my $zsig = $owl::zsig;
	    $zsig =~ s/(\n.*)+$/ [...]/;
	    if (length($zsig)+5+length($owl::sender) > 70) {
		$out.="# ...";
	    } else {
		$out.="# $zsig";
	    }
	}
    }
    $out.="\n";		

    # This indents the body of the message and then appends it on.
    $tmp=$owl::msg;
    $tmp=~s/^/    /g;
    $tmp=~s/\n/\n    /g;
    $out.=$tmp;

    # This makes personal messages bold.
    if (uc($owl::class) eq "MESSAGE" &&
	uc($owl::instance) eq "PERSONAL" &&
       $owl::direction eq "in") {
	$out="\@bold{".$out."}";
    }

    # Finally, this appends a newline and returns the formatted message.
    return($out."\n");
}

## This is run when a message is received, and after
## it has been added to the message list.
## In most cases you won't need anything here.
sub owl::receive_msg() {
    
    ## If this is uncommented, it would mark all messages
    ## with opcode "PING" for immediate deletion:
    #
    # if (uc($owl::opcode) eq "PING") {
    #    owl::command("delete -id $owl::id");
    # }

    ## If this is uncommented, it would mark all messages
    ## with class "LOGIN" for immediate deletion:
    #
    # if (uc($owl::login) eq "LOGIN") {
    #    owl::command("delete -id $owl::id");
    # }

    return 1;
}