File: mprand

package info (click to toggle)
mpdtoys 0.8
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 80 kB
  • ctags: 6
  • sloc: perl: 495; sh: 58; makefile: 18
file content (38 lines) | stat: -rwxr-xr-x 681 bytes parent folder | download
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
#!/usr/bin/perl
use strict;
use warnings;
use Audio::MPD q{0.19.0};

=head1 NAME

mprand - play a random playlist

=head1 SYNOPSIS

mptoggle [host]

=head1 DESCRIPTION

B<mprand> picks a playlist at random and tells mpd to play it.

If the hostname is omitted, the MPD_HOST environment variable will be used.

=head1 AUTHOR

Copyright 2007 Joey Hess <joey@kitenet.net>

Licensed under the GNU GPL version 2 or higher.

http://kitenet.net/~joey/code/mpdtoys

=cut

if (@ARGV) {
	$ENV{MPD_HOST}=shift;
}
my $mpd=Audio::MPD->new(conntype => $REUSE);

$mpd->playlist->clear;
my @playlists=$mpd->collection->all_playlists;
$mpd->playlist->load($playlists[rand @playlists]);
$mpd->play;