projects
/
app-xmms2-notifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bump version and update Changes
[app-xmms2-notifier.git]
/
lib
/
App
/
XMMS2
/
Notifier.pm
diff --git
a/lib/App/XMMS2/Notifier.pm
b/lib/App/XMMS2/Notifier.pm
index 3e3183d933c74a74563a8133ee271241d730e27f..e68566ee205c522f13430ad0e1ec0c3e04e42e1c 100644
(file)
--- a/
lib/App/XMMS2/Notifier.pm
+++ b/
lib/App/XMMS2/Notifier.pm
@@
-1,28
+1,17
@@
package App::XMMS2::Notifier;
package App::XMMS2::Notifier;
-use
v5.14
;
+use
5.014000
;
use strict;
use warnings;
use strict;
use warnings;
-our $VERSION = 0.00100
1
;
+our $VERSION = 0.00100
2
;
use Audio::XMMSClient 0.03;
use Gtk2::Notify 0.05 -init,'xmms2-notifyd';
use Audio::XMMSClient 0.03;
use Gtk2::Notify 0.05 -init,'xmms2-notifyd';
-use Getopt::Long;
-
use constant CONVERSION_SPECIFIERS => qw/bitrate date sample_format url id channels samplerate tracknr genre artist album title/;
##################################################
use constant CONVERSION_SPECIFIERS => qw/bitrate date sample_format url id channels samplerate tracknr genre artist album title/;
##################################################
-my $use_libnotify = 1;
-my $use_libpurple;
-my $format = '$artist - $title';
-
-GetOptions (
- "libnotify!" => \$use_libnotify,
- "libpurple!" => \$use_libpurple,
- "format=s" => \$format,
-);
-
+my $format;
my $xmms = Audio::XMMSClient->new('xmms2-notifyd');
my $notify = Gtk2::Notify->new('');
my $xmms = Audio::XMMSClient->new('xmms2-notifyd');
my $notify = Gtk2::Notify->new('');
@@
-31,45
+20,47
@@
$notify->set_timeout(3000);
##################################################
sub notify_libnotify{
##################################################
sub notify_libnotify{
- $notify->update($_[0]);
- $notify->show;
+
$notify->update($_[0]);
+
$notify->show;
}
sub notify{
}
sub notify{
- my $id=$xmms->playback_current_id->wait->value or return;
- my $minfo=$xmms->medialib_get_info($id)->wait->value;
+ my ($id, $minfo);
+ eval {
+ $id=$xmms->playback_current_id->wait->value or return;
+ $minfo=$xmms->medialib_get_info($id)->wait->value;
+ } or return;
-
my %metadata = map { $_ => exists $minfo->{$_} ? (values $minfo->{$_
})[0] : undef } CONVERSION_SPECIFIERS;
- my $str=$format;
-
$str =~ s/\$$_/$metadata{$_}/g
for keys %metadata;
+
my %metadata = map { $_ => exists $minfo->{$_} ? (values %{$minfo->{$_}
})[0] : undef } CONVERSION_SPECIFIERS;
+
my $str=$format;
+
$str =~ s/\$$_/$metadata{$_}/gs
for keys %metadata;
- notify_libnotify $str if $use_libnotify;
-# notify_libpurple $str if $use_libpurple;
+ notify_libnotify $str
}
sub on_playback_current_id {
}
sub on_playback_current_id {
- notify;
- $xmms->broadcast_playback_current_id->notifier_set(\&on_playback_current_id);
+
notify;
+
$xmms->broadcast_playback_current_id->notifier_set(\&on_playback_current_id);
}
sub on_playback_status {
}
sub on_playback_status {
- notify if $xmms->playback_status->wait->value == 1; # 1 means playing, 2 means paused
- $xmms->broadcast_playback_status->notifier_set(\&on_playback_status);
+
notify if $xmms->playback_status->wait->value == 1; # 1 means playing, 2 means paused
+
$xmms->broadcast_playback_status->notifier_set(\&on_playback_status);
}
sub run {
}
sub run {
- while(1){
- last if ($xmms->connect);
- sleep 1
- }
-
- $xmms->broadcast_playback_current_id->notifier_set(\&on_playback_current_id);
- $xmms->broadcast_playback_status->notifier_set(\&on_playback_status);
- $xmms->loop
+ $format = $_[0];
+ while (1) {
+ last if ($xmms->connect);
+ sleep 1
+ }
+
+ $xmms->broadcast_playback_current_id->notifier_set(\&on_playback_current_id);
+ $xmms->broadcast_playback_status->notifier_set(\&on_playback_status);
+ $xmms->loop
}
}
-1
-
+1;
__END__
=head1 NAME
__END__
=head1 NAME
@@
-154,7
+145,7
@@
Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
=head1 COPYRIGHT AND LICENSE
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2013 by Marius Gavrilescu
+Copyright (C) 2013
-2016
by Marius Gavrilescu
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.14.2 or,
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.14.2 or,
This page took
0.011024 seconds
and
4
git commands to generate.