Created
November 24, 2009 17:12
-
-
Save zaphar/242028 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/perl -w | |
| use Mac::Growl qw{:all}; | |
| use Getopt::Long; | |
| =pod | |
| Put this script in a your $PATH and set it to be executable. | |
| =cut | |
| my ($app, $title, $msg); | |
| GetOptions( | |
| 'app=s' => \$app, | |
| 'message=s' => \$msg, | |
| 'title=s' => \$title, | |
| ); | |
| RegisterNotifications($app, | |
| [$app. 'Notification'], | |
| [$app. 'Notification'], | |
| ); | |
| PostNotification($app, $app . 'Notification', $title, $msg); |
This file contains hidden or 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 Irssi; | |
| use IO::Pipe; | |
| use vars qw($VERSION %IRSSI); | |
| $VERSION = "0.01"; | |
| %IRSSI = ( | |
| authors => 'Jeremy Wall (zaphar) <jeremy@marzhillstudios.com>', | |
| contact => 'jeremy@marzhillstudios.com', | |
| name => "hilight-notify", | |
| description => "outputs a configurable notification for mentions of hilight", | |
| license => "Artistic License", | |
| url => "http://gist.github.com/", | |
| changed => "2009-11-14T20:58:00+0600" | |
| ); | |
| =pod | |
| Place this script in your irssi plugin directory. Use scripts/autoload if you want it to load automatically when you launch irssi. | |
| =cut | |
| sub sig_printtext { | |
| my ($dest, $text, $stripped) = @_; | |
| if (($dest->{level} & (MSGLEVEL_HILIGHT|MSGLEVEL_MSGS)) && | |
| ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0) { | |
| send_notification($dest->{target}, $text); | |
| } | |
| } | |
| sub send_notification { | |
| my $title = shift; | |
| my $message = shift; | |
| my $pipe = IO::Pipe->new(); | |
| my $template = Irssi::settings_get_str("hilight_notify_template"); | |
| my @args = | |
| map { $_ =~ s/\$message/$message/; $_ } | |
| map { $_ =~ s/\$title/$title/; $_ } | |
| split / +/, $template; | |
| $pipe->reader(@args); | |
| my $result; | |
| while (<$pipe>) { | |
| $result = shift; | |
| } | |
| } | |
| sub _test_notify_me { | |
| send_notification("jwall", "If you see this it worked"); | |
| } | |
| Irssi::settings_add_str('hilight-notify', 'hilight_notify_template', | |
| 'growlatme.pl --app=irssi --title=$title --message=$message'); | |
| #Irssi::settings_add_str('hilight-notify', 'hilight_notify_template', | |
| # 'xmessage -timeout 20 <$title>: $message'); | |
| Irssi::command_bind test_hilight_notify => \&_test_notify_me; | |
| Irssi::signal_add('print text', 'sig_printtext'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment