Created
October 3, 2013 00:41
-
-
Save Goles/6802801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use vars qw($VERSION %IRSSI); | |
use Irssi; | |
$VERSION = '1.0.0'; | |
%IRSSI = ( | |
authors => 'Brandon Black', | |
contact => '[email protected]', | |
name => 'irssi-osx-notify', | |
description => 'OS X Notifications for Irssi.', | |
url => 'https://gist.github.com/brandonblack/6056455', | |
license => 'GNU General Public License', | |
changed => '$Date: 2013-07-22 12:00:00 +0100 (Mon, 22 Jul 2013) $' | |
); | |
#-------------------------------------------------------------------- | |
# Requires terminal-notifier (https://github.com/alloy/terminal-notifier): | |
# | |
# gem install terminal-notifier | |
# | |
# Based on the following previous works: | |
# | |
# fnotify.pl 0.0.3 by Thorsten Leemhuis | |
# http://www.leemhuis.info/files/fnotify/fnotify | |
# | |
# knotify.pl 0.1.1 by Hugo Haas | |
# http://larve.net/people/hugo/2005/01/knotify.pl | |
# | |
# osd.pl 0.3.3 by Jeroen Coekaerts, Koenraad Heijlen | |
# http://www.irssi.org/scripts/scripts/osd.pl | |
# | |
# 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 ); | |
system("terminal-notifier -title '".$nick."' -message '".$msg."'"); | |
} | |
#-------------------------------------------------------------------- | |
# Printing hilight's | |
#-------------------------------------------------------------------- | |
sub hilight { | |
my ($dest, $text, $stripped) = @_; | |
if ($dest->{level} & MSGLEVEL_HILIGHT) { | |
filewrite($dest->{target}. " " .$stripped ); | |
system("terminal-notifier -title '".$dest->{target}."' -message '".$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/irssi-osx-notify"); | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment