DockGuard.spoon is a Hammerspoon plugin(Spoon) that prevents the macOS Dock from moving from the main monitor (the one with the menu bar) to another monitor.
⚠️ Note: If 'Automatically hide and show the Dock' is enabled, this plugin(Spoon) may not work as expected.
By default, macOS allows the Dock to move to a secondary monitor if the mouse cursor stays at the bottom edge of a screen without a Dock for a certain period. DockGuard.spoon prevents this by nudging the mouse cursor upward when it approaches the bottom edge, so the Dock does not move. Don't worry, unless you look very closely, you won't notice the cursor movement.
- Install Hammerspoon
- If you have Homebrew, run:
brew install --cask hammerspoon open -a Hammerspoon
- Or download and install from the official Hammerspoon website.
- If you have Homebrew, run:
- Download or clone this repository.
- Copy the
DockGuard.spoonfolder to your~/.hammerspoon/Spoons/directory. - Add the following to your
~/.hammerspoon/init.luato activate DockGuard.spoon:hs.loadSpoon("DockGuard") spoon.DockGuard:start()
- Click the Hammerspoon icon in the menu bar and select 'Reload Config'. (If it does not work, check Accessibility permissions in 'Preferences'.)
DockGuard.spoon has been tested with macOS Sequoia (15.1.1) using the default settings. If it does not work as expected on your macOS version, try adjusting the following parameters:
edgeTriggerMargin: Number of pixels from the bottom edge to trigger the nudge (default: 1)mouseNudgeDistance: Number of pixels to nudge the cursor upward (default: 1)watcherRestartDelay: Delay (in seconds) before restarting the watcher after nudging (default: 0.1)
Example configuration:
hs.loadSpoon("DockGuard")
spoon.DockGuard.edgeTriggerMargin = 5 -- Trigger within 5px of the bottom edge
spoon.DockGuard.mouseNudgeDistance = 2 -- Nudge cursor up by 2px
spoon.DockGuard.watcherRestartDelay = 0.2 -- Restart watcher after 0.2s
spoon.DockGuard:start()This project is released under The Unlicense. See LICENSE for details.