Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Change desktop picture without Finder restart Desktop
This is a revision of an 8 year old hint - listed here - on how to update the desktop picture from a downloaded image.

Things have moved on a bit from 2002, but since at least one person is still interested in this hint, here's a revised version for 10.5.x and 10.6.x.

There are three changes:
  • The wget command has been replaced with a curl command. wget in not installed by default on 10.6, if in fact it ever was, but curl is.
  • The entire script has been converted to applescript as a matter of convenience.
  • The Finder's desktop command has been deprecated, so System Events is used instead.
The Script (test image courtesy of XKCD Comics):
set pictureURL to "http://imgs.xkcd.com/comics/barrel_cropped_(1).jpg"
set localFile to POSIX path of (path to home folder from user domain) & "DTPic.jpg"
set cmd to "curl " & quoted form of pictureURL & " > " & quoted form of localFile
do shell script cmd

tell application "System Events"
  tell desktop 1
    set picture rotation to 1
    set picture rotation to "never"
    set picture to POSIX file localFile
  end tell
end tell
The image should be automatically scaled to fit. If the image is an odd size and suffers distortion, you can add in a call to Image Events (before the call to System Events) to size it correctly:
tell application "Image Events"
  set theImage to open localFile
  scale theImage to size 1200 -- adjusts the longest edge (assumedly the bottom edge) to a reasonable size
  pad theImage to dimensions {1440, 900} -- pads the image with black to the size of the screen to prevent distortion
  save theImage
end tell
Save this as a script and run it from the script menu, or from launchd using osascript if you want to change the image at scheduled times.

[crarko adds: I tested this, and it works as described.]
    •    
  • Currently 2.18 / 5
  You rated: 4 / 5 (28 votes cast)
 
[5,239 views]  

Change desktop picture without Finder restart | 10 comments | Create New Account
Click here to return to the 'Change desktop picture without Finder restart' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Change desktop picture without Finder restart
Authored by: chabig on Aug 19, '10 01:54:17PM

I think the title to this hint is misleading. It implies that the desktop picture cannot be changed without restarting the Finder. Yet changing the desktop via the normal way (System Preferences) has never required a Finder restart.



[ Reply to This | # ]
Seconded!
Authored by: cycomachead on Aug 19, '10 04:36:01PM

There's plenty of ways to change the desktop background, including right clicking an image in Safari which doesn't require a Finder restart.

As far as scripting goes, there's also an Automator action which doesn't require a restart.



[ Reply to This | # ]
Seconded!
Authored by: tedw on Aug 19, '10 11:43:56PM

Oh, I agree, I was just following up on the name of the original hint.

I will point out, though, that scripting it in applescript or automator is not quite as automatic as you might think. Once you've changed the image, you often have to kick-start it by changing the picture rotation, particularly if you previously had the system set to rotate the picture on a timed basis. If you don't, you'd probably need a logout or restart to see the new image.

This script is mostly useful in that peculiar case where you want to download a background picture automatically from the web (as from a webcam) in the background and without user intervention. While you can clearly use Safari to do it, Safari has to open and load the page, and scripting the image download is a bit trickier than you might imagine. Downloading it with curl and applescripting it is both easier and more stable, if automation is what you're after.

Edited on Aug 19, '10 11:45:33PM by tedw



[ Reply to This | # ]
Seconded!
Authored by: crarko on Aug 20, '10 07:07:00AM

I think it's fine that the title is the same as the older hint; so if searchers hit on the old one they should be able to find the updated one too.



[ Reply to This | # ]
Change desktop picture without Finder restart
Authored by: robertcoogan on Aug 20, '10 03:01:56AM

I honestly can't believe that this was posted here (and the title of the hint is misleading). I don't even think a dev would find this useful. Is changing the desktop picture via System Preferences truly THAT painful to the author???

For anyone who does find this useful, I have jars of air for sale.



[ Reply to This | # ]
Change desktop picture without Finder restart
Authored by: tedw on Aug 20, '10 11:14:17AM

I take it you've never been to an 'air bar'; they were all the rage in Southern California a few years back (which you would understand if you'd ever breathed Southern California air...) :-)



[ Reply to This | # ]
Change desktop picture without Finder restart
Authored by: excarnate on Aug 24, '10 12:36:51PM

Please, something not being useful to YOU doesn't mean it isn't useful to someone else. You are not the center of the universe and the hints don't revolve around you and your needs.

Here is an actual example: Setting the background image to be the current radar picture (the NWS has a simple radar that updates every 5 minutes).

I can think of several more, especially for someone not afraid to explore a man page or two.



[ Reply to This | # ]
Change desktop picture without Finder restart
Authored by: robertcoogan on Aug 25, '10 04:38:58PM

Not exactly what I was talking about...you're talking about something a bit beyond what is being discussed in the hint, something that is dynamically updated, whereas the hint is just referring to changing the desktop picture once.

Apples and oranges, really. The Automator hint below is good, though.



[ Reply to This | # ]
Change desktop picture without Finder restart
Authored by: OmniDragon on Aug 25, '10 09:11:03AM

I'm still in Leopard, so I just use the Automator way. Have it saved as an application and sitting in my Dock so I can just drag a photo from anywhere onto it to change the desktop picture.

By the way, I'm here and reading this hint, so I guess I'll take one of those jars of air to go, please. lol



[ Reply to This | # ]
There's an app for that! ; )
Authored by: tice on Aug 22, '10 10:20:44PM
Same routine with drag'n'drop: Desky
Edited on Aug 22, '10 10:21:50PM by tice


[ Reply to This | # ]