Created
February 8, 2010 20:59
-
-
Save xantus/298578 to your computer and use it in GitHub Desktop.
A simple wrapper for libnotify that takes growlnotify params
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/env perl | |
use strict; | |
use warnings; | |
# TBD: locate these using env? | |
# mac | |
my $growl = '/usr/bin/growlnotify'; | |
# ubuntu: apt-get install libnotify-bin | |
my $libnotify = '/usr/bin/notify-send'; | |
# passthrough | |
exec( $growl, @ARGV ) if ( -e $growl ); | |
if ( -e $libnotify ) { | |
require Getopt::Long; | |
import Getopt::Long; | |
my ( $iconpath, $image, $appIcon, $icon, $sticky, $name, $msg ); | |
# options compatible with libnotify | |
GetOptions( | |
"iconpath=s" => \$iconpath, | |
"image=s" => \$image, | |
"appIcon=s" => \$appIcon, | |
"icon=s" => \$icon, | |
"sticky" => \$sticky, # bool | |
"name=s" => \$name, | |
"m=s" => \$msg, | |
); | |
# last option | |
my $title = shift @ARGV; | |
$msg = join( ' ', @ARGV ) unless defined $msg; | |
my @icon; | |
if ( $icon || $iconpath || $image || $appIcon ) { | |
@icon = ( '-i' ); | |
if ( $iconpath && $icon ) { | |
$iconpath .= '/' unless ( $iconpath =~ m!\$/! ); | |
push( @icon, $iconpath.$icon ); | |
} elsif ( $image ) { | |
push( @icon, $image ); | |
} elsif ( $appIcon ) { | |
push( @icon, $appIcon ); | |
} | |
} | |
my @time = $sticky ? qw( -t 60000 ) : qw( -t 2000 ); # ms | |
exec( '/usr/bin/notify-send', qw( -u normal ), @time, @icon, ( $title || $name || () ), $msg ); | |
} | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment