This question already has an answer here:
When I have a giant Thunderbolt monitor plugged into my MacBook, I want windows arranged a certain way. No full-screen apps, some apps are shown on my small laptop screen, other apps are shown on my Thunderbolt display. When I unplug the Thunderbolt display, I would like programs arranged differently, e.g., the browser is a full-screen app. Is there any program that will let me "save" my window state when I have an external monitor plugged in, and save another layout when I don't have any external display, and automatically switch between the two when it detects that external display has been plugged in or unplugged? I'm on Mountain Lion on a MacBook Pro.