Skip to content

Instantly share code, notes, and snippets.

@mismith
Created December 10, 2015 06:59
Show Gist options
  • Save mismith/63987d1d78122395f844 to your computer and use it in GitHub Desktop.
Save mismith/63987d1d78122395f844 to your computer and use it in GitHub Desktop.
'use strict';
var keys = [],
triple = ['ctrl', 'alt', 'cmd'];
// left half
keys.push(Phoenix.bind('left', triple, function () {
var window = Window.focusedWindow(),
screen = window.screen().visibleFrameInRectangle();
window.setFrame({
x: screen.x,
y: screen.y,
width: screen.width * .5,
height: screen.height,
});
}));
// right half
keys.push(Phoenix.bind('right', triple, function () {
var window = Window.focusedWindow(),
screen = window.screen().visibleFrameInRectangle();
window.setFrame({
x: screen.x + screen.width * .5,
y: screen.y,
width: screen.width * .5,
height: screen.height,
});
}));
// left two third
keys.push(Phoenix.bind('up', triple, function () {
var window = Window.focusedWindow(),
screen = window.screen().visibleFrameInRectangle();
window.setFrame({
x: screen.x,
y: screen.y,
width: screen.width * .65,
height: screen.height,
});
}));
// right third
keys.push(Phoenix.bind('down', triple, function () {
var window = Window.focusedWindow(),
screen = window.screen().visibleFrameInRectangle();
window.setFrame({
x: screen.x + screen.width * .65,
y: screen.y,
width: screen.width * .35,
height: screen.height,
});
}));
// fill screen
keys.push(Phoenix.bind('space', triple, function () {
var window = Window.focusedWindow(),
screen = window.screen().visibleFrameInRectangle();
window.setFrame(screen);
}));
// move to next screen
keys.push(Phoenix.bind('pageUp', triple, function () {
var window = Window.focusedWindow(),
oldWindow = window.frame(),
oldScreen = window.screen().visibleFrameInRectangle(),
screen = window.screen().previous().visibleFrameInRectangle();
window.setFrame({
x: screen.x + ((oldWindow.x - oldScreen.x) / oldScreen.width) * screen.width,
y: screen.y + ((oldWindow.y - oldScreen.y) / oldScreen.height) * screen.height,
width: screen.width * (oldWindow.width / oldScreen.width),
height: window.height * (oldWindow.height / oldScreen.height),
});
}));
// move to previous screen
keys.push(Phoenix.bind('pageDown', triple, function () {
var window = Window.focusedWindow(),
oldWindow = window.frame(),
oldScreen = window.screen().visibleFrameInRectangle(),
screen = window.screen().next().visibleFrameInRectangle();
window.setFrame({
x: screen.x + ((oldWindow.x - oldScreen.x) / oldScreen.width) * screen.width,
y: screen.y + ((oldWindow.y - oldScreen.y) / oldScreen.height) * screen.height,
width: screen.width * (oldWindow.width / oldScreen.width),
height: window.height * (oldWindow.height / oldScreen.height),
});
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment