Skip to content

Instantly share code, notes, and snippets.

@yuuan
Created July 31, 2016 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuuan/e87bd224ced9c767e8724ca2675fd9e8 to your computer and use it in GitHub Desktop.
Save yuuan/e87bd224ced9c767e8724ca2675fd9e8 to your computer and use it in GitHub Desktop.
#!/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