how to make four windows of the same app fill four quadrants of a screen using slate

2

I can move a window to the top left corner of a screen using something like this in slate

bind a:shift;cmd;alt move screenOriginX;screenOriginY screenSizeX/2;screenSizeY/2

usually when I fire sequel pro.. i like to automatically make four windows of it cover four quadrants of the screen.

I was wondering if I can bind a key in slate to make that automatically (it's ok if i have to manually create four windows of it.. all i need is slate to actually place those windows in the right spots).

abbood

Posted 2014-04-18T03:39:45.877

Reputation: 702

Answers

2

I couldn't figure out how to do it without hard-coding the application name, but try something like this:

alias topleft move screenOriginX;screenOriginY screenSizeX/2;screenSizeY/2
alias topright move screenOriginX+screenSizeX/2;screenOriginY screenSizeX/2;screenSizeY/2
alias bottomleft move screenOriginX;screenOriginY+screenSizeY/2 screenSizeX/2;screenSizeY/2
alias bottomright move screenOriginX+screenSizeX/2;screenOriginY+screenSizeY/2 screenSizeX/2;screenSizeY/2

layout texteditquadrants 'TextEdit' ${topleft} | ${topright} | ${bottomleft} | ${bottomright}
bind 1:ctrl layout texteditquadrants

If you have one only screen, you can use an AppleScript like this:

tell application "Finder"
    set {0, 0, w, h} to bounds of window of desktop
end tell
tell application "System Events" to tell (process 1 where frontmost is true)
    set n to number of windows
    if n > 4 then set n to 4
    repeat with i from 1 to n
        set p to item i of {{0, 22}, {w / 2, 22}, {w / 2, h / 2 + 11}, {w / 2, h / 2 + 11}}
        set position of window i to p
        set size of window i to {w / 2, h / 2 - 11}
    end repeat
end tell

This creates four new TextEdit windows and tiles them on the screen:

tell application "Finder"
    set {0, 0, w, h} to bounds of window of desktop
end tell
set ytop to 22
set yhalf to (h - 22) / 2
tell application "TextEdit"
    close windows
    repeat with i from 1 to 4
        make new document
    end repeat
    set bounds of window 1 to {0, ytop, w / 2, yhalf}
    set bounds of window 2 to {w / 2, ytop, w, yhalf}
    set bounds of window 3 to {0, yhalf, w / 2, h}
    set bounds of window 4 to {w / 2, yhalf, w, h}
end tell

Lri

Posted 2014-04-18T03:39:45.877

Reputation: 34 501

oh my God.. you are good – abbood – 2014-04-19T04:27:20.833

it worked perfectly with the textedit app.. however with a couple of other apps including sequel pro and google chrome and the script tiles all of the four windows on the top left corner.. i just changed the application name in the command nothing else.. any idea what that's happening? – abbood – 2014-04-19T04:35:27.677

after some playing around.. i realized that your script (the slate one) works on apps that have a no spaces in them (ie TextEdit or SourceTree).. however apps like 'Google Chrome' or 'Pro Sequel' assume that you're applying the command only to the first argument.. any idea how to address that? – abbood – 2014-04-19T04:48:14.113