macosshellapplescript

Move OS X Dock to other monitor programmatically


I'm using 2 external monitors with my rMBP (one via thunderbolt/DVI and one via HDMI). The lid of the laptop is closed. Is it possible to move the Dock and the Menu Bar from one display to the other (ie. make it the main display) programmatically?

I use ControlPlane to detect certain situations and I'd like to swap the main monitor if a situation occurs with a script (like bash or AppleScript).

I looked in the com.apple.dock.plist but didn't find any key that I could use.


Solution

  • Yes, you can do that with a command line tool I wrote here. There's an example applescript to show you how it might be used.