-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlowlightwin.pl
133 lines (100 loc) · 3.63 KB
/
lowlightwin.pl
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
#
# Print all messages to a window named 'lowlight'
# irssi 0.8.15-svn
# by rking + billnye & kalikiana (on Freenode)
=head1
The opposite of [hilightwin.pl](https://scripts.irssi.org/scripts/hilightwin.pl)
Though hilightwin.pl's goals are to show you all the text that is aimed at you
(nick-pings and privmsg's), lowlightwin.pl shows you the opposite -- all the
rest of the text.
This is good if you are interested enough in a channel to idle in it, but not
enought to make the effort to switch to that window repeatedly.
Installation
------------
1. `mkdir -p ~/.irssi/scripts/autorun` # (If it's not already there)
2. `(cd ~/.irssi/scripts; curl -O https://raw.githubusercontent.com/ryanjosephking/irssi-lowlightwin/master/lowlightwin.pl)`
3. `ln -vsf ~/.irssi/scripts/{lowlightwin.pl,autorun}`
4. `/load lowlightwin.pl` # (or restart irssi)
5. `/win new` then `/win name lowlight` then `/win down` # See
[irssisplit](http://quadpoint.org/articles/irssisplit) to attempt to make
sense of this.
6. Play around with `/win grow` and `/win shrink`
7. When you get things right, `/layout save` then `/save`
Updating
--------
Perform steps #2 and #4, above.
Configuration
-------------
You can do:
/set lowlight_ignore #noisychan1,#noisychan2
To skip all traffic on those channels (or nicks).
Also, there is:
/set lowlight_say_less on
...which will cause these to be silenced (from /help levels):
- CLIENTNOTICE - Irssi's notices
- CLIENTERROR - Irssi's error messages
- CLIENTCRAP - Some other messages from Irssi
The most noticeable change is that information that would've gone to your
"(status)" window will no longer be part of the lowlight window.
Complaints to:
--------------
<rking@panoptic.com>
=cut
use Irssi;
use POSIX;
use vars qw($VERSION %IRSSI);
our $NAME = 'lowlight';
$VERSION = "0.3";
%IRSSI = (
authors => "rking",
contact => "rking\@panoptic.com",
name => $NAME,
description => "Prefix and print all messages to window named \"$NAME\"",
license => "Public Domain",
url => "http://irssi.org/",
changed => "Fri Apr 27 03:41:00 EDT 2012",
);
Irssi::settings_add_bool('lowlight', 'lowlight_say_less', "0");
Irssi::settings_add_str('lowlight', 'lowlight_ignore', "");
# lifted from nickcolor.pl
my @colors = qw/31 32 33 34 35 36 37/;
sub simple_hash {
my ($string) = @_;
chomp $string;
my @chars = split //, $string;
my $counter;
foreach my $char (@chars) {
$counter += ord $char;
}
$counter = $colors[$counter % 11];
return $counter;
}
sub sig_printtext {
my ($dest, $text, $stripped) = @_;
$window = Irssi::window_find_name($NAME);
my $hush = MSGLEVEL_NEVER|MSGLEVEL_JOINS|MSGLEVEL_PARTS|
MSGLEVEL_NICKS|MSGLEVEL_QUITS;
$hush |= MSGLEVEL_NOTICES|MSGLEVEL_CLIENTNOTICE|MSGLEVEL_CLIENTCRAP
if Irssi::settings_get_bool('lowlight_say_less');
return if $dest->{level} & $hush;
my @ignores = split /[, ]+/, Irssi::settings_get_str('lowlight_ignore');
for (@ignores) {
return if $dest->{target} eq $_;
}
if (
$dest->{level} & MSGLEVEL_PUBLIC and not $dest->{level} & $hush
) {
$color_esc = "\e[" . simple_hash($dest->{target}) . ";1m";
$text = "$color_esc$dest->{target}\e[10;1m\e[0m: $text";
}
$text =~ s/%/%%/g; # don't show %r as red, etc.
$text = strftime(
Irssi::settings_get_str('timestamp_format')." ",
localtime
) . $text;
$window->print($text, MSGLEVEL_NEVER) if ($window);
}
$window = Irssi::window_find_name($NAME);
Irssi::print("Create a window named '$NAME'") if (!$window);
Irssi::signal_add('print text', 'sig_printtext');
# vim:set ts=4 sw=4 et: