I know GUI scripting is typically not suggested due to the rapid changes between OS builds, but I’ve been searching over a week now on how to script the System Preferences “Change picture:” check box within Desktop & Screen Savers. I’ve seen a few scripts here on this site that do just that, but none of them have worked. I thought rewriting the com.apple.desktop.plist was the best bet (and I did score it with moderate success), but evidently you can only change the desktop picture and paths, not any other variants of that preference pane (although change intervals are flagged within the plist’s XML) without crashing that particular tab in System Preferences. I’ve used UIBrowser and UIElementInspector again with moderate success. So I ask you script gurus, please help me out.
This is the best of what I have so far (even if it’s elementary) and please let me know if I can also adjust the change interval to 5 minutes:
tell application "System Preferences"
set current pane to pane id "com.apple.preference.desktopscreeneffect"
delay 2
tell application "System Events"
tell application "System Preferences" of window 1 of tab group 1 of group 1 of checkbox 1 to set to true
end tell
end tell
end tell
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.desktopscreeneffect"
end tell
tell application "System Events"
tell application process "System Preferences"
click checkbox "Change picture:" of group 1 of tab group 1 of window "Desktop & Screen Saver"
end tell
end tell
drawn a blank with the change every 5 minutes pop up though!! sorry
I can’t tell you how long I’ve been trying to wrap my head around that. As for adjusting the “Change picture:” rotation I’ve been able to adjust only through a shell command and even that seemingly wipes the plist to once again disable the checkbox (also it only defaults to 30 minutes no matter how many seconds you assign to it) by adding:
do shell script "defaults write com.apple.desktop Background ChangeTime=300"
I will keep on working on this and see what I can come up with. In the meantime I truly appreciate your assistance.
OK, I figured out how to accurately change the desktop (and in what increments) thanks to both pidge and kai. All I did was add kai’s changetime formula to the script pidge helped me iron out. Thank you both, this is all part of a greater scheme in which I automate tweaking of ByHost preferences when they sometimes don’t carry over after a netinstall.
--desktop script - (Thanks to both kai and pidge!). UI script clicks Sys Pref check box while finding and modifying the "changeTime" path inside the desktop.plist XML. PS - since paths are used as opposed to visual UI scripting, the "Change picture:" drop down menu will not accurately reflect the interval in which it changes.
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.desktopscreeneffect"
end tell
tell application "System Events"
tell application process "System Preferences"
click checkbox "Change picture:" of group 1 of tab group 1 of window "Desktop & Screen Saver"
tell application "System Events" to tell (property list item "ChangeTime" of (property list items where ¬
name of property list items contains "ChangeTime")) of property list item "Background" of ¬
property list file ((path to preferences as Unicode text) & "com.apple.desktop.plist") to if exists then
set v to "300.000000"
set value to (v div 0.5) - v + 0.01
end if
end tell
end tell