AppleScript code to help lock your Mac's Dock to your main screen. This is a common issue with multiple monitors, as the Dock can sometimes appear on secondary screens or move unexpectedly.
- Open "Script Editor" on your Mac (you can find it in Applications > Utilities or search for it using Spotlight)
- Copy and paste the code above into a new Script Editor document
- Save the file with a name like "LockDockToMainScreen.scpt"
- Run the script by clicking the "Play" button in Script Editor
The script works by:
- Determining your current Dock position and orientation settings
- Continuously monitoring these settings
- Resetting the Dock to your main screen whenever it detects movement
If you want to set a specific position for your Dock instead of using your current settings:
- Replace
originalPositionwith either "bottom", "left", or "right" - Replace
originalOrientationwith either "start", "middle", or "end"
For example, to always keep the Dock at the bottom center of your main screen:
property originalPosition : "bottom"
property originalOrientation : "middle"