Reputation: 29
I do have the following two applescripts which are doing the same thing in different ways. The scripts are finding and displaying the path and the image name of the current wallpaper on OS X Yosemite 10.10.3 and then showing the original image in finder.
I am working in dual monitor mode, so I have to find the current wallpaper for the primary monitor and for the secondary monitor. In my scripts I address the different monitors either with "desktop 1" and "desktop 2" or with "preferences.picture_id=3" for the primary monitor or "preferences.picture_id=5" for the secondary monitor.
Both scripts are working in principle, but because of some reason both scripts are sometimes not working for both monitors (Primary and secondary) but just for one of them. Sometimes for primary but not secondary and sometimes visa versa.
If the scripts are not working they showing the error number 10010.
I searched the net for days and I tried all kind of different things bit I could not find the problem. I have to say I am not a applescripts specialist. Help would very much appreciated.
Kind Regards,
Peter
Here are the two scripts:
Script 1:
tell application "System Events"
set posix_path to (pictures folder of desktop 2)
set picPath to (POSIX file posix_path) as string
end tell
tell application "System Events"
tell current desktop
if picture rotation = 0 then
tell application "System Events"
set posix_path to (picture of desktop 2)
set thePicture to (POSIX file posix_path) as string
end tell
tell application "Finder"
reveal thePicture
activate
end tell
else
set thePictures to (do shell script "sqlite3 ~/Library/Application\\ Support/Dock/desktoppicture.db \"SELECT * FROM data\" | sed -n '$p'")
set fullPath to picPath as string
set rotationImage to fullPath & thePictures
tell application "Finder"
reveal rotationImage
activate
end tell
end if
end tell
tell application "Finder"
get selection
repeat with moose in result
if original item of moose exists then
reveal original item of moose
end if
end repeat
end tell
end tell
Script 2:
tell application "System Events"
set posix_path to (pictures folder of desktop 1)
set picPath to (POSIX file posix_path) as string
end tell
set thePictures to (do shell script "sqlite3 ~/Library/Application\\ Support/Dock/desktoppicture.db \"SELECT data.value FROM preferences INNER JOIN data on preferences.key=16 and preferences.picture_id=3 and preferences.data_id=data.ROWID\"")
set fullPath to picPath as string
set rotationImage to fullPath & thePictures
tell application "Finder"
reveal rotationImage
activate
end tell
tell application "Finder"
get selection
repeat with moose in result
if original item of moose exists then
reveal original item of moose
end if
end repeat
end tell
Upvotes: 2
Views: 1470
Reputation: 738
If what you're trying to do is show the current wallpapers for your desktops, you can simply use this code:
tell application "System Events"
repeat with current_desktop in desktops
set picPath to POSIX file (picture of current_desktop) as string
tell application "Finder" to reveal picPath
end repeat
end tell
Upvotes: 1