Apple - Remember window sizes and placement when unplugging and replugging second monitor

Have a look at Stay by Cordless Dog. I believe it does exactly what you're looking for.


Slate is a very powerful free Mac app that does exactly what you want. When you plug in your secondary monitor, it automatically detects the new monitor, and all of your windows will be moved and resized just the way you like them. You can define custom positions and sizes for all of your applications, including full screen, half screen, and grid-based.

One of the coolest things about Slate is that you can define different layouts based on how many monitors you have connected. For example, if you are using your laptop by itself, you might want to have all of your apps filling the whole screen. But when you have a larger secondary monitor, you might want to split up your screen between your browser, mail, and music. Slate does this easily.

You can also define keyboard shortcuts for specific layouts and actions such as nudging and resizing windows by a certain percentage.

Below is my configuration file. I keep all of my apps at full screen on all of my monitors, but you can change it to make them half or some other size:

# Monitor Aliases
alias mon-laptop    0    # variable for my laptop monitor
alias mon-hp        1    # my external HP monitor

# Window Position Regions
alias hp-full        move screenOriginX;screenOriginY screenSizeX;screenSizeY         ${mon-hp}
alias hp-left        move screenOriginX;screenOriginY screenSizeX/2;screenSizeY         ${mon-hp}
alias hp-right       move screenOriginX+screenSizeX/2;screenOriginY screenSizeX/2;screenSizeY         ${mon-hp}
alias laptop-full        move screenOriginX;screenOriginY screenSizeX;screenSizeY         ${mon-laptop}
alias laptop-left        move screenOriginX;screenOriginY screenSizeX/2;screenSizeY         ${mon-laptop}
alias laptop-right       move screenOriginX+screenSizeX/2;screenOriginY screenSizeX/2;screenSizeY         ${mon-laptop}
alias laptop-righttop    move screenOriginX+screenSizeX/2;screenOriginY screenSizeX/2;screenSizeY/2       ${mon-laptop}
alias laptop-rightbottom move screenOriginX+screenSizeX/2;screenOriginY+screenSizeY/2    screenSizeX/2;screenSizeY/2       ${mon-laptop}

# Window layouts for when I have 2 monitors
layout 2monitor 'Google Chrome':REPEAT ${hp-full}
layout 2monitor 'iCal':REPEAT ${hp-full}
layout 2monitor 'Coda':REPEAT ${hp-full}
layout 2monitor 'Mail':REPEAT ${laptop-full}
layout 2monitor 'Rdio':REPEAT ${laptop-full}
layout 2monitor 'Spotify':REPEAT ${laptop-full}
layout 2monitor 'Evernote':REPEAT ${laptop-full}

# Single monitor window layouts
layout 1monitor 'Google Chrome':REPEAT ${laptop-full}
layout 1monitor 'iCal':REPEAT ${laptop-full}
layout 1monitor 'Coda':REPEAT ${laptop-full}
layout 1monitor 'Mail':REPEAT ${laptop-full}
layout 1monitor 'Rdio':REPEAT ${laptop-full}
layout 1monitor 'Spotify':REPEAT ${laptop-full}
layout 1monitor 'Evernote':REPEAT ${laptop-full}

# Keyboard shortcuts for each layout
bind l:shift;ctrl layout 2monitor
bind g:shift;ctrl grid padding:5 0:2,1 1:2,2

# Auto-detect when a monitor is plugged in or out
default 2monitor count:2
default 1monitor count:1

Here is the list of features from Slate's GitHub page:

  • Highly customizable
  • Bind keystrokes to:
    • move and/or resize windows
    • directionally focus windows
    • activate preset layouts
    • create, delete, and activate snapshots of the current state of windows
  • Set default layouts for different monitor configurations which will activate when that configuration is detected.
  • Window Hints: an intuitive way to change window focus
  • [Beta] A better, more customizable, application switcher.

Here is a great tutorial on how to get the most out of Slate.


I have solved this with a small AppleScript and the small freeware utility Quicksilver.

  1. Save this small AppleScript in a location that will not change on your computer:

    try
        tell application "Adium"
            activate
            tell window "contacts"
                set the bounds to {1281, 200, 1460, 850}
            end tell
            tell chat windows
                set the bounds to {1281, 800, 1800, 1200}
            end tell
        end tell
    end try
    
    try
        tell application "iTunes"
            activate
            set the bounds of the first window to {1750, 520, 2700, 1150}
        end tell
    end try
    
    try
        tell application "Terminal"
            activate
            set the bounds of the first window to {2450, 320, 3180, 950}
        end tell
    end try
    
    try
        tell application "Firefox"
            activate
            set the bounds of the first window to {1460, 20, 2800, 950}
        end tell
    end try
    
  2. You will need to customize which applications you want on your monitor and the window bounds the way you like them. I'm a programmer and the above configuration is how I run my second monitor.

  3. Install Quicksilver.

    I chose to make it not visible in the Dock, and just run as a small taskbar daemon

  4. Set up a key command in Quicksilver, and drag and drop your AppleScript from step 1 into the window as the action to perform. I bound it to CommandShiftA. Works great!