I have just coded this to toggle my icons appearing. But it will not actually work. If I enter the commands in Terminal, it works. So I am stumped. Any suggestions?
if (do shell script "defaults read com.apple.finder CreateDesktop") is false then
do shell script "defaults write com.apple.finder CreateDesktop true"
else
do shell script "defaults write com.apple.finder CreateDesktop false"
end if
delay 1
do shell script "killall Finder"
Thanks
Model: Macbook Pro
AppleScript: Latest
Browser: Safari 601.3.9
Operating System: Mac OS X (10.10)
On mine, it produces the error “The domain/default pair of (/Blah/blah/Library/Preferences/com.apple.finder, CreateDesktop) does not exist” ” meaning that the CreateDesktop value ” if there is one ” hasn’t been changed from the factory setting. Ideally, a toggling script needs to test if the defaults contain the non-factory setting. If not, the setting’s either not included or has been explicitly set to the factory value. The factory setting here is apparently true (or 1), so the setting for which to test is 0 (= false). To change the setting to true, you can either set it explicitly or delete it.
if ((do shell script "defaults read com.apple.finder") contains "CreateDesktop = 0") then
do shell script "defaults delete com.apple.finder CreateDesktop"
else
do shell script "defaults write com.apple.finder CreateDesktop -bool false"
end if
delay 1
do shell script "killall Finder"