I ran into the same problem a while ago, and here's what I did:
First, I mirrored the displays, as has already been suggested. Soon after doing this, I realized that it was very distracting to have the macbook's lit screen off in the corner of my eye. This required that I kill the brightness on the macbook's screen. But being the lazy guy that I am, I hated having to manually adjust the brightness every time I un/plugged an external monitor. So I wondered if there was a way to automate the process. I found this free app called Control Plane which let's me set "contexts" based on whether certain devices (monitors, hard drives, etc) are plugged in, whether certain wi-fi networks are in range, etc; and based on these contexts, run certain shell scripts. So all I had to do was write an applescript (called killBrightness.scpt
) to kill the brightness on the macbook's screen and a shell script to call killBrightness.scpt
; and call this shell script in the required context.
killBrightness.scpt
tell application "System Preferences" to set current pane to pane "Displays"
tell application "System Events"
tell process "System Preferences"
repeat with theWindow in windows
if title of theWindow as string is "Color LCD" then
tell tab group 1 of theWindow
tell slider 1 of group 2
set value to 0
end tell
end tell
end if
end repeat
end tell
end tell
tell application "System Preferences" to quit
The shell script
#!/bin/sh
osascript /path/to/killBrightness.scpt
Since I plug many different monitors into my macbook, I noticed that when one with a different aspect ratio is plugged in, my windows hang off the edge of the screen. The solution to this would be to resize the windows, but that's highly inefficient when you use a ton of apps and windows like I do; also, me being as lazy as I am, didn't like that solution. So, with the help of the nice folks over at Stack Overflow, I was able to come up with this AppleScript (called resizer.scpt
) to automagically resize all windows of (almost) all apps (the caveat is that some applications don't use the correct UI framework hooks, so it's quite difficult to resize them):
resizer.scpt
:
property blacklist : {"Finder", "Preview", "Console", "AppleScript Editor", "Spotify", "TaskCoach", "Skype", "VirtualBox"}
property buttonApps : {"LyX", "Eclipse"}
property buttonMaps : {{name:"LyX", Button:1, pname:"lyx"}, {name:"Eclipse", Button:2, pname:"eclipse"}, {name:"Spotify", Button:3, pname:"Spotify"}, {name:"TaskCoach", Button:3, pname:"TaskCoach"}}
tell application "Finder" to set theBounds to bounds of window of desktop
tell application "System Events"
set bids to bundle identifier of processes where background only is false
end tell
repeat with bid in bids
tell application id bid
if name is not in blacklist then
set appName to name as string
if name is "Terminal" then
set newBounds to {0, 0, (item 3 of theBounds) - 10, item 4 of theBounds}
repeat with theWindow in windows
if visible of theWindow is true then
set bounds of theWindow to newBounds
end if
end repeat
else if name is not in buttonApps then
try
repeat with theWindow in windows
if visible of theWindow is true then
set bounds of theWindow to theBounds
end if
end repeat
end try
else if name is in buttonApps then
-- get the buttonNumber
repeat with buttonApp in buttonMaps
if (name of buttonApp as string) is appName then
set theButton to Button of buttonApp
end if
end repeat
tell application "System Events"
repeat with theProcess in (processes where bundle identifier is bid)
try
tell theProcess to tell window 1 to click button theButton
end try
end repeat
end tell
end if
end if
end tell
end repeat
Now, all I had to do was write a similar shell script to call resizer.scpt
and put that into ControlPlane and I was all set to be lazy all over again!
Hope this helps
PS: I forgot to mention before that all of this was done on my 15 inch MacBook Pro, running Lion