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

10.4: Set desktop picture via Automator Desktop
I was stumped by how to quickly establish a picture as a Desktop background image. After some thought, I have created an interesting solution. First, launch Automator, in your Applications folder. Once it's running, choose File -> New (if necessary) to give yourself a blank working slate.

Then follow these steps to create your new Desktop picture changing application:
  1. Choose File -> New
  2. In the Library column, choose Applications -> Finder.
  3. In the Action column, double-click on the Get Specified Finder Items entry.
  4. In the same Action column, double-click on the Set the Desktop Picture item.
  5. Now choose File -> Save As. Here we type the name, for example Picture to Desktop, and below in the File Format drop-down list, change Workflow to Application.
  6. Specify any place to save file. For example, your Home directory.
  7. Open your Home directory. It is possible (with the Get Info window for the new file) to paste a new icon onto the application, in case you don't want the default Automator icon.
  8. Don't close your Home directory, and then drag your new application to the Dock.
There you go! Now the Desktop wallpaper is established by simply dragging an image onto the Dock icon for your new application.

The program reacts to files which are not the images as follows: it deletes existing wallpapers, and does not put anything in exchange -- simply a screen of continuous color. It is possibly to get rid of this issue, if between Get Specified Finder Items and Set the Desktop Picture you insert the Filter Finder Items Action, and list the corresponding filters for image files.

[robg adds: In my testing, the results were somewhat inconsistent -- sometimes this script worked, sometimes it didn't. I tried using various methods of getting the Finder selection, but everything I tried had the same issue. I'm not sure if it's something particular to my setup, or just a not-quite-there implementation of setting the desktop picture via Automator.]
    •    
  • Currently 3.50 / 5
  You rated: 5 / 5 (6 votes cast)
 
[26,673 views]  

10.4: Set desktop picture via Automator | 12 comments | Create New Account
Click here to return to the '10.4: Set desktop picture via Automator' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Set desktop picture via Automator
Authored by: bradleyd1971 on Jul 25, '06 09:36:17AM

I did something fairly similar except I made mine a finder plug-in, so all I have to do is cmd-click on the image file (or right click when using a two-button mouse), and choose my plug-in from the listed Automator actions.



[ Reply to This | # ]
10.4: Set desktop picture via Automator
Authored by: Zoltak on Jul 25, '06 10:31:32AM

I did the same thing, works pretty good from the use I have done with it.

I also had the widget mentioned further down and found it was really slow and stopped using it.



[ Reply to This | # ]
10.4: Set desktop picture via Automator
Authored by: RussellK on Jul 25, '06 09:37:58AM
There is a Dashboard widget for this:

http://www.apple.com/downloads/dashboard/status/setwallpaperwidget.html

I haven't tried it, but recalled reading about it when I saw this hint. Maybe it's an easier and more reliable solution?

[ Reply to This | # ]
10.4: Set desktop picture via Automator
Authored by: rexroof on Jul 25, '06 12:26:53PM
I looked a long time for an automated way to set my desktop image. being a unix geek but not knowing a lot about applescript, and having never used automator, it took a while. here's the shell script I finally came up with.

#!/bin/sh
FILE=$1

/usr/bin/osascript <<END
tell application "Finder"
  set myFile to POSIX file "$FILE" as string
  set desktop picture to file myFile
end tell
END


[ Reply to This | # ]
10.4: Set desktop picture via Automator
Authored by: thebug on Jul 25, '06 08:57:28PM
I like this script! Easy to work into any unix script workflow. It'd be easy to make it a Contextual Menu with On My Command.

When I tried it, it seemed to need a full path to the image. I updated it to test to see if it's a full path or not, and if it's not, assume that it's in the current directory, and use that to create a full path. I don't do that much shell scripting, so hopefully this isn't too bad.

If you don't like the "solid color" effect of a bad image, you could easily add in a few lines to test if the file name at least ends with something like ".jpg" (or another image type), or test it with the unix file command. You could also do that in the AppleScript section as well, whichever is easier.


#!/bin/sh

PWD=`pwd`
FILE=$1
PATH="$PWD/$FILE"

cd /  # need full path, so go to root of drive, and see if I have a full path.

if [ -f $FILE ]
then
    PATH=$FILE
fi

#PATH should now be the full path to the image.
# check to see if it exists, if not quit
if [ ! -f $PATH ]
then
	echo "$PATH does not exist. Exiting."
	exit
fi

/usr/bin/osascript <<END
tell application "Finder"
  set myFile to POSIX file "$PATH" as string
  set desktop picture to file myFile
end tell
END

---
Outside of a dog, a book is man's best friend. Inside of a dog, it's too dark to read.

[ Reply to This | # ]

Set picture from current album?
Authored by: gidds on Jul 25, '06 03:16:59PM

Interesting hint. But I have another challenge! I tend to let OS X pick randomly through my huge wallpaper folder, but it'd be really handy if that could get replaced or overlaid by iTunes artwork whenever I'm playing music. Anyone know if that's possible without paid-for software or extracting out all the artwork stored in all my MP3 and AAC files?

---
Andy/



[ Reply to This | # ]
Set picture from current album?
Authored by: thebug on Jul 25, '06 09:22:38PM
I googled a bit and came up with this script to save artwork to a folder. It does the heavy lifting of getting the image of the current song.

http://www.dougscripts.com/itunes/scripts/scripts13.php?page=1#saveartworktofolder

This doesn't do everything you want, but you could combine this to easily set your desktop picture to the current album. Just save out the current song art, then execute any of these "set desktop" scripts.

Now if you want to overlay this on the current desktop image, that's more work. You'd need to find some scriptable solution to combine the files (there are many, Image Magik comes to mind). I think I've seen a few hints about doing something like that. Or you could use GeekTool (it has a setting for picture).

Of course you'd have to get something to be notifed when iTunes switched songs. Or you can just poll every so many seconds.


---
Outside of a dog, a book is man's best friend. Inside of a dog, it's too dark to read.

[ Reply to This | # ]

10.4: Set desktop picture via Automator
Authored by: Unsoluble on Jul 26, '06 02:33:09AM

Anyone got an easy solution for setting a new desktop picture from an Aperture library? I've loved everything about my move from iPhoto to Aperture, except that I just noticed there's no way to either access the library from the Desktop prefpane or set a desktop image from within the app -- I have to export a jpg into a folder and then keep it there (ugh).



[ Reply to This | # ]
10.4: Set desktop picture via Automator
Authored by: dev_sleidy on Jul 26, '06 03:10:57AM

Or ...

Click on 'Automator' (under 'Library'), double click 'Run AppleScript' (under 'Action'), enter the following code ...

on run {input, parameters}
tell application "Finder" to if ((selection as string) is not "") then set desktop picture to file (selection as string)
return input
end run

... and save as 'Make Desktop Picture.workflow' in the '~/Library/Workflows/Applications/Finder/' folder. Create any needed folder(s).

Select a single graphic file, and via a right button click contextual menu - select the 'Automator, Make Desktop Picture' sub-menu item.

------

And / or, save ...

tell application "Finder" to if ((selection as string) is not "") then set desktop picture to file (selection as string)

... as 'Make Desktop Picture.scpt' and place into '~/Library/Scripts/' or '/Library/Scripts'.

Select a graphic file (in 'Finder') and via the 'Script Menu' or 'FastScripts' (or 'FastScripts Lite') select 'Make Desktop Picture'.

-----

And / or, save ...

on open tSelection
my handle_Selection((item 1 of tSelection))
end open

on run {}
tell application "Finder" to set tSelection to (choose file) as string
my handle_Selection(tSelection)
end run

on handle_Selection(local_Selection)
tell application "Finder" to if (((local_Selection) as string) is not "") then set desktop picture to file ((local_Selection) as string)
end handle_Selection

... as 'Make Desktop Picture.app' - an applet (save as an application).

Either drag a graphic file onto the applet (whether the applet is 'Finder' or 'Dock' based), or double click on the applet (if 'Finder' based) or once (if 'Dock' based) - and navigate to and select a graphic file.

-----

The codes listed above provide no error checking, etc; with room for improvement.



[ Reply to This | # ]
10.4: Set desktop picture via Automator
Authored by: DougAdams on Jul 26, '06 09:03:57AM
I wrote Art to Desktop this morning. It uses routines from other similar scripts to set your desktop picture to the artwork of the currently playing iTunes track.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/

[ Reply to This | # ]

10.4: Set desktop picture via Automator
Authored by: rspress on Jul 26, '06 10:16:33AM

I set up Automator to do just this a long time ago. You can leave off the save as command if you wish to leave the picture file where it is at or you can have it save the file in the desktop pictures folder all the time be modifying the save as command.

I created a finder plug-in to do this with a click on the second button on my mouse or my trackball. The only problem with automator is that it may tile the file if it is much smaller than the screen.

You could also add a save as JPG command to save any quicktime supported format file so that desktop pictures can understand it.



[ Reply to This | # ]
10.4: Set desktop picture via Automator
Authored by: mpanighetti on Jul 28, '06 02:47:38PM

I use this handy Automator action to cycle out pictures from my iPhoto library as desktop images. Just use the "Find Photos in iPhoto" action, select an album of your choice (I use a Smart Album of recent photos, combining the last four rolls with the last month's worth of pictures), then the "Set The Desktop Picture" action. It will select the first picture in the list, so I organize it by Rating in Descending order. For the final touch, I made a weekly iCal entry that runs the program, so every Saturday my desktop image is rotated (assuming I took any pictures in the last week).



[ Reply to This | # ]