MacOS – enable hiding the dock on the MacBook monitor only

displaydockmacos

When at home I use my 13" MacBook Pro hooked up to an 27" external monitor. When working on my 27" screen I prefer to have a visible dock at all times. I have enough screen real estate to afford this luxury.

When I'm on the road working on my 13" screen I prefer to automatically hide the dock as it really gets in the way when screen real estate is limited.

I now manually switch between enabling and disabling hiding (using ⌥⌘D) but I would prefer this to happen automatically. Can I enable hiding the dock on my MacBook monitor and disable hiding the dock on my external monitor?

Best Answer

I was able to use the previously suggested ControlPlane app along with some simple shell scripts to get this working.

First, I created a context for having my Thunderbolt Display plugged in ("Desk"), and one that negated that choice ("Lap"). Next, I made two simple shell scripts to toggle the autohide setting and restart the Dock. I put them in a .controlplane directory in my home folder.

~/.controlplane/dock-hiding-on.sh

defaults write com.apple.dock autohide -bool true && killall Dock

~/.controlplane/dock-hiding-off.sh

defaults write com.apple.dock autohide -bool false && killall Dock

I then set those files to be executable.

Lastly, I set the correct script to run for the appropriate ControlPlane context. (Note: I had to show hidden files in the dialog with "⌘+⇧+.")