If you’ve been following along you know all of my music is ripped or downloaded as FLAC and is living on an Ubuntu server here on my network. I do a fair job of scanning in the album art (there are stacks yet to be scanned because it takes too much time, but that is neither here nor there). I thought I’d like to make use of all these scanned covers as rotating background art on my hi-fi machine.
Really there are three problems. First, get a complete list of the cover images. Second, mount that location and list in a useful manner. And third, rotate (randomly) through those images as backgrounds.
First I tackled the mounting part. I already was mounting the music share (referred to as MusicShare in the script) so I simply added an administrative folder (referred to as zetc) in that share which included a folder to house the images. I could then place a shortcut in my Pictures folder on the client machine and make a call to that folder with whatever I used to rotate the images.
Next I wrote the necessary script, but I want to save that for the end so let’s talk about the application for changing the wallpapers now. I selected Wallch and it seems to have all the options I need and seems to work well enough. (I have it running on two machines currently and I have not seen any issues worth reporting.)
Wallch is in the standard repositories so you can locate it in the Ubuntu Software Center or install it using the Terminal (with sudo apt-get install wallch). The only unusual thing I did was add a custom time interval in the Preferences dialog as I wanted a 15 second interval (the included intervals went from 10 seconds to thirty). Set it to randomly select images and called that good.
Let’s look at this script briefly as that’s really the meat of this matter. There are issues with using symbolic links in smb shares (if I serve symbolic links I lose the use of non-Windows standard characters) so I created a folder (as mentioned above) to house the hard links to the found image files.
I didn’t care to sort out proper names for them as I won’t likely ever look in the folder or care about what any particular file is called, so the image links are all named incrementally without regard for album, artist, or location.
Finally, I didn’t want to concern myself with what may or may not be located in my links folder when I run the script again (to create a more current set of links), so I remove all files located in the links folder before filling it up again with the new image links.
Here is my script. I hope this helps you with your music art needs.
## #!/bin/bash # by JamesIsIn from JamesIsIn.com # Do something nice today. directory="/media/MusicDrive/MusicShare/" zedfile="/media/MusicDrive/MusicShare/zetc/CoverSlideshow/ZedList" zedfolder="/media/MusicDrive/MusicShare/zetc/CoverSlideshow/SymLinks/" find "$directory" -type f -name [Cc]over.[Jj][Pp]*[Gg] -o -name [Cc]over.[Pp][Nn][Gg] -o -name [Cc]over.[Bb][Mm][Pp] -o -name [Cc]over.[Tt][Ii][Ff] > "$zedfile" declare -a zedfind let i=0 while read zedline; do zedfind[$i]="$zedline" ((i++)) done < "$zedfile" echo "I have found" ${#zedfind[@]} "cover images." echo read -p "Press <ENTER> to coninue. " echo echo rm "$zedfolder"/* for (( ii=0 ; ii < ${#zedfind[@]} ; ii++ )) ; do originalfile=$( basename "${zedfind[ii]}" ) echo "Creating link:" $ii-"$originalfile" ln "${zedfind[ii]}" "$zedfolder"$ii-"$originalfile" done unset exit ##