From 9de78532a6a8222598b45737d6d655d6eb9688d2 Mon Sep 17 00:00:00 2001 From: eleksir Date: Sun, 18 Sep 2016 02:35:57 +0300 Subject: [PATCH] added desktop notification script for hexchat --- hexchat-notification.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 hexchat-notification.pl diff --git a/hexchat-notification.pl b/hexchat-notification.pl new file mode 100644 index 0000000..0b0f104 --- /dev/null +++ b/hexchat-notification.pl @@ -0,0 +1,24 @@ +use strict; +use warnings "all"; + +sub hookfn; +my $script_name = "Notification plugin"; +HexChat::register($script_name, '0.1', 'Sends *nix desktop notifications'); + +HexChat::print("$script_name loaded\n"); +HexChat::hook_print('Channel Message', \&hookfn); +HexChat::hook_print('Channel Msg Hilight', \&hookfn); +HexChat::hook_print('Channel Action', \&hookfn); +HexChat::hook_print('Channel Action Hilight', \&hookfn); + +sub hookfn { + my ($nick, $text, $modechar) = @{$_[0]}; + my $channel = HexChat::get_info('channel'); + $channel = '' unless(defined($channel)); + $nick = '' unless(defined($nick)); + $text = '' unless(defined($text)); + $text =~ s/\"/\\"/g; + my $topic = sprintf("%s at %s says:", $nick, $channel); + `notify-send -u normal -t 10000 -a hexchat "$topic" -i hexchat "$text" &`; + return HexChat::EAT_NONE; +}