Automatic coverart wallpaper with last.fm

The following post outlines how I managed to get a wallpaper compiled out of my top 50 artists at last.fm that changes automatically every hour. To achieve that I used the last.fm cover art website, Automator and the Unix utility cron.

  1. Open Automator and start a new workflow. First thing we have to make sure is that the old wallpaper gets deleted. You wouldn’t want your harddisk fill up with wallpapers. So drag the “Find Finder Items” action from the Finder Library to the workflow and set it up as showed in the picture. (Wallpaper is a folder in my Pictures folder that holds all of my background images.)
    Find Finder Items
  2. Choose the “Move to Trash” Action from the Finder Library and drag it under the previous Action.
  3. Next we have to get the desired wallpaper from the previously mentioned page. First go there and set up the wallpaper just as you like it. Make sure the “Randomise” checkbox is checked, otherwise it wouldn’t make much sense to reload the image every hour, would it? 😉
    When you’re done setting up your image click on “Image Me” and wait for the picture to appear, then copy the address from the address bar of your browser.
    Back in Automator choose the Safari Library and drag the “Get specified URLs” Action to the workflow. Paste the just copied address into the “Address” field in the Action. (Or if you did this with Safari and got the page still open, just click the “Current Safari Page” button)
    Get Specified URLs
  4. To save the image in the right folder we need the “Download URLs” Action from the Safari Library and specify the folder we chose previously in the delete step.
    Download URLS
  5. In the following two steps of the workflow the file is renamed with date and seconds till midnight, so it has a different filename each time it gets downloaded. Otherwise OS X wouldn’t change the wallpaper even if the image changed.
    Rename
  6. The last Action is Finder’s “Set the Desktop Picture” which you just have to drag into the workflow and you’re done.
  7. Save the workflow as Application into your Applocations folder and remember the name. (I named mine “last.fm – Azath0th – Wallpaper”). Now comes the scary part – the Terminal 😉
  8. We have to set up a cronjob. In order to do that type in crontab -e and paste the following in the crontab file.
    SHELL=/bin/bash
    0 * * * * /usr/bin/open "/Applications/last.fm - Azath0th - Wallpaper.app"

    Of course you have to substitute the name of the program with yours.
    This executes the Automator workflow every hour at 0 minutes on every possible day. (0 * * * *)

That’s it!
A few words of caution though:

Be sure that your desired download folder doesn’t contain any other files that contain “coverart” in their filename or Automator will delete those as well.

When the workflow runs it forces itself into the foreground which can be a bit annoying sometimes. I’m not sure what happens if you’re in the middle of a presentation and the workflow kicks in, it might be better to deactivate it during those occasions by putting a hash caracter (#) in front of the call in the crontab file.

Enjoy it and please tell me if you’ve got any ideas to improve the whole thing.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.