Skip to content

Instantly share code, notes, and snippets.

@codewings
Created November 16, 2016 15:23
Show Gist options
  • Save codewings/d131c070a6b9608ab9b5261909a37f4e to your computer and use it in GitHub Desktop.
Save codewings/d131c070a6b9608ab9b5261909a37f4e to your computer and use it in GitHub Desktop.
Lock or Unlock the OSX dock
-- Version 1.0.2
set currentStatus to "0"
try
set currentStatus to do shell script "defaults read com.apple.dock contents-immutable"
end try
if currentStatus is equal to "0" then
tell application "Finder" to display alert "Lock the icons in the Dock?" buttons {"Cancel", "Lock"}
else
tell application "Finder" to display alert "Unlock the icons in the Dock?" buttons {"Cancel", "Unlock"}
end if
copy the result as list to {theButton}
if theButton is "Lock" then
do shell script "defaults write com.apple.dock contents-immutable -bool true"
tell application "Dock" to quit
else if theButton is "Unlock" then
do shell script "defaults write com.apple.dock contents-immutable -bool false"
tell application "Dock" to quit
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment