Created
July 15, 2011 09:59
-
-
Save iizukanao/1084413 to your computer and use it in GitHub Desktop.
growlnotify over UDP
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Net::GrowlClient; | |
use Getopt::Long::Descriptive; | |
my ($opt, $usage) = describe_options( | |
`basename $0`." %o", | |
[ "name|n:s", "Set the name of the application that sends the notification", {default => "growlnotify"} ], | |
[ "priority|p:i", "Specify an int or named key", {default => 0}, ], | |
[ "title|t:s", "ignored", {default => ""} ], | |
[ "message|m=s", "Sets the message to be used instead of using stdin" ], | |
[ "help", "Display this help" ], | |
); | |
print($usage->text), exit if $opt->help || !$opt->message; | |
my $growl = Net::GrowlClient->init( | |
CLIENT_TYPE_REGISTRATION => 0, | |
CLIENT_TYPE_NOTIFICATION => 1, | |
CLIENT_CRYPT => 0, | |
CLIENT_PASSWORD => 'YOUR_PASSWORD', | |
CLIENT_PEER_HOST => 'YOUR_IP', | |
CLIENT_PEER_PORT => 9887, | |
CLIENT_APPLICATION_NAME => 'vagrant', | |
CLIENT_NOTIFICATION_LIST => [$opt->name], | |
) or die $!; | |
$growl->notify( | |
title => $opt->title, | |
message => $opt->message, | |
notification => $opt->name, | |
priority => $opt->priority, | |
sticky => 0, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment