-
Notifications
You must be signed in to change notification settings - Fork 213
/
desktop_notify
38 lines (29 loc) · 940 Bytes
/
desktop_notify
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name 'desktop_notify';
description 'Notify build results using the Desktop Notifications framework on the Linux desktop';
author 'Dagfinn Ilmari Mannsåker';
api_version 0.1;
my $notify;
hook init => sub {
my $args = shift;
$notify = eval { require Desktop::Notify; Desktop::Notify->new }
or $args->{app}->diag("! Couldn't find Desktop::Notify. desktop_notify plugin is disabled.\n");
};
hook install_success => sub {
my $args = shift;
notify($args, "Successfully installed %s");
};
hook build_failure => sub {
my $args = shift;
notify($args, "Building %s failed.");
};
sub notify {
my($args, $template, $is_sticky) = @_;
return unless $notify;
my $dist = "$args->{meta}->{name}-$args->{meta}->{version}";
$dist = $args->{module} if $dist eq '-';
my $msg = sprintf $template, $dist;
$notify->create(
timeout => -1,
summary => $msg,
)->show;
}