Go Back   The macosxhints Forums > Working with OS X > Tweaking OS X / Wish List



Reply
 
Thread Tools Display Modes
Old 05-06-2006, 11:50 PM   #1
bongo_x
Registered User
 
Join Date: May 2006
Posts: 1
hey

I'm not sure if this is the right place for this, but;

is there a way to display the name of my current desktop picture?

I have 1200 or more pictures in a folder changing randomly. when I decide I would like to get rid of one it takes 10 minutes to find it.

thanks for your help

bb
bongo_x is offline   Reply With Quote
Old 05-07-2006, 06:38 AM   #2
6502
Major Leaguer
 
Join Date: Mar 2006
Posts: 335
Here's the AppleScript to snag the name from my computer. You'll have to look in your own com.apple.desktop.plist file (at ~/Library/Preferences) to see if the path is the same (I suspect that it's not). Use the Property List Editor to view the pref's file properly.

Code:
tell application "System Events"
	set my_desktop to value of (property list item "LastName" of property list item "1983938400" of property list item "Background" of property list file ((path to preferences as Unicode text) & "com.apple.desktop.plist"))
	
	display dialog my_desktop
end tell
Hey! I just realized... this would make a great tip for the front page....

Last edited by 6502; 05-07-2006 at 06:55 AM.
6502 is offline   Reply With Quote
Old 05-07-2006, 06:53 AM   #3
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by 6502
Here's the AppleScript to snag the name from my computer

That didn't work on my system.
But this (modified version of your script) does work:
Code:
tell application "System Events"
	set my_desktop to value of (property list item "ImageFilePath" of property list item "default" of property list item "Background" of property list file ((path to preferences as Unicode text) & "com.apple.desktop.plist"))
	
	set my_desktop to my_desktop as text
	display dialog my_desktop
end tell
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 05-07-2006, 07:03 AM   #4
6502
Major Leaguer
 
Join Date: Mar 2006
Posts: 335
Looking at the ImageFilePath item in my .plist file, I see a significant problem with using it.

On my Mac, it shows the path to the first image that I selected from my screens folder. It doesn't show the path to the current file being randomly selected from that folder. Do you get the full path that way? Or just the file name? I assumed that the goal was to snag just the file name.

...and in playing around, I just noticed that I don't have to coerce my_desktop to text. I've modified my original post to reflect that change.

...and looking at the path you're using, I can tell there's a SIGNIFICANT difference between our .plist files. There's no such entry for an item "default" in mine.

Last edited by 6502; 05-07-2006 at 07:14 AM.
6502 is offline   Reply With Quote
Old 05-07-2006, 07:22 AM   #5
6502
Major Leaguer
 
Join Date: Mar 2006
Posts: 335
Oh! Playing with your code, I can see that I don't need to have a literal .plist entry for "default."

It sort of works, but it pulls up the path to the first image that I selected from that folder rather than displaying the name or path of the current desktop image.

I think you need to use the value of the LastName plist item.
6502 is offline   Reply With Quote
Old 05-07-2006, 01:20 PM   #6
bongo_x
Registered User
 
Join Date: May 2006
Posts: 1
thanks a lot for the help, I know almost nothing about this but I tried to follow what you were saying and ended up with this;

tell application "System Events"
set my_desktop to value of (property list item "LastName" of property list item "default" of property list item "Background" of property list file ((path to preferences as Unicode text) & "com.apple.desktop.plist"))

set my_desktop to my_desktop as text
display dialog my_desktop
end tell

and it works! thanks again.

bb
bongo_x is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 08:31 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.