#!/usr/bin/perl -wT # based and inspired on # http://jaredquinn.info/it-related/technical/unix/2007.09.25/libnotify-with-irssi-over-ssh/ use strict; $ENV{PATH} = '/bin:/usr/bin'; my $icon = "gtk-dialog-info"; my $timeout = 5000; my $urgency = "normal"; my $content = ""; my $category = "Message"; my $subject = ""; sub unmarshall(\$) { my $foo = shift; ${$foo} =~ s/\\\\/\\/g; ${$foo} =~ s/\\n/\n/g; # escape it as well ${$foo} =~ s/&/&/g; ${$foo} =~ s/'/'/g; ${$foo} =~ s/"/"/g; ${$foo} =~ s/>/>/g; ${$foo} =~ s/) { if (/^([A-Z]+)\s+(.+?)\s*$/) { $category = $2 if ($1 eq 'CATEGORY'); $icon = $2 if ($1 eq 'ICON'); $content = $2 if ($1 eq 'CONTENT'); $timeout = $2 if ($1 eq 'TIMEOUT'); $subject = $2 if ($1 eq 'SUBJECT'); $urgency = $2 if ($1 eq 'URGENCY'); } } exit unless ($content or $subject); unmarshall($category); unmarshall($icon); unmarshall($content); unmarshall($timeout); unmarshall($subject); unmarshall($urgency); my $CMD = "notify-send -i '$icon' -c '$category' -u '$urgency' -t $timeout -- '$subject' '$content'"; print $CMD; system($CMD);