Re: desktop picture
Re: desktop picture
- Subject: Re: desktop picture
- From: "Nigel Garvey" <email@hidden>
- Date: Fri, 13 Jan 2006 00:07:59 +0000
ME wrote on Wed, 11 Jan 2006 20:31:38 -0500:
>On Jan 11, 2006, at 18:59:59, Nigel Garvey wrote:
>> Is there a reliable way to _get_ the current desktop picture?
>
>The 'random' settings don't affect the static desktop image. All it
>does is tell Dock.app to draw a new image layer on top the static
>desktop picture. This is why, after setting a desktop image with
>applescript, you won't see the image until you uncheck the 'Chang
>picture' option in system preferences.
Thanks, Mike. I didn't know that. It explains (though perhaps doesn't
quite excuse) the problem. After posting the query, I found the relevant
setting in the preference file "com.apple.desktop.plist", but didn't get
much further with it until ...
kai wrote on Thu, 12 Jan 2006 04:26:10 +0000:
>to getTempDesktopPic()
> set pFile to POSIX path of (path to preferences from user domain) &
>"com.apple.desktop.plist"
> try
> tell application "System Events" to tell property list item 1 of
>property list item ¬
> "Background" of property list file pFile to set filePath to value
>of ¬
> property list item "ChangePath" & "/" & value of property list
>item "LastName"
> set fileAlias to POSIX file filePath as alias
> display dialog filePath buttons {"Cancel", "Show Me..."} default
>button 2
> tell application "Finder"
> activate
> reveal fileAlias
> end tell
> on error number errorNumber
> if errorNumber is not -128 then display dialog ¬
> "Data not currently available. Please try again later." buttons
>{"Cancel"} default button 1
> end try
>end getTempDesktopPic
Thanks, kai. That works brilliantly on my Tiger machine. The same file on
my Jaguar machine is in XML format and the System Events there doesn't
have the XML or Property List Suites, but a casual flick of the text item
delimiters does the trick and is good enough for my own use. I've adapted
your script to detect which system it's running on and to use an
appropriate sub-handler to get the path to the picture file. The Tiger
handler contains your System Events code; the Jaguar handler is this:
on JaguarPath() -- Prefs file in XML format, pre System Events XML Suite.
set xmlData to (read file ((path to preferences as Unicode text) &
"com.apple.desktop.plist"))
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "<key>ChangePath</key>"
set folderPosix to "/" & text from word 4 to word -4 of (paragraph 2
of text item 2 of xmlData)
set AppleScript's text item delimiters to "<key>LastName</key>"
set fileName to text from word 4 to word -4 of (paragraph 2 of text
item 2 of xmlData)
set AppleScript's text item delimiters to astid
return (POSIX file (folderPosix & "/" & fileName)) as Unicode text
end JaguarPath
> if errorNumber is not -128 then display dialog ¬
> "Data not currently available. Please try again later." buttons
Definitely inspired by BT's "line busy" announcements! ;-)
NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden