Last active
August 28, 2017 15:40
-
-
Save pik4ez/5cb9b9a2376d7f65ab8417e9517efe60 to your computer and use it in GitHub Desktop.
Slate.js window manager configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Functions | |
// String.startsWith | |
if (typeof String.prototype.startsWith != 'function') { | |
String.prototype.startsWith = function (str){ | |
return this.slice(0, str.length) == str; | |
}; | |
} | |
// Config | |
S.config("checkDefaultsOnLoad", true); | |
// Layouts | |
var monRight = "1440x2560"; | |
var monLeft = "2560x1440"; | |
var monLaptop = "1"; | |
var posMonLaptop = S.op("corner", { | |
"screen": monLaptop, | |
"direction": "top-left", | |
"width": "screenSizeX", | |
"height": "screenSizeY" | |
}); | |
var posMonLeftTwoFifth = S.op("corner", { | |
"screen": monLeft, | |
"direction": "top-left", | |
"width": "screenSizeX*2/5", | |
"height": "screenSizeY" | |
}); | |
var posMonLeftThreeFifth = S.op("corner", { | |
"screen": monLeft, | |
"direction": "top-right", | |
"width": "screenSizeX*3/5", | |
"height": "screenSizeY" | |
}); | |
var posMonRightFull = S.op("corner", { | |
"screen": monRight, | |
"direction": "top-left", | |
"width": "screenSizeX", | |
"height": "screenSizeY" | |
}); | |
var layoutWork = S.lay("work", { | |
"Google Chrome": { | |
"operations": [posMonLeftTwoFifth, posMonLaptop] | |
}, | |
"iTerm2": { | |
"operations": [posMonLeftThreeFifth, posMonRightFull], | |
"title-order-regex": ["^[^2]\..+$"], | |
"repeat-last": true, | |
} | |
}); | |
var layoutStock = S.lay("stock", { | |
"Google Chrome": { | |
"operations": [posMonLaptop] | |
}, | |
"iTerm2": { | |
"operations": [posMonLaptop] | |
} | |
}); | |
S.def(3, layoutWork); | |
S.def(1, layoutStock); | |
// Bindings | |
var focusItermConsole = function(win) { | |
S.eachApp(function(appObj) { | |
if (appObj.name() === "iTerm2") { | |
appObj.eachWindow(function(winObj) { | |
if (winObj.title().startsWith("1. ")) { | |
winObj.focus(); | |
return; | |
} | |
}); | |
} | |
}); | |
}; | |
var focusItermVim = function(win) { | |
S.eachApp(function(appObj) { | |
if (appObj.name() === "iTerm2") { | |
appObj.eachWindow(function(winObj) { | |
if (winObj.title().startsWith("2. ")) { | |
winObj.focus(); | |
return; | |
} | |
}); | |
} | |
}); | |
}; | |
var moveRightFullscreen = function(win) { | |
var op = S.op("throw", { | |
"x": "screenOriginX", | |
"y": "screenOriginY", | |
"width": "screenSizeX", | |
"height": "screenSizeY", | |
"screen": monRight | |
}); | |
win.doOperation(op); | |
}; | |
var moveLeftLeft = function(win) { | |
var op = S.op("throw", { | |
"x": "screenOriginX", | |
"y": "screenOriginY", | |
"width": "screenSizeX*2/5", | |
"height": "screenSizeY", | |
"screen": monLeft | |
}); | |
win.doOperation(op); | |
}; | |
var moveLeftRight = function(win) { | |
var op = S.op("throw", { | |
"x": "screenOriginX + screenSizeX*2/5", | |
"y": "screenOriginY", | |
"width": "screenSizeX*3/5", | |
"height": "screenSizeY", | |
"screen": monLeft | |
}); | |
win.doOperation(op); | |
}; | |
var moveLaptopFullscreen = function(win) { | |
var op = S.op("throw", { | |
"x": "screenOriginX", | |
"y": "screenOriginY", | |
"width": "screenSizeX", | |
"height": "screenSizeY", | |
"screen": monLaptop | |
}); | |
win.doOperation(op); | |
}; | |
S.bnda({ | |
"r:cmd,shift": S.op("relaunch"), | |
"i:cmd": focusItermConsole, | |
"o:cmd": focusItermVim, | |
"m:cmd": S.op("focus", {"app": "Google Chrome"}), | |
"u:cmd": S.op("focus", {"app": "Firefox"}), | |
"p:cmd": S.op("focus", {"app": "Slack"}), | |
"[:cmd": S.op("focus", {"app": "Telegram"}), | |
"]:cmd": S.op("focus", {"app": "ChitChat"}), | |
"b:cmd": S.op("focus", {"app": "Airmail"}), | |
"up:cmd,ctrl,alt": moveLeftLeft, | |
"left:cmd,ctrl,alt": moveLeftRight, | |
"right:cmd,ctrl,alt": moveRightFullscreen, | |
"down:cmd,ctrl,alt": moveLaptopFullscreen | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment