| // Configs | |
| S.cfga({ | |
| "defaultToCurrentScreen" : true, | |
| "secondsBetweenRepeat" : 0.1, | |
| "checkDefaultsOnLoad" : true, | |
| "focusCheckWidthMax" : 3000, | |
| "orderScreensLeftToRight" : true | |
| }); | |
| // Monitors | |
| var monTbolt = "2560x1600"; | |
| var monLaptop = "1920x1200"; | |
| // Operations | |
| var lapFull = S.op("move", { | |
| "screen" : monLaptop, | |
| "x" : "screenOriginX", | |
| "y" : "screenOriginY", | |
| "width" : "screenSizeX", | |
| "height" : "screenSizeY" | |
| }); | |
| var lapChat = S.op("corner", { | |
| "screen" : monLaptop, | |
| "direction" : "top-left", | |
| "width" : "screenSizeX/9", | |
| "height" : "screenSizeY" | |
| }); | |
| var lapMain = lapChat.dup({ "direction" : "top-right", "width" : "8*screenSizeX/9" }); | |
| var tboltFull = S.op("move", { | |
| "screen" : monTbolt, | |
| "x" : "screenOriginX", | |
| "y" : "screenOriginY", | |
| "width" : "screenSizeX", | |
| "height" : "screenSizeY" | |
| }); | |
| var tboltBig = S.op("move", { | |
| "screen" : monTbolt, | |
| "x" : "screenOriginX+screenSizeX/3", | |
| "y" : "screenOriginY", | |
| "width" : "screenSizeX*2/3", | |
| "height" : "screenSizeY", | |
| }); | |
| var tboltLeft = tboltFull.dup({ "width" : "screenSizeX/3" }); | |
| var tboltMid = tboltLeft.dup({ "x" : "screenOriginX+screenSizeX/3" }); | |
| var tboltRight = tboltLeft.dup({ "x" : "screenOriginX+(screenSizeX*2/3)" }); | |
| var tboltLeftTop = tboltLeft.dup({ "height" : "screenSizeY/2" }); | |
| var tboltLeftBot = tboltLeftTop.dup({ "y" : "screenOriginY+screenSizeY/2" }); | |
| var tboltMidTop = tboltMid.dup({ "height" : "screenSizeY/2" }); | |
| var tboltMidBot = tboltMidTop.dup({ "y" : "screenOriginY+screenSizeY/2" }); | |
| var tboltRightTop = tboltRight.dup({ "height" : "screenSizeY/2" }); | |
| var tboltRightBot = tboltRightTop.dup({ "y" : "screenOriginY+screenSizeY/2" }); | |
| // common layout hashes | |
| var lapMainHash = { | |
| "operations" : [lapMain], | |
| "ignore-fail" : true, | |
| "repeat" : true | |
| }; | |
| var lapFullHash = { | |
| "operations" : [lapFull], | |
| "ignore-fail" : true, | |
| "repeat" : true | |
| }; | |
| var adiumHash = { | |
| "operations" : [lapChat, lapMain], | |
| "ignore-fail" : true, | |
| "title-order" : ["Contacts"], | |
| "repeat-last" : true | |
| }; | |
| var mvimHash = { | |
| "operations" : [tboltMid, tboltRightTop], | |
| "repeat" : true | |
| }; | |
| var tboltBigHash = { | |
| "operations" : [tboltBig], | |
| "sort-title" : true, | |
| "repeat" : true | |
| }; | |
| var tboltFullHash = { | |
| "operations" : [tboltFull], | |
| "sort-title" : true, | |
| "repeat" : true | |
| }; | |
| var genBrowserHash = function(regex) { | |
| return { | |
| "operations" : [function(windowObject) { | |
| var title = windowObject.title(); | |
| if (title !== undefined && title.match(regex)) { | |
| windowObject.doOperation(tboltLeftBot); | |
| } else { | |
| windowObject.doOperation(lapFull); | |
| } | |
| }], | |
| "ignore-fail" : true, | |
| "repeat" : true | |
| }; | |
| } | |
| // 3 monitor layout | |
| var twoMonitorLayout = S.lay("twoMonitor", { | |
| "Adium" : { | |
| "operations" : [lapChat, lapMain], | |
| "ignore-fail" : true, | |
| "title-order" : ["Contacts"], | |
| "repeat-last" : true | |
| }, | |
| "MacVim" : mvimHash, | |
| "iTerm" : tboltFullHash, | |
| "Xcode" : tboltBigHash, | |
| "Google Chrome" : genBrowserHash(/^Developer\sTools\s-\s.+$/), | |
| "GitX" : { | |
| "operations" : [lapFull], | |
| "repeat" : true | |
| }, | |
| "Firefox" : genBrowserHash(/^Firebug\s-\s.+$/), | |
| "Safari" : lapFullHash, | |
| "Spotify" : { | |
| "operations" : [lapFull], | |
| "repeat" : true | |
| }, | |
| "TextEdit" : { | |
| "operations" : [lapFull], | |
| "repeat" : true | |
| } | |
| }); | |
| // 1 monitor layout | |
| var oneMonitorLayout = S.lay("oneMonitor", { | |
| "Adium" : adiumHash, | |
| "MacVim" : lapFullHash, | |
| "iTerm" : lapFullHash, | |
| "Google Chrome" : lapFullHash, | |
| "Xcode" : lapFullHash, | |
| "Flex Builder" : lapFullHash, | |
| "GitX" : lapFullHash, | |
| "Ooyala Player Debug Console" : lapFullHash, | |
| "Firefox" : lapFullHash, | |
| "Safari" : lapFullHash, | |
| "Eclipse" : lapFullHash, | |
| "Spotify" : lapFullHash | |
| }); | |
| // Defaults | |
| S.def(2, twoMonitorLayout); | |
| S.def(1, oneMonitorLayout); | |
| // Layout Operations | |
| var twoMonitor = S.op("layout", { "name" : twoMonitorLayout }); | |
| var oneMonitor = S.op("layout", { "name" : oneMonitorLayout }); | |
| var universalLayout = function() { | |
| // Should probably make sure the resolutions match but w/e | |
| S.log("SCREEN COUNT: "+S.screenCount()); | |
| if (S.screenCount() === 2) { | |
| twoMonitor.run(); | |
| } else if (S.screenCount() === 1) { | |
| oneMonitor.run(); | |
| } | |
| }; | |
| // Batch bind everything. Less typing. | |
| S.bnda({ | |
| // Layout Bindings | |
| "padEnter:ctrl" : universalLayout, | |
| "space:ctrl" : universalLayout, | |
| // Basic Location Bindings | |
| "pad0:ctrl" : lapChat, | |
| "[:ctrl" : lapChat, | |
| "pad.:ctrl" : lapMain, | |
| "]:ctrl" : lapMain, | |
| "pad1:ctrl" : tboltLeftBot, | |
| "pad2:ctrl" : tboltMidBot, | |
| "pad3:ctrl" : tboltRightBot, | |
| "pad4:ctrl" : tboltLeftTop, | |
| "pad5:ctrl" : tboltMidTop, | |
| "pad6:ctrl" : tboltRightTop, | |
| "pad7:ctrl" : tboltLeft, | |
| "pad8:ctrl" : tboltMid, | |
| "pad9:ctrl" : tboltRight, | |
| "pad=:ctrl" : tboltFull, | |
| // Resize Bindings | |
| // NOTE: some of these may *not* work if you have not removed the expose/spaces/mission control bindings | |
| "right:ctrl" : S.op("resize", { "width" : "+10%", "height" : "+0" }), | |
| "left:ctrl" : S.op("resize", { "width" : "-10%", "height" : "+0" }), | |
| "up:ctrl" : S.op("resize", { "width" : "+0", "height" : "-10%" }), | |
| "down:ctrl" : S.op("resize", { "width" : "+0", "height" : "+10%" }), | |
| "right:alt" : S.op("resize", { "width" : "-10%", "height" : "+0", "anchor" : "bottom-right" }), | |
| "left:alt" : S.op("resize", { "width" : "+10%", "height" : "+0", "anchor" : "bottom-right" }), | |
| "up:alt" : S.op("resize", { "width" : "+0", "height" : "+10%", "anchor" : "bottom-right" }), | |
| "down:alt" : S.op("resize", { "width" : "+0", "height" : "-10%", "anchor" : "bottom-right" }), | |
| // Push Bindings | |
| // NOTE: some of these may *not* work if you have not removed the expose/spaces/mission control bindings | |
| "right:ctrl;shift" : S.op("push", { "direction" : "right", "style" : "bar-resize:screenSizeX/2" }), | |
| "left:ctrl;shift" : S.op("push", { "direction" : "left", "style" : "bar-resize:screenSizeX/2" }), | |
| "up:ctrl;shift" : S.op("push", { "direction" : "up", "style" : "bar-resize:screenSizeY/2" }), | |
| "down:ctrl;shift" : S.op("push", { "direction" : "down", "style" : "bar-resize:screenSizeY/2" }), | |
| // Nudge Bindings | |
| // NOTE: some of these may *not* work if you have not removed the expose/spaces/mission control bindings | |
| "right:ctrl;alt" : S.op("nudge", { "x" : "+10%", "y" : "+0" }), | |
| "left:ctrl;alt" : S.op("nudge", { "x" : "-10%", "y" : "+0" }), | |
| "up:ctrl;alt" : S.op("nudge", { "x" : "+0", "y" : "-10%" }), | |
| "down:ctrl;alt" : S.op("nudge", { "x" : "+0", "y" : "+10%" }), | |
| // Throw Bindings | |
| // NOTE: some of these may *not* work if you have not removed the expose/spaces/mission control bindings | |
| "pad1:ctrl;alt" : S.op("throw", { "screen" : "2", "width" : "screenSizeX", "height" : "screenSizeY" }), | |
| "pad2:ctrl;alt" : S.op("throw", { "screen" : "1", "width" : "screenSizeX", "height" : "screenSizeY" }), | |
| "pad3:ctrl;alt" : S.op("throw", { "screen" : "0", "width" : "screenSizeX", "height" : "screenSizeY" }), | |
| "right:ctrl;alt;cmd" : S.op("throw", { "screen" : "right", "width" : "screenSizeX", "height" : "screenSizeY" }), | |
| "left:ctrl;alt;cmd" : S.op("throw", { "screen" : "left", "width" : "screenSizeX", "height" : "screenSizeY" }), | |
| "up:ctrl;alt;cmd" : S.op("throw", { "screen" : "up", "width" : "screenSizeX", "height" : "screenSizeY" }), | |
| "down:ctrl;alt;cmd" : S.op("throw", { "screen" : "down", "width" : "screenSizeX", "height" : "screenSizeY" }), | |
| // Focus Bindings | |
| // NOTE: some of these may *not* work if you have not removed the expose/spaces/mission control bindings | |
| "l:cmd" : S.op("focus", { "direction" : "right" }), | |
| "h:cmd" : S.op("focus", { "direction" : "left" }), | |
| "k:cmd" : S.op("focus", { "direction" : "up" }), | |
| "j:cmd" : S.op("focus", { "direction" : "down" }), | |
| "k:cmd;alt" : S.op("focus", { "direction" : "behind" }), | |
| "j:cmd;alt" : S.op("focus", { "direction" : "behind" }), | |
| "right:cmd" : S.op("focus", { "direction" : "right" }), | |
| "left:cmd" : S.op("focus", { "direction" : "left" }), | |
| "up:cmd" : S.op("focus", { "direction" : "up" }), | |
| "down:cmd" : S.op("focus", { "direction" : "down" }), | |
| "up:cmd;alt" : S.op("focus", { "direction" : "behind" }), | |
| "down:cmd;alt" : S.op("focus", { "direction" : "behind" }), | |
| // Window Hints | |
| "esc:cmd" : S.op("hint"), | |
| // Switch currently doesn't work well so I'm commenting it out until I fix it. | |
| //"tab:cmd" : S.op("switch"), | |
| // Grid | |
| "esc:ctrl" : S.op("grid") | |
| }); | |
| // Test Cases | |
| S.src(".slate.test", true); | |
| S.src(".slate.test.js", true); | |
| // Log that we're done configuring | |
| S.log("[SLATE] -------------- Finished Loading Config --------------"); |