A script to dim my Macbook display when an external display is detected

To save a bit of energy while my laptop is mirrored to my external display.