Stops the macOS Dock from hopping between displays.
The Dock moves to whichever screen you push the cursor against the bottom edge of. DockGuard makes the bottom couple of pixels of your secondary screens unreachable, so that edge condition never happens and the Dock stays put.
A menu bar app. No Dock icon, no installer, no launchd plist. Works with DisplayLink docks as well as directly attached displays.
Grab DockGuard-vX.Y.zip from Releases,
unzip it, and drag DockGuard.app to /Applications.
macOS will block it the first time. The app is ad-hoc signed and not notarized, so Gatekeeper refuses anything downloaded from the internet. To allow it: open it once and let it be blocked, then go to System Settings ▸ Privacy & Security, scroll to the bottom, and click Open Anyway next to DockGuard. The right-click-Open shortcut no longer works for this on macOS 15 and later.
Notarizing would remove that step but needs a paid Developer ID certificate. If you would rather not click through a Gatekeeper warning for an app that asks for Accessibility — a reasonable position — build it yourself instead. A locally built copy is never quarantined, so it just runs.
Then double-click it and grant Accessibility when it asks.
./build.sh # → /Applications/DockGuard.app
./build.sh ~/Desktop # somewhere elseRequires Xcode command line tools (swiftc); no other dependencies.
To cut a release: bump VERSION, then ./release.sh writes
dist/DockGuard-vX.Y.zip. It builds into a staging directory, so your installed
copy keeps running and keeps its Accessibility grant.
| Item | |
|---|---|
| Margin | 1–12 px of dead zone along the bottom edge. Applies immediately. |
| Cursor correction | See below. Leave on Automatic unless something misbehaves. |
| Fence main display too | Off by default — see the note under Behaviour. |
| Start at login | Registers the app with SMAppService. |
| Restart Guard | Tears down and recreates the event tap. |
| Reset Permission & Re-ask… | Clears the Accessibility record so you can grant a fresh one. |
The icon dims whenever the fence is not actually up.
Only secondary displays are fenced by default. The Dock lives on the main
display, so fencing that one does not help pin it — and it would break
reveal-on-hover for an auto-hidden Dock. Fence main display too is there if
you want it anyway.
Edges shared with another display are never fenced. If a screen sits directly below another, blocking its bottom edge would make it impossible to move the cursor between them. DockGuard checks whether another display continues below the point being clamped and lets the cursor through if so.
That check is per-X, so a screen stacked above another stays crossable where the
two overlap and stays fenced where its bottom edge is genuinely exposed — an
arrangement where the top screen is wider than, or offset from, the one below
gets both behaviours along the same edge. --selftest covers these cases.
Horizontal movement is untouched. Only Y is pinned, so you can still slide along the bottom edge normally.
A .cghidEventTap sits ahead of the window server, so rewriting a mouse event's
location there is enough to move the cursor. CGWarpMouseCursorPosition is the
fallback for when it isn't — but each warp briefly disassociates the mouse from
the cursor, and doing that on every event makes sliding along the edge feel
stuck.
- Automatic (default) — rewrite the event, and warp only when the previous rewrite is observed not to have held.
- Always — warp on every clamped event. Reliable, but sliding drags.
- Never — rewrite only.
DockGuard needs Accessibility to create its event tap.
Rebuilding changes the app's code hash, which leaves macOS holding a grant it
lists as enabled but silently refuses — AXIsProcessTrusted() keeps answering
true while the event tap gets denied. The app detects that state and offers
Reset Permission & Re-ask…; build.sh also clears the grant automatically
before it replaces the bundle. Both rely on tccutil, which only resolves
bundle identifiers — one of the reasons this ships as an app bundle rather than
a bare executable.
Ad-hoc signing means this happens on every rebuild. Avoiding it would need a Developer ID certificate.
/Applications/DockGuard.app/Contents/MacOS/dockguard --status
/Applications/DockGuard.app/Contents/MacOS/dockguard --login on|off
/Applications/DockGuard.app/Contents/MacOS/dockguard --selftest
log stream --predicate 'subsystem == "com.stan.dockguard"'--status prints permission state, settings, and the display layout with each
screen marked fenced or free.
CC0 1.0 Universal.