source: examples/owlconf.erik @ 0236842

barnowl_perlaimdebianowlrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 0236842 was 039213e, checked in by Erik Nygren <nygren@mit.edu>, 19 years ago
Changed default of maxwrapcols to 0 and made docs more clear.
  • Property mode set to 100644
File size: 7.6 KB
RevLine 
[7d4fbcd]1### The owlconf config file   -*- perl -*- 
2###  $Id$
[b950088]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
[7d4fbcd]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###
35###     $owl::class, $owl::instance, $owl::recipient,
36###     $owl::sender, $owl::opcode, $owl::zsig,
37###     $owl::msg, $owl::time, $owl::host, @owl::fields, $owl::id
38###   
39
40# tokens for sepbar are:
41#    .username = ping
42#    >username = login
43#    <username = logout
44#    :username = personal message
45#    M         = mail received
46my @sepbartokens = ();
47
48
49# adds a sepbartoken and also updates the appendtosepbar variable
50sub sepbartokens_add {
51    my ($token) = @_;
52    $token =~ s/"//g;  # "
53    unshift @sepbartokens, $token;
54    pop @sepbartokens if (@sepbartokens > 80);
55    sepbartokens_set();
56}
57
58# trims a sepbartoken from the list also updates the appendtosepbar variable
59sub sepbartokens_trim {
60    my ($token) = @_;
61    @sepbartokens = map { if ($_ ne $token) { $_; } else { (); } } @sepbartokens;
62    sepbartokens_set();
63}
64
65# trims a sepbartoken from the list also updates the appendtosepbar variable
66sub sepbartokens_set {
67    owl::command(sprintf "set -q appendtosepbar \"%s\"", (join " ", @sepbartokens));
68}
69
[8ee73f8d]70my $restoreview = undef;
71sub swapview {
72    my $curview = owl::command("getview");
73    if ($restoreview) {
74        owl::command("view $restoreview");
75        $restoreview = undef;
76    } else {
77        $restoreview = $curview;
78        owl::command("smartnarrow");
79    }
80}
81
82my $lastcolored = undef;
83sub colorthread {
84    if ($lastcolored) {
85        owl::command("filter $lastcolored -c default");
86    }
87    my $smartfilt = owl::command("smartfilter");
88    if (!$smartfilt or $smartfilt eq $lastcolored) {
89        owl::command("filter $lastcolored -c default");
90        $lastcolored = undef;
91    } else {
92        owl::command("filter $smartfilt -c green");
93        $lastcolored = $smartfilt;
94    }
95}
96
[7d4fbcd]97sub owl::startup {
98    owl::command("set -q logging off");
99    owl::command("set -q zsigproc /home/nygren/bin/owlzsigs");
100    owl::command("set -q startuplogin off");
101    owl::command("set -q shutdownlogout off");
102    #owl::command("set personalbell on");
103    owl::command("set -q rxping on");
104    owl::command("set -q typewinsize 5");
105    if ($ENV{"DISPLAY"} eq ":0") {
106      owl::command("set -q webbrowser galeon"); 
107    }
108    owl::command("filter me recipient ".$ENV{"USER"});
109    owl::command("filter help class help");
110    owl::command("filter quiet not ( class ^greed|geek|help|login$ or instance white-magic )");   
111
112    owl::command("alias z zwrite");
113    owl::command("alias zc zwrite -c");
114
[b950088]115    # Send zephyrs with "C-c C-c". 
116    # Note that this will cause "C-c" to not work...
[7d4fbcd]117    owl::command("bindkey editmulti \"C-c C-c\" command editmulti:done");
[b950088]118
119    # Make "d" ignore current movement direction
120    owl::command("bindkey recv d command ( delete --no-move ; next --skip-deleted )");
121
122    # Useful keys for reading and deleting by class/instance
[7d4fbcd]123    owl::command("bindkey recv M-k command ( smartnarrow ; delete view )");
124    owl::command("bindkey recv M-l command ( expunge ; view all )");
125    owl::command("bindkey recv M-K command ( smartnarrow ; delete view ; expunge ; view all )");
[b950088]126
[039213e]127    # Toggle between a view and a smartnarrow with TAB.
128    # Note that you probably want to use something other than TAB as
129    # it will have another binding in a future version of owl.
[8ee73f8d]130    owl::command("alias swapview perl swapview();");
131    owl::command("bindkey recv C-i command swapview");
132
133    # color the current thread
134    owl::command("alias colorthread perl colorthread();");
135    owl::command("bindkey recv M-c command colorthread");
136
[b950088]137    # Make 'M-s' insert a <scritchscritchscritch> sequence with a random
138    # number of scritches.
[7d4fbcd]139    owl::command(q(bindkey edit M-s command perl owl::command("edit:insert-text <".("scritch"x int(1+rand(5))).">")));
140
141}
142
143sub owl::shutdown {
144#    not doing anything at the moment...
145}
146
147# run to format a message
148sub owl::format_msg {
149    my $out, $tmp;
150
151    $owl::sender=~s/\@ATHENA\.MIT\.EDU$//;
152    $owl::sender=~s/\@local-realm$//;
153
154    if (uc($owl::opcode) eq "PING") {
155        return("\@bold(PING) from \@bold($owl::sender)\n");
156    } elsif (uc($owl::class) eq "LOGIN") {
157        if (uc($owl::opcode) eq "USER_LOGIN") {
158            $out="\@bold(LOGIN)";
159        } elsif (uc($owl::opcode) eq "USER_LOGOUT") {
160            $out="\@bold(LOGOUT)";
161        } else {
162            $out="\@bold(UNKNOWN)";
163        }
164        $out.=" for \@bold($owl::sender) at $fields[0] on $fields[2]\n";
165        return($out);
166    } elsif (uc($owl::class) eq "MAIL" and uc($owl::instance) eq "INBOX") {
167        $out = "\@bold(MAIL) ";
168        if ($owl::msg =~ /^From:\s+(.+)\s*$/m) { $out .= "From $1 "; }
169        if ($owl::msg =~ /^To:\s+(.+)\s*$/m) { $out .= "To $1 "; }
170        if ($owl::msg =~ /^Subject:\s+(.+)\s*$/m) { $out .= "Subject $1 "; }
171        return($out."\n");
172    }
173
174    $out = sprintf "[mit,%s,%s] / %s / %s", lc($owl::class), 
175                   lc($owl::instance), $owl::time, lc($owl::host);
176    if ($owl::opcode ne "") {$out.=" op:$owl::opcode";}
177    $out.="\n";
178    $out.= "  \@bold($owl::sender)> ";
179    if ($owl::zsig ne "") {
180        my $zsig = $owl::zsig;
181        $zsig =~ s/(\n.*)+$/ [...]/;
182        if (length($zsig)+5+length($owl::sender) > 70) {
183            $out.="# ...";
184        } else {
185            $out.="# $zsig";
186        }
187    }
188    $out.="\n";         
189
190    # indent it
191    $tmp=$owl::msg;
192    $tmp=~s/^/    /g;
193    $tmp=~s/\n/\n    /g;
194    $out.=$tmp;
195
196    # make personal messages bold
197    if (uc($owl::class) eq "MESSAGE" &&
198        uc($owl::instance) eq "PERSONAL") {
199        $out="\@bold{".$out."}";
200    }
201
202    return($out."\n");
203}
204
205# run when a message is received, and after
206# it has been added to the message list.
207sub owl::receive_msg() {
208    my $out, $tmp;
209
210    $owl::sender=~s/\@ATHENA\.MIT\.EDU$//;
211    $owl::sender=~s/\@local-realm$//;
212
213    if (uc($owl::opcode) eq "PING") {
214        sepbartokens_add(".$owl::sender");
215        owl::command("delete -id $owl::id");
216    } elsif (uc($owl::class) eq "LOGIN") {
217        owl::command("delete -id $owl::id");
218        if (uc($owl::opcode) eq "USER_LOGIN") {
219            sepbartokens_add(">$owl::sender");
220            sepbartokens_trim("<$owl::sender");
221        } elsif (uc($owl::opcode) eq "USER_LOGOUT") {
222            sepbartokens_add("<$owl::sender");
223            sepbartokens_trim(">$owl::sender");
224        } 
225    } elsif (uc($owl::class) eq "MAIL") {
226        owl::command("delete -id $owl::id");
227        sepbartokens_add("M");
228    }
229
230
231    # make personal messages bold
232    if (uc($owl::class) eq "MESSAGE" &&
233        uc($owl::instance) eq "PERSONAL") {
234        sepbartokens_trim(".$owl::sender");
235        sepbartokens_add(":$owl::sender");
236    }
237
238    return 1;
239}
Note: See TracBrowser for help on using the repository browser.