Forked from blackknight36/audacious-random-album.pl
Last active
September 11, 2016 09:03
-
-
Save Nemoder/2191ee5931d4adcd6d8aa568e20bc832 to your computer and use it in GitHub Desktop.
random folders instead of tracks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use List::Util qw(shuffle); | |
| my ($dir, $num)=@ARGV; | |
| if (not defined $dir){ | |
| $dir=`pwd`; | |
| chomp($dir); | |
| } | |
| my $cmd = "find \"$dir\" -type d"; | |
| my @folders = `$cmd`; | |
| my @rfolders = shuffle @folders; | |
| open(LIST, ">", "/tmp/rand_playlist.m3u"); | |
| my $count=0; | |
| foreach my $folder (@rfolders) { | |
| chomp $folder; | |
| my $cmd = "find \"$folder\" -maxdepth 1 -type f"; | |
| my @songs = `$cmd`; | |
| foreach my $song (@songs){ | |
| next unless ($song =~ m/\.mp3$/) or ($song =~ m/\.ogg$/) or ($song =~ m/\.flac$/); | |
| print LIST $song; | |
| $count++; | |
| } | |
| } | |
| close(LIST); | |
| if($count >0){ | |
| system("audacious /tmp/rand_playlist.m3u &"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment