Created
July 31, 2016 03:37
-
-
Save yuuan/e87bd224ced9c767e8724ca2675fd9e8 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
#!/usr/bin/perl | |
use common::sense; | |
use IPC::System::Simple qw(systemx); | |
my @arguments = @ARGV; | |
my @ignores = qw/ | |
-u --urgency | |
-t --expire-time | |
-a --app-name | |
-i --icon | |
-c --category | |
-h --hint | |
/; | |
my @messages; | |
for my $v (@ARGV) { | |
push @messages, $v if ($v !~ /^-/); | |
shift @ARGV if (scalar grep { $v eq $_ } @ignores); | |
} | |
systemx('/usr/bin/notify-send', @arguments); | |
my $slackboard = 'slackboard-cli -s localhost:29800 -c #scripts -u fedora -i :fedora:'; | |
if (scalar grep { $_ =~ /fail/i } @arguments) { | |
$slackboard .= ' -l crit'; | |
} | |
else { | |
$slackboard .= ' -C #6EB7DB'; | |
} | |
if (open my $FH, "| ${slackboard}") { | |
print $FH join("\n", @messages); | |
close $F; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment