[wiki] [sites] wiki updated

From: <hg_AT_suckless.org>
Date: Fri, 30 Oct 2009 09:38:19 +0000 (UTC)

changeset: 337:eec52902e2c6
tag: tip
user: Kris Maglione <maglione.k_AT_gmail.com>
date: Fri Oct 30 04:47:15 2009 -0400
files: wmii.suckless.org/code_snippets/plan_9_port/irssi_notifier.md wmii.suckless.org/code_snippets/python/irssi_notifier.md
description:
Update wmii irc notifier.


diff -r c6801199770e -r eec52902e2c6 wmii.suckless.org/code_snippets/plan_9_port/irssi_notifier.md
--- a/wmii.suckless.org/code_snippets/plan_9_port/irssi_notifier.md Thu Oct 29 13:17:15 2009 -0700
+++ b/wmii.suckless.org/code_snippets/plan_9_port/irssi_notifier.md Fri Oct 30 04:47:15 2009 -0400
_AT_@ -1,7 +1,12 @@
 Irssi Message Notifier
 ======================
 
-This script notifies you, by setting the Urgent hint on your irssi window, of messages with your nick, or in channels you care about. It can optionally display the messages on the bar. You'll need to set the title of the window running irssi to 'irssi' for this to work. I use `label`(1) from plan9port.
+This script notifies you, by setting the Urgent hint on your irssi window, of
+messages with your nick, or in channels you care about. It can optionally
+display the messages on the bar. You'll need to set the title of the window
+running irssi to 'irssi' for this to work. I use `label`(1) from plan9port.
+
+See also the [../python/irssi_notifier](python version).
 
 This portion goes in your rc.wmii.local, or can be modified to run standalone:
 
_AT_@ -27,11 +32,15 @@
                     wmiir xwrite /client/$1/ctl NotUrgent
     }
 
-This portion is a perl script for irssi. It should go in `~/.irssi/scripts`, and can be loaded with `/script load notify`, or autoloaded by symlinking it into `~/.irssi/scripts/autoload`. The irssi `notify_channels` setting takes a list of channels to always notify you of messages to, or '*' to notify you for all channels.
+This portion is a perl script for irssi. It should go in `~/.irssi/scripts`,
+and can be loaded with `/script load notify`, or autoloaded by symlinking it
+into `~/.irssi/scripts/autorun`. The irssi `notify_channels` setting takes a
+list of channels to always notify you of messages to, or '*' to notify you for
+all channels.
 
     # ---------------------------------------------------------------------------
     # "THE BEER-WARE LICENSE" (Revision 42):
- # <fbsdaemon_AT_gmail.com> wrote this file. As long as you retain this notice you
+ # <maglione.k_AT_gmail.com> wrote this file. As long as you retain this notice you
     # can do whatever you want with this stuff. If we meet some day, and you think
     # this stuff is worth it, you can buy me a beer in return. Kris Maglione
     # ---------------------------------------------------------------------------
_AT_@ -42,10 +51,10 @@
 
     use strict;
 
- our $VERSION = '20070524';
+ our $VERSION = '20091030';
     our %IRSSI = (
             authors => 'Kris Maglione',
- contact => 'bsdaemon_AT_comcast.net',
+ contact => 'maglione.k_AT_gmail.com',
             name => 'notify',
             description => 'Writes certain messages to the wmii event FIFO',
             license => 'BEER-WARE',
_AT_@ -79,10 +88,7 @@
             my $target = shift;
             my _AT_notifies = split /,\s*/, Irssi::settings_get_str('notify_channels');
 
- if (grep { $_ eq "*" || $_ eq $target } _AT_notifies) {
- return 1;
- }
-
+ return 1 if grep { $_ eq "*" || $_ eq $target } _AT_notifies;
             0;
     }
 
_AT_@ -90,14 +96,9 @@
     Irssi::signal_add('message public', 'message_handler');
     Irssi::settings_add_str('misc', 'notify_channels', '');
 
-There is another way to set the label:
+You can also set the label as required, if you so choose, from the IRSSI
+plugin as so:
 
-Use the perl script in at this website: `http://tldp.org/HOWTO/Xterm-Title-7.html#ss7.2`
-And put it into `~/.irssi/scripts/title.pl` for example.
+ open my $tty, '>', '/dev/tty';
+ print $tty "\033]0;irssi\007";
 
-Content of ` ~/.irssi/scripts/autorun/title.pl`:
-
- system('~/.irssi/scripts/title.pl irssi');
-
-This will nicely set the title for irssi.
-
diff -r c6801199770e -r eec52902e2c6 wmii.suckless.org/code_snippets/python/irssi_notifier.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wmii.suckless.org/code_snippets/python/irssi_notifier.md Fri Oct 30 04:47:15 2009 -0400
_AT_@ -0,0 +1,102 @@
+Irssi Message Notifier
+======================
+
+An IRC notifier based on the [../plan9port/irssi_notifier](plan9port version).
+
+This script notifies you when messages containing your nick, private
+messages, or messages in certain important channels, arrive in
+irssi.
+
+First, create `~/.wmii/plugins/irc_notify.py` with the following
+contents:
+
+ from wmiirc import *
+ from pygmi import *
+
+ def isirssi(client):
+ return Client(client).label == 'irssi'
+
+ def irc_message(whom, message):
+ if isirssi('sel'):
+ return
+ for t in Tag.all():
+ for a in t.index:
+ for f in a.frames:
+ if isirssi(f.client):
+ f.client.urgent = True
+ notice.show('IRC: %s %s' % (whom, message))
+ return
+
+ events.bind({
+ Match('ClientFocus', _): lambda e, c: isirssi(c) and setattr(Client(c), 'urgent', False),
+ 'IRCMessage': lambda s: irc_message(*s.split(' ', 2)[1:]),
+ })
+
+This portion is a perl script for irssi. It should go in
+`~/.irssi/scripts`, and can be loaded with `/script load notify`, or
+autoloaded by symlinking it into `~/.irssi/scripts/autorun`. The
+irssi `notify_channels` setting takes a list of channels to always
+notify you of messages to, or '*' to notify you for all channels.
+
+ # ---------------------------------------------------------------------------
+ # "THE BEER-WARE LICENSE" (Revision 42):
+ # <maglione.k_AT_gmail.com> wrote this file. As long as you retain this notice you
+ # can do whatever you want with this stuff. If we meet some day, and you think
+ # this stuff is worth it, you can buy me a beer in return. Kris Maglione
+ # ---------------------------------------------------------------------------
+ # <phk_AT_FreeBSD.ORG> wrote this license. As long as you retain this notice you
+ # can do whatever you want with this stuff. If we meet some day, and you think
+ # this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ # ---------------------------------------------------------------------------
+
+ use strict;
+
+ our $VERSION = '20091030';
+ our %IRSSI = (
+ authors => 'Kris Maglione',
+ contact => 'maglione.k_AT_gmail.com',
+ name => 'notify',
+ description => 'Writes certain messages to the wmii event FIFO',
+ license => 'BEER-WARE',
+ url => '',
+ changed => $VERSION,
+ modules => '',
+ );
+
+ use Irssi;
+ use Fcntl;
+
+ open my $tty, '>', '/dev/tty';
+ print $tty "\033]0;irssi\007";
+ close $tty;
+
+ sub should_notify ($);
+
+ sub message_handler {
+ my ($server, $mesg, $nick, $address, $target) = _AT__;
+ my $mynick = $server->{nick};
+
+ if (not defined $target
+ or should_notify($target)
+ or $mesg =~ /\b$mynick\b/) {
+ $mesg =~ s/\n/\\n/g;
+ $target = ($target ? " in $target" : "");
+
+ open my $fifo, '| wmiir write /event' or return;
+ print $fifo "IRCMessage from $nick$target: $mesg\n";
+ close $fifo;
+ }
+ }
+
+ sub should_notify ($) {
+ my $target = shift;
+ my _AT_notifies = split /,\s*/, Irssi::settings_get_str('notify_channels');
+
+ return 1 if grep { $_ eq "*" || $_ eq $target } _AT_notifies;
+ 0;
+ }
+
+ Irssi::signal_add('message private', 'message_handler');
+ Irssi::signal_add('message public', 'message_handler');
+ Irssi::settings_add_str('misc', 'notify_channels', '');
+
Received on Fri Oct 30 2009 - 10:38:19 CET

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:30:57 CEST