OSX Leopard: How to show the current wallpaper in finder?
April 22, 2008 3:35 PM   Subscribe

How can I get my iMac running Leopard to show the current wallpaper in Finder? I'm using Leopard's built-in wallpaper-switching function to randomly display a wallpaper from my collection of over 1,000, but when I get one I don't like, it gives me no way to easily find the file and delete it.

For those of you looking to shuffle wallpapers in Windows, I recommend John's Background Switcher.
posted by XSteveMurphy to Computers & Internet (14 answers total) 1 user marked this as a favorite
 
Try this bit of AppleScript

on run

tell application "Finder"
select window of desktop
set curDesktop to (get desktop picture as text)
display dialog "The Current Desktop Image is " & curDesktop
end tell

end run

posted by jedicus at 4:11 PM on April 22, 2008


You could modify the script to select another image in the folder and delete the old one.
posted by jedicus at 4:12 PM on April 22, 2008


Or you could modify jedicus's script to show the wallpaper in Finder exactly as you ask:
on run
	tell application "Finder"
		select window of desktop
		set curDesktop to (get desktop picture as text)
		reveal curDesktop
	end tell
end run

posted by nowonmai at 6:47 PM on April 22, 2008


The on run / end run lines aren't necessary in this context. Simply copy and paste the rest of nowonmai's script into the Script Editor (/Applications/AppleScript/Script Editor) and save it as an Application. Then you can just double-click it when you want to reveal the current desktop image.
posted by pmbuko at 6:56 AM on April 23, 2008


Just noticed that you're running Leopard, which gives Applescript better access to this stuff. Here's what you want:
tell application "System Events"
    tell current desktop to set currentDesktop to (get picture)
end tell
tell application "Finder"
    reveal currentDesktop
    activate
end tell
After some testing, I noticed that this method (and those listed above) only seems to return the correct picture the first time it is run. I'll try to figure out the problem.
posted by pmbuko at 8:09 AM on April 23, 2008


Ha, yes, these scripts only work once. That's pretty weird.

I think the problem is that the Finder no longer manages the desktop picture in OS X. In Leopard, the System Preferences application is much more scriptable than in 10.4. See http://www.apple.com/applescript/features/system-prefs.html

I can't test it because I don't have Leopard, but the examples on that page imply that a working script should be easy.
posted by nowonmai at 3:54 PM on April 23, 2008


Okay, in that case, give this a whirl.


tell application "System Events"
   tell current desktop
      set currentDesktop to (get picture as text)
      tell application "Finder"
          reveal currentDesktop
      end tell
   end tell
end tell


Unfortunately, I don't have a Mac handy to test this one on, but I think that should work (and work repeatedly).
posted by jedicus at 7:32 AM on April 24, 2008


Response by poster: First of all, thank you all for getting so into this, I would never have gotten this far on my own.

That said... even that last script only worked once. No matter what wallpaper is being displayed... the same file comes up in finder every time.

Any other ideas?

Thanks again!
posted by XSteveMurphy at 1:58 PM on April 25, 2008


Response by poster: Ok... that wasn't quite accurate. It did not, in fact, work the first time either, it was close but as it turns out that was a coincidence. Here's the story:

I tried all scripts but the first, and they all behave the same strange way. Here is what I found: Leopard must maintain a memory of the last manually-selected wallpaper, and then elsewhere must maintain a record of the currently displayed image. I think your scripts are calling for the last manually-selected one, and not the currently-displayed one.

I did a bunch of testing, and I've written and rewritten this description, but that's what I found.

Here's a step-by-step.

I have an iPhoto event called "Wallpapers" that is the list I actually want it to randomly choose from. I have another iPhoto event with pics of my dog. I opened the pets event in the Desktop Preferences window and clicked one, and my dog was displayed as my wallpaper and also as the preview image in the top left corner. I then clicked back to the "Wallpapers" event within the Desktop Preferences, but did NOT click any single photo. The "preview" image in the top left corner was still the pic of my dog. I clicked "Change Picture Every 5 Minutes," and the wallpaper jumped to a wallpaper from the currently selected event, "Wallpapers." The preview pic of my dog was replaced by what I'll call a "cycle" icon.

But then if I turn OFF "Change Picture every 5 minutes..." the wallpaper reverts to the picture of my dog, which is in a different iPhoto event altogether. The preview pic also reverts to my dog, despite the fact that the "Wallpaper" event is selected and not the event with my dog in it. Running any of the scripts also reveals the dog picture.

I turn Change Picture back on, and it displays a normal wallpaper from the "Wallpaper" event. I log off and log back on, the wallpaper is another random wallpaper. I run all three scripts... and they all bring up the dog picture. I turn off "Change Picture" in the Desktop Preferences... and the preview picture and the wallpaper both revert to my dog. Restarting has the same result as logging off and on.

I believe that this icon is only hiding the previously selected image, and that all of these scripts are bringing up the image behind the "cycle" icon, the most recent image to be manually-selected.

Sorry that was so long and complicated but it's tough to explain. Please help! Thanks!
posted by XSteveMurphy at 2:30 PM on April 25, 2008


I worked on this problem for a very long time and finally concluded that there is no way to get the current random wallpaper. You can only get the selected wallpaper. I wasn't willing to get rid of random wallpapers so I had to do a workaround. I have a cron job that randomly selects a wallpaper and sets it. That way, the OSX built-in random wallpaper never gets turned on and get desktop picture acts as expected. I have another script that just throws out the current wallpaper. I just call it with quicksilver as needed and it works reliably for me. If you would like copies of the scripts, just MeMail me.
posted by MasterShake at 11:38 AM on April 26, 2008


If you have a plist file editor (for example, the one that comes with Developer Tools), open up ~/Library/Preferences/com.apple.desktop.plist. Look at the path /Background/default/NewImageFilePath.

Alas, I am no AppleScript guru, so I don't know how to use that information programmatically.
posted by mkb at 4:14 PM on June 28, 2008


Response by poster: @mkb: I don't think I have a plist editor, and don't have Developer Tools, but I did open this file in Text Editor and see where it lists the current wallpaper. So that's a big step in the right direction, we now know where this file's name is kept.

Now if I could find some way to run a file and have this pop up, or even better open Finder right to the image, then I'm at 100%.

Thanks!
posted by XSteveMurphy at 4:40 AM on August 6, 2008


Response by poster: @mkb - Can you name some (free?) plist editors for me? The text file works but it's awkward, and I'm not sure what programs are out there for plist editing.

Thanks!
posted by XSteveMurphy at 4:43 AM on August 6, 2008


This is the only one I know. It's a free trial. Developer Tools ARE free though.
posted by mkb at 8:17 AM on August 6, 2008


« Older Place to stay in Kyoto and must see sights?   |   Purse contents for the perpetually prepared person Newer »
This thread is closed to new comments.