summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul W. Frields <stickster@gmail.com>2007-01-28 01:36:01 +0000
committerPaul W. Frields <stickster@gmail.com>2007-01-28 01:36:01 +0000
commit9eed1f6e24b5d8b2ba7551237f62767b49b61288 (patch)
tree55fac378bc12a06c00c0a00c0f44fbe789a9ae1a
parenteda633cb6986b8a12c701320a32b225bec81a376 (diff)
downloadirssi-notify-9eed1f6e24b5d8b2ba7551237f62767b49b61288.tar.gz
irssi-notify-9eed1f6e24b5d8b2ba7551237f62767b49b61288.tar.xz
irssi-notify-9eed1f6e24b5d8b2ba7551237f62767b49b61288.zip
Use dbus instead of libnotify to see if we can make this more portable
git-svn-id: https://irssi-libnotify.googlecode.com/svn/trunk@18 291cbfae-0d27-0410-99d7-557b17e6fe3d
-rw-r--r--notify.pl27
1 files changed, 17 insertions, 10 deletions
diff --git a/notify.pl b/notify.pl
index 67a0b33..fa40e99 100644
--- a/notify.pl
+++ b/notify.pl
@@ -8,6 +8,8 @@
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
+use Net::DBus qw(:typing);
+
$VERSION = "0.01";
%IRSSI = (
@@ -24,20 +26,25 @@ Irssi::settings_add_str('notify', 'notify_time', '5000');
sub notify {
my ($server, $summary, $message) = @_;
+ my $bus = Net::DBus->session;
+ my $svc = $bus->get_service("org.freedesktop.Notifications");
+ my $obj = $svc->get_object("/org/freedesktop/Notifications");
- # Make the message entity-safe
- $message =~ s/&/&amp;/g; # That could have been done better.
+ # Make the message entity-safe. This is all a crappy hack and I'd
+ # love to know a Perl-ish way to do this properly.
+ $message =~ s/&/&amp;/g;
$message =~ s/</&lt;/g;
$message =~ s/>/&gt;/g;
$message =~ s/'/&apos;/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);
+ $obj->Notify("notification.pl",
+ 0,
+ '',
+ $summary,
+ $message,
+ ['Close', 'Close'],
+ {0, 0, 0},
+ 5_000);
}
sub print_text_notify {
@@ -59,7 +66,7 @@ sub dcc_request_notify {
my ($dcc, $sendaddr) = @_;
my $server = $dcc->{server};
- return if (!$dcc);
+ return if (!$server || !$dcc);
notify($server, "DCC ".$dcc->{type}." request", $dcc->{nick});
}