Toggle desktop
Last modification: Saturday, August 22, 2009 12:24 pmSets the Finder to either show or hide the desktop
Implementation
-- Get the current value for the preference settingtry
set _bitSet to do shell script "defaults read com.apple.Finder CreateDesktop"
set _bitSet to _bitSet as integer
set _bitSet to _bitSet as boolean
on error
set _bitSet to true
end try
-- Quit the target application, allowing recent changes by the user to be saved
tell application "Finder" to quit
repeat 100 times
tell application "System Events" to if (exists process "Finder") is false then exit repeat
delay 0.1
end repeat
if _bitSet then
do shell script "defaults write com.apple.Finder CreateDesktop -boolean NO"
else
do shell script "defaults write com.apple.Finder CreateDesktop -boolean YES"
end if
-- Launch the Finder
tell application "Finder" to launch