| 1 | package Plagger::Plugin::Notify::Beep; | ||
| 2 | use strict; | ||
| 3 | use base qw( Plagger::Plugin ); | ||
| 4 | |||
| 5 | use Audio::Beep; | ||
| 6 | |||
| 7 | sub register { | ||
| 8 | my($self, $context) = @_; | ||
| 9 | $context->register_hook( | ||
| 10 | $self, | ||
| 11 | 'publish.feed' => \&update, | ||
| 12 | 'publish.finalize' => \&finalize, | ||
| 13 | ); | ||
| 14 | $self->{count} = 0; | ||
| 15 | } | ||
| 16 | |||
| 17 | sub update { | ||
| 18 | my($self, $context, $args) = @_; | ||
| 19 | $self->{count}++ if $args->{feed}->count; | ||
| 20 | } | ||
| 21 | |||
| 22 | sub finalize { | ||
| 23 | my($self, $context, $args) = @_; | ||
| 24 | if ($self->{count}) { | ||
| 25 | if ($self->conf->{music}) { | ||
| 26 | Audio::Beep->new->play($self->conf->{music}); | ||
| 27 | } else { | ||
| 28 | Audio::Beep::beep; | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | 1; | ||
| 34 | |||
| 35 | __END__ |