Skip to content

Instantly share code, notes, and snippets.

@loganakamatsu
Created April 25, 2016 15:50
Show Gist options
  • Save loganakamatsu/baf5bfe675f3949ad8d0dbd9a3ee0763 to your computer and use it in GitHub Desktop.
Save loganakamatsu/baf5bfe675f3949ad8d0dbd9a3ee0763 to your computer and use it in GitHub Desktop.
Slate Javascript Config
var fullscreen = slate.operation("move", {
"x" : "screenOriginX",
"y" : "screenOriginY",
"width" : "screenSizeX",
"height" : "screenSizeY"
});
var pushLeft = slate.operation("push", {
"direction" : "left",
"style" : "bar-resize:screenSizeX/2"
});
var pushRight = slate.operation("push", {
"direction" : "right",
"style" : "bar-resize:screenSizeX/2"
});
var pushUp = slate.operation("push", {
"direction" : "up",
"style" : "bar-resize:screenSizeY/2"
});
var pushDown = slate.operation("push", {
"direction" : "down",
"style" : "bar-resize:screenSizeY/2"
});
var moveUp = function(win) {
var next = win.screen().id() + 1;
if (next >= slate.screenCount()){
next = 0;
}
moveTo(win, next);
}
var moveDown = function(win) {
var next = win.screen().id() - 1;
if (next < 0) {
next = slate.screenCount() - 1;
}
moveTo(win, next);
}
var moveTo = function(win, screen) {
win.doOperation(slate.operation("move", {
"x" : "screenOriginX",
"y" : "screenOriginY",
"width" : "screenSizeX/2",
"height" : "screenSizeY",
"screen" : screen
})
);
}
slate.bind("down:ctrl;cmd", moveDown);
slate.bind("up:ctrl;cmd", moveUp);
slate.bind("m:ctrl;alt;cmd", function(win) {
// here win is a reference to the currently focused window
win.doOperation(fullscreen);
});
slate.bind("right:ctrl;alt;cmd", function(win) {
win.doOperation(pushRight);
});
slate.bind("left:ctrl;alt;cmd", function(win) {
win.doOperation(pushLeft);
});
slate.bind("up:ctrl;alt;cmd", function(win) {
win.doOperation(pushUp);
});
slate.bind("down:ctrl;alt;cmd", function(win) {
win.doOperation(pushDown);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment