(*
Dock Size and Contents Lock/Unlock Toggle
*)
-- Get the current status
set contentsLockMessage to getCurrentDockContentStatus()
set sizeLockMessage to getCurrentDockSizeStatus()
-- Ask the user if they want to Lock or Unlock the Dock
set userPrompt to (display dialog "Do you want to Lock or Unlock the Dock?" & "
" & "
" & "Current Status:" & space & contentsLockMessage & "," & space & sizeLockMessage buttons {"Lock", "Unlock", "Cancel"} default button "Lock" with title "Dock Lock/Unlock Toggle")
set userAction to button returned of userPrompt
-- Turn the user request into a useable value
if userAction is "Lock" then
set toggleValue to true
else if userAction is "Unlock" then
set toggleValue to false
end if
-- Perform the requested action
toggleDockLock(toggleValue)
------------------------------------------
-- Functions --
------------------------------------------
to toggleDockLock(toggleValue)
set contentsLock to "defaults write com.apple.dock contents-immutable -bool " & toggleValue
set sizeLock to "defaults write com.apple.Dock size-immutable -bool " & toggleValue
-- Perform the requested action
do shell script contentsLock
do shell script sizeLock
do shell script "killall Dock"
end toggleDockLock
to getCurrentDockContentStatus()
try
set contentsLockStatus to do shell script "defaults read com.apple.dock contents-immutable"
on error
set contentsLockStatus to ""
end try
if contentsLockStatus = "0" or contentsLockStatus = "" then
set contentsLockMessage to "Contents unlocked"
else if contentsLockStatus = "1" then
set contentsLockMessage to "Contents locked"
end if
return contentsLockMessage
end getCurrentDockContentStatus
to getCurrentDockSizeStatus()
try
set sizeLockStatus to do shell script "defaults read com.apple.Dock size-immutable"
on error
set sizeLockStatus to ""
end try
if sizeLockStatus = "0" or sizeLockStatus = "" then
set sizeLockMessage to "Size unlocked"
else if sizeLockStatus = "1" then
set sizeLockMessage to "Size locked"
end if
return sizeLockMessage
end getCurrentDockSizeStatus