source: examples/owlconf.erik @ b950088

barnowl_perlaimdebianowlrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since b950088 was b950088, checked in by Erik Nygren <nygren@mit.edu>, 19 years ago
* Added --no-move option to delete command. In particular, delete-and-always-move-down may now be implemented with '( delete --no-move ; next --skip-deleted )'. * Folded the nextmsg and prevmsg commands and functions together into one command which takes arguments. Added '--filter <name>' option (eg, for next_personal), '--skip-deleted' option, and '--last-if-none'/'--first-if-none' options. Help updated accordingly. In particular, the 'personal' view is now used for 'next personal'. * Updated examples/owlconf.erik with the above.
  • Property mode set to 100644
File size: 6.5 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###
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
70sub owl::startup {
71    owl::command("set -q logging off");
72    owl::command("set -q zsigproc /home/nygren/bin/owlzsigs");
73    owl::command("set -q startuplogin off");
74    owl::command("set -q shutdownlogout off");
75    #owl::command("set personalbell on");
76    owl::command("set -q rxping on");
77    owl::command("set -q typewinsize 5");
78    if ($ENV{"DISPLAY"} eq ":0") {
79      owl::command("set -q webbrowser galeon"); 
80    }
81    owl::command("filter me recipient ".$ENV{"USER"});
82    owl::command("filter help class help");
83    owl::command("filter quiet not ( class ^greed|geek|help|login$ or instance white-magic )");   
84
85    owl::command("alias z zwrite");
86    owl::command("alias zc zwrite -c");
87
88    # Send zephyrs with "C-c C-c". 
89    # Note that this will cause "C-c" to not work...
90    owl::command("bindkey editmulti \"C-c C-c\" command editmulti:done");
91
92    # Make "d" ignore current movement direction
93    owl::command("bindkey recv d command ( delete --no-move ; next --skip-deleted )");
94
95    # Useful keys for reading and deleting by class/instance
96    owl::command("bindkey recv M-k command ( smartnarrow ; delete view )");
97    owl::command("bindkey recv M-l command ( expunge ; view all )");
98    owl::command("bindkey recv M-K command ( smartnarrow ; delete view ; expunge ; view all )");
99
100    # Make 'M-s' insert a <scritchscritchscritch> sequence with a random
101    # number of scritches.
102    owl::command(q(bindkey edit M-s command perl owl::command("edit:insert-text <".("scritch"x int(1+rand(5))).">")));
103
104}
105
106sub owl::shutdown {
107#    not doing anything at the moment...
108}
109
110# run to format a message
111sub owl::format_msg {
112    my $out, $tmp;
113
114    $owl::sender=~s/\@ATHENA\.MIT\.EDU$//;
115    $owl::sender=~s/\@local-realm$//;
116
117    if (uc($owl::opcode) eq "PING") {
118        return("\@bold(PING) from \@bold($owl::sender)\n");
119    } elsif (uc($owl::class) eq "LOGIN") {
120        if (uc($owl::opcode) eq "USER_LOGIN") {
121            $out="\@bold(LOGIN)";
122        } elsif (uc($owl::opcode) eq "USER_LOGOUT") {
123            $out="\@bold(LOGOUT)";
124        } else {
125            $out="\@bold(UNKNOWN)";
126        }
127        $out.=" for \@bold($owl::sender) at $fields[0] on $fields[2]\n";
128        return($out);
129    } elsif (uc($owl::class) eq "MAIL" and uc($owl::instance) eq "INBOX") {
130        $out = "\@bold(MAIL) ";
131        if ($owl::msg =~ /^From:\s+(.+)\s*$/m) { $out .= "From $1 "; }
132        if ($owl::msg =~ /^To:\s+(.+)\s*$/m) { $out .= "To $1 "; }
133        if ($owl::msg =~ /^Subject:\s+(.+)\s*$/m) { $out .= "Subject $1 "; }
134        return($out."\n");
135    }
136
137    $out = sprintf "[mit,%s,%s] / %s / %s", lc($owl::class), 
138                   lc($owl::instance), $owl::time, lc($owl::host);
139    if ($owl::opcode ne "") {$out.=" op:$owl::opcode";}
140    $out.="\n";
141    $out.= "  \@bold($owl::sender)> ";
142    if ($owl::zsig ne "") {
143        my $zsig = $owl::zsig;
144        $zsig =~ s/(\n.*)+$/ [...]/;
145        if (length($zsig)+5+length($owl::sender) > 70) {
146            $out.="# ...";
147        } else {
148            $out.="# $zsig";
149        }
150    }
151    $out.="\n";         
152
153    # indent it
154    $tmp=$owl::msg;
155    $tmp=~s/^/    /g;
156    $tmp=~s/\n/\n    /g;
157    $out.=$tmp;
158
159    # make personal messages bold
160    if (uc($owl::class) eq "MESSAGE" &&
161        uc($owl::instance) eq "PERSONAL") {
162        $out="\@bold{".$out."}";
163    }
164
165    return($out."\n");
166}
167
168# run when a message is received, and after
169# it has been added to the message list.
170sub owl::receive_msg() {
171    my $out, $tmp;
172
173    $owl::sender=~s/\@ATHENA\.MIT\.EDU$//;
174    $owl::sender=~s/\@local-realm$//;
175
176    if (uc($owl::opcode) eq "PING") {
177        sepbartokens_add(".$owl::sender");
178        owl::command("delete -id $owl::id");
179    } elsif (uc($owl::class) eq "LOGIN") {
180        owl::command("delete -id $owl::id");
181        if (uc($owl::opcode) eq "USER_LOGIN") {
182            sepbartokens_add(">$owl::sender");
183            sepbartokens_trim("<$owl::sender");
184        } elsif (uc($owl::opcode) eq "USER_LOGOUT") {
185            sepbartokens_add("<$owl::sender");
186            sepbartokens_trim(">$owl::sender");
187        } 
188    } elsif (uc($owl::class) eq "MAIL") {
189        owl::command("delete -id $owl::id");
190        sepbartokens_add("M");
191    }
192
193
194    # make personal messages bold
195    if (uc($owl::class) eq "MESSAGE" &&
196        uc($owl::instance) eq "PERSONAL") {
197        sepbartokens_trim(".$owl::sender");
198        sepbartokens_add(":$owl::sender");
199    }
200
201    return 1;
202}
Note: See TracBrowser for help on using the repository browser.