Skip to content

Instantly share code, notes, and snippets.

@gfreezy
Last active November 18, 2021 16:13
Show Gist options
  • Save gfreezy/6060661 to your computer and use it in GitHub Desktop.
Save gfreezy/6060661 to your computer and use it in GitHub Desktop.
slate configuration
var pushRight = slate.operation("push", {
"direction": "right",
"style": "bar-resize:screenSizeX/2"
});
var pushLeft = slate.operation("push", {
"direction": "left",
"style": "bar-resize:screenSizeX/2"
});
var throwNextLeft = slate.operation("throw", {
"width": "screenSizeX/2",
"height": "screenSizeY",
"screen": "next"
});
var throwNextRight = slate.operation("throw", {
"x": "screenOriginX+(screenSizeX)/2",
"y": "screenOriginY",
"width": "screenSizeX/2",
"height": "screenSizeY",
"screen": "next"
});
var fullscreen = slate.operation("move", {
"x" : "screenOriginX",
"y" : "screenOriginY",
"width" : "screenSizeX",
"height" : "screenSizeY"
});
var throwNextFullscreen = slate.operation("throw", {
"x": "screenOriginX",
"y": "screenOriginY",
"width": "screenSizeX",
"height": "screenSizeY",
"screen": "next"
});
var throwNext = function(win) {
if (!win) {
return;
}
var winRect = win.rect();
var screen = win.screen().visibleRect();
var newX = (winRect.x - screen.x)/screen.width+"*screenSizeX+screenOriginX";
var newY = (winRect.y - screen.y)/screen.height+"*screenSizeY+screenOriginY";
var newWidth = winRect.width/screen.width+"*screenSizeX";
var newHeight = winRect.height/screen.height+"*screenSizeY";
var throwNext = slate.operation("throw", {
"x": newX,
"y": newY,
"width": newWidth,
"height": newHeight,
"screen": "next"
});
win.doOperation(throwNext);
};
var pushedLeft = function(win) {
if (!win) {
return false;
}
var winRect = win.rect();
var screen = win.screen().visibleRect();
if (winRect.x === screen.x &&
winRect.y === screen.y &&
winRect.width === screen.width/2 &&
winRect.height === screen.height
) {
return true;
}
return false;
};
var pushedRight = function(win) {
if (!win) {
return false;
}
var winRect = win.rect();
var screen = win.screen().visibleRect();
if (winRect.x === screen.x + screen.width/2 &&
winRect.y === screen.y &&
winRect.width === screen.width/2 &&
winRect.height === screen.height
) {
return true;
}
return false;
};
var isFullscreen = function(win) {
if (!win) {
return false;
}
var winRect = win.rect();
var screen = win.screen().visibleRect();
if (winRect.width === screen.width &&
winRect.height === screen.height
) {
return true;
}
return false;
};
slate.bind("left:ctrl,cmd", function(win) {
if (!win) {
return;
}
if (pushedLeft(win)) {
win.doOperation(throwNextLeft);
} else {
win.doOperation(pushLeft);
}
});
slate.bind("right:ctrl,cmd", function(win) {
if (!win) {
return;
}
if (pushedRight(win)) {
win.doOperation(throwNextRight);
} else {
win.doOperation(pushRight);
}
});
slate.bind("up:ctrl,cmd", function(win) {
if (!win) {
return;
}
if (isFullscreen(win)) {
win.doOperation(throwNextFullscreen);
} else {
win.doOperation(fullscreen);
}
});
slate.bind("down:ctrl,cmd", function(win) {
if (!win) {
return;
}
if (pushedLeft(win)) {
win.doOperation(throwNextLeft);
} else if (pushedRight(win)) {
win.doOperation(throwNextRight);
} else if (isFullscreen(win)) {
win.doOperation(throwNextFullscreen);
} else {
throwNext(win);
}
});
@neohunter
Copy link

This is suppose to move maximized to the other monitor?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment