Sorry I have never touched applescript before
in this case you might want to learn a little apple script if you'll be using a script like that. There are probably several ways to do what you want but the following should work.
paste the following into Script Editor (it's in /Applications/Utilities).
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 335px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
property ip_address : ""
set cur_ip to do shell script "ifconfig |grep inet |tail -1 | awk '{print $2}'"
if cur_ip is not equal to ip_address then -- check to see if the ip address has changed since last check. if it didn't - do nothing.
set ip_address to cur_ip
if ip_address = "home.ip.address" then
tell application "System Events"
-- RANDOM ROTATION OF A FOLDER OF IMAGES
tell current desktop
set picture rotation to 1 -- (0=off, 1=interval, 2=login, 3=sleep)
set random order to true
set pictures folder to file "path:to:home:images:"
set change interval to 3600.0 -- seconds
end tell
end tell
else if ip_address = "work.ip.address" then
tell application "System Events"
-- RANDOM ROTATION OF A FOLDER OF IMAGES
tell current desktop
set picture rotation to 1 -- (0=off, 1=interval, 2=login, 3=sleep)
set random order to true
set pictures folder to file "path:to:work:images:"
set change interval to 3600.0 -- seconds
end tell
end tell
end if
end if
</pre>
put the ip addresses of at home and at work in the above, as well as the corect paths to different folders with images. then save the script in your Documents folder. Call it, say, backgrounchanger. Then download [lingon|http://www.tuppis.com/lingon> and use it to make a launch daemon. make it run, say, every minute and execute the following command (enter it on line 2)
osascript /users/username/documents/backgroundchanger.scpt
Put your short user name instead of username in the above.
save the daemon and log out/in to activate it.