diff options
Diffstat (limited to 'mprand')
-rwxr-xr-x | mprand | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -0,0 +1,38 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Audio::MPD q{0.19.0}; + +=head1 NAME + +mprand - play a random playlist + +=head1 SYNOPSIS + +mprand[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; |