Use this to dim your Mac screen when you plug in a monitor.
Connects a callback using CGDisplayRegisterReconfigurationCallback to dim the built-in screen down to zero only when an external monitor is plugged in.
I recommend registering this file as a daemon that starts when you log in. To do this, do the following:
$ cd path-to-dim-clone
$ make
$ mkdir -p ~/Library/LaunchAgents
Now, open local.dim.plist and edit the line underneath the Program key to point to the correct executible path. Then,
$ cp local.dim.plist ~/Library/LaunchAgents
Log out and log back in. The daemon will automatically run in the background.