You are not logged in.
I've tested a few scripts, such as fnotify.pl which logs notifications of username in irssi to a file, and want to know if anyone knows how I can get libnotify to bring up a notification whenever something is sent to this file.
Here's fnotify.pl
# todo: grap topic changes
use strict;
use vars qw($VERSION %IRSSI);
use Irssi;
$VERSION = '0.0.3';
%IRSSI = (
authors => 'Thorsten Leemhuis',
contact => 'fedora@leemhuis.info',
name => 'fnotify',
description => 'Write a notification to a file that shows who is talking to you in which channel.',
url => 'http://www.leemhuis.info/files/fnotify/',
license => 'GNU General Public License',
changed => '$Date: 2007-01-13 12:00:00 +0100 (Sat, 13 Jan 2007) $'
);
#--------------------------------------------------------------------
# In parts based on knotify.pl 0.1.1 by Hugo Haas
# http://larve.net/people/hugo/2005/01/knotify.pl
# which is based on osd.pl 0.3.3 by Jeroen Coekaerts, Koenraad Heijlen
# http://www.irssi.org/scripts/scripts/osd.pl
#
# Other parts based on notify.pl from Luke Macken
# http://fedora.feedjack.org/user/918/
#
#--------------------------------------------------------------------
#--------------------------------------------------------------------
# Private message parsing
#--------------------------------------------------------------------
sub priv_msg {
my ($server,$msg,$nick,$address,$target) = @_;
filewrite($nick." " .$msg );
}
#--------------------------------------------------------------------
# Printing hilight's
#--------------------------------------------------------------------
sub hilight {
my ($dest, $text, $stripped) = @_;
if ($dest->{level} & MSGLEVEL_HILIGHT) {
filewrite($dest->{target}. " " .$stripped );
}
}
#--------------------------------------------------------------------
# The actual printing
#--------------------------------------------------------------------
sub filewrite {
my ($text) = @_;
# FIXME: there is probably a better way to get the irssi-dir...
open(FILE,">>$ENV{HOME}/.irssi/fnotify");
print FILE $text . "\n";
close (FILE);
}
#--------------------------------------------------------------------
# Irssi::signal_add_last / Irssi::command_bind
#--------------------------------------------------------------------
Irssi::signal_add_last("message private", "priv_msg");
Irssi::signal_add_last("print text", "hilight");
#- end
Edit: Additionally, I found another script that was mentioned being put into /usr/bin or other similar directory, which was irssi-notification.sh, and run it
Here's irssi-notification.sh:
#!/bin/sh
tail -F ~/.irssi/fnotify | sed -u 's/[<@&]//g' |while read heading message
do notify-send -i gtk-dialog-info -t 300000 -- "${heading}" "${message}"
done
Thanks in advance.
Last edited by Neikron (2011-05-04 03:52:03)
Offline
i am using this script with irssi so libnotify can spam me when i get private message or someone mentions my name.
It is little bit edited for my needs. rotcbot function but otherwise it is same as original.
##
## Put me in ~/.irssi/scripts, and then execute the following in irssi:
##
## /load perl
## /script load notify
##
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "0.01";
%IRSSI = (
authors => 'Luke Macken, Paul W. Frields',
contact => 'lewk@csh.rit.edu, stickster@gmail.com',
name => 'notify.pl',
description => 'Use libnotify to alert user to hilighted messages',
license => 'GNU General Public License',
url => 'http://lewk.org/log/code/irssi-notify',
);
Irssi::settings_add_str('notify', 'notify_icon', '/home/martins/.icons/irssi.png');
Irssi::settings_add_str('notify', 'notify_time', '5000');
Irssi::settings_add_str('notify', 'rotc', '/usr/share/pixmaps/rotc-ethernet.png');
sub notify {
my ($server, $summary, $message) = @_;
# Make the message entity-safe
$message =~ s/&/&/g; # That could have been done better.
$message =~ s/</</g;
$message =~ s/>/>/g;
$message =~ s/'/'/g;
my $cmd = "EXEC - notify-send" .
" -i " . Irssi::settings_get_str('notify_icon') .
" -t " . Irssi::settings_get_str('notify_time') .
" '" . $summary . "'" .
" '" . $message . "'";
$server->command($cmd);
}
sub rotc {
my ($server, $summary, $message) = @_;
# Make the message entity-safe
$message =~ s/&/&/g; # That could have been done better.
$message =~ s/</</g;
$message =~ s/>/>/g;
$message =~ s/'/'/g;
my $cmd = "EXEC - notify-send" .
" -i " . Irssi::settings_get_str('rotc') .
" -t " . Irssi::settings_get_str('notify_time') .
" '" . $summary . "'" .
" '" . $message . "'";
$server->command($cmd);
}
sub print_text_notify {
my ($dest, $text, $stripped) = @_;
my $server = $dest->{server};
return if (!$server || !($dest->{level} & MSGLEVEL_HILIGHT));
notify($server, $dest->{target}, $stripped);
}
sub private_msg_notify {
my ($server, $msg, $nick, $address) = @_;
return if (!$server);
if ($nick eq "rotcbot") {
rotc($server, "ROTC: Ethernet", $msg);
} else {
notify($server, "Private message from ".$nick, $msg);
}
}
Irssi::signal_add('print text', 'print_text_notify');
Irssi::signal_add('message private', 'private_msg_notify');
Offline
A few questions about that, kurrata:
Earlier, it mentions a notify_icon. Do I need to assign that to something? What is irssi.png exactly?
Also, is this the only thing you needed to do? Did you have to do anything to libnotify?
Offline