Make Different Resolutions Remember Unique Window Sizes

Discussion in 'macOS' started by kolax, Feb 21, 2010.

  1. kolax macrumors G3

    Joined:
    Mar 20, 2007
    #1
    This is the plan: when the resolution is changed for the primary display (i.e. changing the resolution of your laptop display or hooking up to an external monitor and using that as the primary display) apply the window size and positions for that specific resolution.

    Imagine you are working with two resolutions, A and B. When using A, you have your Safari window at 400 by 600 and at position 12 (for examples sake). When you switch to resolution B the application loads up the window data for that resolution and Safari's window then becomes 800 by 600 and position 45.

    Obviously, if you selected a resolution that didn't have any window data yet, then the windows would remain in the positions prior to the resolution change and when you adjusted them, they would become the preset for that resolution.

    This happens for all windows for all applications. The idea is, if you work with an external monitor for your laptop and are switching between being connected to the external display, then you don't have to worry about having to constantly resize your windows.

    On 1280x800 resolution, I like Safari to be a set size, but when on an external monitor at say 1920x1200. I want Safari to be much bigger and in a different position. When switching between the two resolutions, I have to resize Safari. The same applies to every application I work with. Really irritating to have to resize windows all the time.

    Would be great if someone could write a script/app that when the resolution is changed, window sizes are loaded for that specific resolution.

    Anyone else in the same boat of finding it really irritating having to resize windows all the time?
     
  2. pit29 macrumors 6502a

    pit29

    Joined:
    May 23, 2006
    Location:
    The Golden State
  3. kolax thread starter macrumors G3

    Joined:
    Mar 20, 2007
    #3
  4. pit29 macrumors 6502a

    pit29

    Joined:
    May 23, 2006
    Location:
    The Golden State
    #4
    There's actually a similar program called Display Maestro, which you may want to check out as well (it's only 4.95, and $). No idea whether it can also do the stuff you want.
     
  5. kolax thread starter macrumors G3

    Joined:
    Mar 20, 2007
    #5
    SwitchResX seems to do partially what I want.

    Each open application switches its window size and position when I change between two (saved) resolutions. Thing is, when I quit the application, it no longer retains the data for the two resolutions and OS X just loads the previous state window data.
     
  6. kasakka macrumors 68000

    Joined:
    Oct 25, 2008
    #6
    I've solved the problem by writing an Applescript so I always have my main applications at the right size and position on both my home 2560x1600 res display and my work 1920x1200 display.

    Basically it checks which resolution is used and then places and sizes each app's main window accordingly. I'll try to remember to post the script tomorrow.

    You can also turn it into an application to run after switching displays. I used Platypus 4.0 for this with a custom icon. So when I switch displays, I just launch the application from my desktop and the windows are where they're supposed to be.
     
  7. kolax thread starter macrumors G3

    Joined:
    Mar 20, 2007
    #7
    Exactly what I want to do! Please post the script.

    Would be good at some point to develop something that logs the size and position, so if you resize a window on one resolution, you don't have to manually update the script.
     
  8. kasakka macrumors 68000

    Joined:
    Oct 25, 2008
    #8
    Here you go. You might want to make separate rules for your MBP's resolution, I haven't gotten around to it yet. You can use Activity Monitor to find the process names, but generally application names will work just fine.

    It firsts reads the width and height of the Finder desktop (monitor resolution) and this won't work if Finder is not running or its desktop is hidden (e.g. if using Path Finder with the Hide Finder Desktop option). Then it uses System Events to set sizes and positions because many apps don't report these properties otherwise. To find the current sizes you can use "get bounds of front window" for most applications. "get position of front window" for position. The numbers are in a {X,Y} format.

    The script also sets the Dock on the bottom on my 2560x1600 display but left for anything else.

    Code:
    tell application "Finder"
        set _b to (desktop's window's bounds)
        set _w to item 3 of _b
        set _h to item 4 of _b
    end tell
    
    
    tell application "System Events"
        activate application "Finder"
        if _w > 1920 then
            tell process "Finder" to click menu item "Position on Bottom" of menu 1 of menu item "Dock" of menu 1 of menu bar item "Apple" of menu bar 1
        else
            tell process "Finder" to click menu item "Position on Left" of menu 1 of menu item "Dock" of menu 1 of menu bar item "Apple" of menu bar 1
        end if
        if exists process "Firefox" then
            tell process "Firefox"
                if _w > 1920 then
                    set _newSize to {1350, 1516}
                else
                    set _newSize to {1200, 1173}
                end if
                set size of front window to _newSize
                set _windowSize to size of front window
                set position of front window to {_w / 2 - (item 1 of _windowSize) / 2, 22}
            end tell
        end if
        
        if exists process "Google Chrome" then
            tell process "Google Chrome"
                if _w > 1920 then
                    set _newSize to {1350, 1516}
                else
                    set _newSize to {1200, 1173}
                end if
                set size of front window to _newSize
                set _windowSize to size of front window
                set position of front window to {_w / 2 - (item 1 of _windowSize) / 2, 22}
            end tell
        end if
        
        if exists process "Facebook" then
            tell process "Facebook"
                set size of front window to {1000, 710}
                if _w > 1920 then
                    set _newPos to {1400, 485}
                else
                    set _newPos to {780, 485}
                end if
                set position of front window to _newPos
            end tell
        end if
        
        if exists process "Linkinus" then
            tell process "Linkinus"
                if _w > 1920 then
                    set _newSize to {1050, 730}
                    set _newPos to {5, 22}
                else
                    set _newSize to {1050, 780}
                    set _newPos to {65, 22}
                end if
                set size of front window to _newSize
                set position of front window to _newPos
            end tell
        end if
        if exists process "Gmail" then
            tell process "Gmail"
                set size of front window to {1000, 775}
                if _w > 1920 then
                    set _newPos to {1400, 22}
                else
                    set _newPos to {780, 22}
                end if
                set position of front window to _newPos
            end tell
        end if
        if exists process "Google Reader" then
            tell process "Google Reader"
                if _w > 1920 then
                    set _newPos to {5, 758}
                else
                    set _newPos to {65, 415}
                end if
                set size of front window to {1050, 780}
                set position of front window to _newPos
            end tell
        end if
    end tell
     

Share This Page