| 1 |
#!/usr/bin/perl |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use Audio::MPD q{0.19.0}; |
| 5 |
|
| 6 |
=head1 NAME |
| 7 |
|
| 8 |
mprand - play a random playlist |
| 9 |
|
| 10 |
=head1 SYNOPSIS |
| 11 |
|
| 12 |
mprand[host] |
| 13 |
|
| 14 |
=head1 DESCRIPTION |
| 15 |
|
| 16 |
B<mprand> picks a playlist at random and tells mpd to play it. |
| 17 |
|
| 18 |
If the hostname is omitted, the MPD_HOST environment variable will be used. |
| 19 |
|
| 20 |
=head1 AUTHOR |
| 21 |
|
| 22 |
Copyright 2007 Joey Hess <[email protected]> |
| 23 |
|
| 24 |
Licensed under the GNU GPL version 2 or higher. |
| 25 |
|
| 26 |
http://kitenet.net/~joey/code/mpdtoys |
| 27 |
|
| 28 |
=cut |
| 29 |
|
| 30 |
if (@ARGV) { |
| 31 |
$ENV{MPD_HOST}=shift; |
| 32 |
} |
| 33 |
my $mpd=Audio::MPD->new(conntype => "reuse"); |
| 34 |
|
| 35 |
$mpd->playlist->clear; |
| 36 |
my @playlists=$mpd->collection->all_playlists; |
| 37 |
$mpd->playlist->load($playlists[rand @playlists]); |
| 38 |
$mpd->play; |