I created 288 different earth renders depending on sun position (one for every 5 earth minutes) based on this file from blendswap. It the image sequence starts at noon and ends at noon. I would like to set at each time of day the correct image as background image on OS X (eg at 12.00 it should be image No 1 at 18:00 it should be image No 72 ). How could I do that.

(The Original Idea was to use the "change background image every 5 minutes" setting in OS X background settings, but it only changes the picture if the computer is awake. Therefore the sequence would be out of sync every time I shut down the computer

btw I uploaded the Files


They are at full Retina resolution at 650MB. + blendfile + license.

  • Can you please revise your question to clearly state the problem you are trying to solve? As it's written now, it doesn't really make sense.
    – nohillside
    Commented Jul 23, 2012 at 8:01
  • yep you are right and there is even a error in my thought Commented Jul 23, 2012 at 8:42
  • You want a third party app suggestion which can do this or you want to write a script for this ?
    – iGameRam
    Commented Jul 23, 2012 at 9:58
  • I would rather write my on script, I found some third party apps myself already but I don't believe it would be to hard to do it myself. I already now how to change a background image with applescript (at least I believe) the interesting part is to execute it every 5 minutes according to system time Commented Jul 23, 2012 at 10:04
  • I think I am going to mix this together with the automator action of changing the background Commented Jul 23, 2012 at 10:15

3 Answers 3


Thank you for your input

So finally I managed to do it (at least I think so)

I embedded an Applescript to change the background in a shell script which I added it to launchd.

This is what it looks like:

Script "scriptly.sh"

osascript -e '
set myhour to get the (hours of (current date))
set myminutes to get the (minutes of (current date))
set mypicturenumber to (myhour - 12) * 12 + myminutes / 5 as integer
if mypicturenumber < 0 then
    set mypicturenumber to (288 + mypicturenumber)
end if
set picnumber to 0
if mypicturenumber > 99 then
    set picnumber to "0" & mypicturenumber
end if

if (99 ≥ mypicturenumber) = (9 < mypicturenumber) then
    set picnumber to "00" & mypicturenumber
end if
if 9 ≥ mypicturenumber then
    set picnumber to "000" & mypicturenumber
end if
tell application "Finder"
    set desktop picture to {"Macintosh HD:users:USERNAME:Individualfile:backgrounds:earth:earth24h" & picnumber & ".png"} as alias
end tell

launchd file "com.individual.Background.plist"

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

command to put it in action

launchctl load /Users/USERNAME/Individualfile/com.individual.Background.plist


The last command is there to load the script directly, however It will not be executed on startup. To do That you have to copy the file


to the ~/Libary/LaunchAgents/ folder.

  • The third condition in the script looks wrong. You could also run the AppleScript directly with something like <string>osascript</string><string>/Users/username/script.scpt</string>. The UserName key is not needed in per-user services saved to ~/Library/LaunchAgents/.
    – Lri
    Commented Jul 25, 2012 at 0:38
  • Thanks for that, it told me in the console, that it the private key was not necessary and would be ignored, so I didn't change it. And the I wasn't sure if I could launch it directly with osascript, because osascript was throwing errors because of some permission to change user things when I ran it from the commandline Commented Jul 25, 2012 at 8:01

This might be an unfortunate answer, but i'd suggest making a Quartz composition for this, turn it into a screen saver, and use one of many available tricks for running screen savers as a wall paper.

  • Good idea in general,I would need to look how I can make a time dependent screensaver. Commented Jul 24, 2012 at 9:07
  • Quartz Compositor probably has goodies in the library for tracking time (can't confirm right now)
    – Alexander
    Commented Jul 24, 2012 at 12:48
  • Just finished the Applescript. I am going to add a launchd job to run the script every 5 minutes Commented Jul 24, 2012 at 13:34

Here's a shorter version of the script:


n=$(((($(date +%H)-12)*12)+$(date +%M)/5))
[[ $n -lt 0 ]] && n=$((n+288))
n=$(printf %04d $n)

osascript -e "tell app \"Finder\" to set desktop picture to POSIX file \"/Users/username/Desktop/background/earth24h$n.png\""

You could run the script every five minutes by editing the crontab with EDITOR=nano crontab -e and adding a line like */5 * * * * ~/script.sh. Unlike the LaunchAgent, it wouldn't be run after waking up from sleep though.

  • nice shell coding. I don't have that kind of skill level. Commented Jul 25, 2012 at 8:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .