Live Desktop Wallpaper

A cool hack for Mac OS X users


Motivation

How cool would be if you could organize your favorite photographs, back them up in the cloud and do not use any of your Dropbox space?

Also, from time to time, you would like to fetch photographs from this source and use them as wallpaper. The less effort that you spend on this task and the cooler it gets, the better.

Motivated by this post I wrote a Python script using the FlickrAPI that randomly downloads a certain number of images from your own Flickr account, and save them on a local folder. After that, there is a simple Mac OS X trick to use your screensaver as desktop wallpaper, providing a dynamic desktop background.

Awesome wallpaper being randomly generated

The Hack

The script is pretty straight forward. You will need an Flickr app key, your account user id, and a Mac. That's it!

Setting up

The code is on my GitHub repository.

Fork and clone it to your computer. First of all, go to the folder rename the example-config.json to config.json.

Open config.json file and replace the variables with your own values. Make sure to create a brand new folder and put it on the app_folder variable. All images downloaded from a previous execution are deleted before the next execution, so do not chose a folder with personal files.

Executing

To run the script, using the Terminal, use the command:

python app.py

Python is already installed in all MacOS, don't worry about that.

The first execution takes longer because a local file with all your images url is created. Subsequent executions use this local file as reference and the speed is drastically improved.

The number_of_photos variable, specifies how many images you want to download to your app_folder. All this images are downloaded in parallel, so it's blazing fast (depending on your internet connection…).

While the first execution occurs, use the time to configure your screensaver. Open System Preferences > Desktop & Screen Saver. On the "Screen Saver" tab, choose you favorite effect. I personally like "Photo Wall". You also need to specify the source folder for this screensaver. Choose the same folder you created and set the app_folder variable in the configuration file.

After the execution of app.py finishes, execute this command:

/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background

This simply runs the "Screensaver app" and sets it to be the desktop background. If you want to return to your regular desktop wallpaper, just press CTRL + C.


There is room for improvements here, so feel free to fork it and modify it anyway you want. Be social! A few ideas:

  • Download the images only from an specified set in the config file.
  • Detect when new images are uploaded and recreated the local file with the new urls.
  • Parallel execution on flickr_obj.walk_set method to speed the first execution.

If you run into trouble, I'm on twitter :-)