|
Revision 986
(checked in by miyagawa, 4 years ago)
|
new plugin Notify::Beep
|
| Line | |
|---|
| 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__ |
|---|
| 36 |
|
|---|
| 37 |
=head1 NAME |
|---|
| 38 |
|
|---|
| 39 |
Plagger::Plugin::Notify::Beep - Beep your computer when feed arrives |
|---|
| 40 |
|
|---|
| 41 |
=head1 SYNOPSIS |
|---|
| 42 |
|
|---|
| 43 |
- module: Notify::Beep |
|---|
| 44 |
config: |
|---|
| 45 |
music: "g' f bes' c8 f d4 c8 f d4 bes c g f2" |
|---|
| 46 |
|
|---|
| 47 |
=head1 DESCRIPTION |
|---|
| 48 |
|
|---|
| 49 |
Beep your computer when feed arrives. |
|---|
| 50 |
|
|---|
| 51 |
=head1 CONFIG |
|---|
| 52 |
|
|---|
| 53 |
=over 4 |
|---|
| 54 |
|
|---|
| 55 |
=item music |
|---|
| 56 |
|
|---|
| 57 |
When it is set, beep tries to play a melody specified as Lilypond |
|---|
| 58 |
notation. Defaults to nothing and in that case, it just beeps. |
|---|
| 59 |
|
|---|
| 60 |
=back |
|---|
| 61 |
|
|---|
| 62 |
=head1 AUTHOR |
|---|
| 63 |
|
|---|
| 64 |
Tatsuhiko Miyagawa |
|---|
| 65 |
|
|---|
| 66 |
=head1 SEE ALSO |
|---|
| 67 |
|
|---|
| 68 |
L<Plagger>, L<Audio::Beep> |
|---|
| 69 |
|
|---|
| 70 |
=cut |
|---|