#!/usr/bin/perl #H# This launches xv with all graphics files in the directory of the currently playing #H# mp3 file. #H# #H# I used to just do a simple 'xv *.jpg *.png *.gif' but this is better because it #H# always puts the album cover image first instead of just using the alpha sort #H# provided by the shell globbing. # print out help info if requested if ($ARGV[0] ne "") { open (SELF, $0); while () { if ($_ =~ /^#H# /) { $_ =~ s/^#H# //; print $_; } } exit; } @Files=(); # Figure out what is currently playing and what directory it is in. #$FileName=`xmmsctrl print %F`; $FileName=`audtool current-song-filename | sed -e 's/^file...//' -e 's/%20/ /g'`; chomp $FileName; $FQFN=`realpath "$FileName"`; chomp $FQFN; $Dir=`dirname "$FQFN"`; chomp $Dir; # Find all pic files in the directory of the currently playing song. open (FileList, qq[cd "$Dir" ; /bin/ls *.jpg *.png *.gif |]); while () { $FileName=$_; chomp $FileName; # If I find a cover picture put it first so that it is what xv will pop up. if ($FileName =~ /Cover\./) { @Files=(qq["$Dir/$FileName"],@Files); } else { @Files=(@Files,qq["$Dir/$FileName"]); } } close (FileList); # Actually display the pics (only if there are any). if (@Files >= 1) { exec ("xv @Files"); }