sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 7f3ca63fcb77eae97feec5df30bf173093951664
parent 0dca202bf79e29421be5ebf9d65306e3077e6068
Author: Kris Maglione <maglione.k@gmail.com>
Date:   Fri, 30 Oct 2009 04:47:15 -0400

Update wmii irc notifier.
Diffstat:
Mwmii.suckless.org/code_snippets/plan_9_port/irssi_notifier.md | 37+++++++++++++++++++------------------
Awmii.suckless.org/code_snippets/python/irssi_notifier.md | 102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 121 insertions(+), 18 deletions(-)

diff --git a/wmii.suckless.org/code_snippets/plan_9_port/irssi_notifier.md b/wmii.suckless.org/code_snippets/plan_9_port/irssi_notifier.md @@ -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: @@ -27,11 +32,15 @@ This portion goes in your rc.wmii.local, or can be modified to run standalone: 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@gmail.com> wrote this file. As long as you retain this notice you + # <maglione.k@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 # --------------------------------------------------------------------------- @@ -42,10 +51,10 @@ This portion is a perl script for irssi. It should go in `~/.irssi/scripts`, and use strict; - our $VERSION = '20070524'; + our $VERSION = '20091030'; our %IRSSI = ( authors => 'Kris Maglione', - contact => 'bsdaemon@comcast.net', + contact => 'maglione.k@gmail.com', name => 'notify', description => 'Writes certain messages to the wmii event FIFO', license => 'BEER-WARE', @@ -79,10 +88,7 @@ This portion is a perl script for irssi. It should go in `~/.irssi/scripts`, and my $target = shift; my @notifies = split /,\s*/, Irssi::settings_get_str('notify_channels'); - if (grep { $_ eq "*" || $_ eq $target } @notifies) { - return 1; - } - + return 1 if grep { $_ eq "*" || $_ eq $target } @notifies; 0; } @@ -90,14 +96,9 @@ This portion is a perl script for irssi. It should go in `~/.irssi/scripts`, and Irssi::signal_add('message public', 'message_handler'); Irssi::settings_add_str('misc', 'notify_channels', ''); -There is another way to set the label: - -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. - -Content of ` ~/.irssi/scripts/autorun/title.pl`: - - system('~/.irssi/scripts/title.pl irssi'); +You can also set the label as required, if you so choose, from the IRSSI +plugin as so: -This will nicely set the title for irssi. + open my $tty, '>', '/dev/tty'; + print $tty "\033]0;irssi\007"; diff --git a/wmii.suckless.org/code_snippets/python/irssi_notifier.md b/wmii.suckless.org/code_snippets/python/irssi_notifier.md @@ -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@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@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@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) = @_; + 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 @notifies = split /,\s*/, Irssi::settings_get_str('notify_channels'); + + return 1 if grep { $_ eq "*" || $_ eq $target } @notifies; + 0; + } + + Irssi::signal_add('message private', 'message_handler'); + Irssi::signal_add('message public', 'message_handler'); + Irssi::settings_add_str('misc', 'notify_channels', ''); +