Steven Levine
Steven Levine
1 min read


The Problem

You have a MacBook and a nice Apple Cinema display (this doesn’t sound like a problem so far), and you travel with the MacBook every day. When you open the lid of your MacBook you like to have the Dock on the left side of the screen giving you the most top to bottom space, but when you come home and connect the MacBook to your Cinema display and set up dual monitors, you want the dock on the bottom of the Cinema, not on the left side of the MacBook.

You don’t want to have to go in to preferences every time to switch the location. (or maybe you do?) For me it was becoming a very tedious task, so I began researching ways to automate it.

The Solution

Leverage Apple’s “Language of Automation”, Applescript to handle the task. Applescript has lots of useful hooks in to OS X.

The requirements for the script are quite simple:

  • Obtain the current resolution of the primary monitor
  • if the resolution is > 1900 (Cinema Display) configure the Dock for large display
  • else configure the Dock for laptop display

For the moment, that is my goal, simple, yet time saving.

Step 1: Open AppleScript Editor Step 2: Paste the following code in

Step 3: Run it to make sure it works as expected, if so, save the script as application, so you don’t need to open AppleScript Editor each time you want to run it.

Future requirements

  • Figure out how to hook the script in to sleep/wake events in Snow Leopard.
  • Customize more than just the Dock.
  • Migrate it in to a startup script that brings up all necessary applications based upon current mood (reading/blogging/coding).
  • Others???

Overall, I find Applescript a very easy way to automate things in Snow Leopard.

All of the source for this post can be found on Please feel free to fork and improve. Enjoy.