Skip to content

Instantly share code, notes, and snippets.

@frantic
Last active October 23, 2015 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frantic/3492036e9be49a63ac0f to your computer and use it in GitHub Desktop.
Save frantic/3492036e9be49a63ac0f to your computer and use it in GitHub Desktop.
My Pheonix 2.0 config file
var mod = ['ctrl', 'cmd', 'alt'];
var handlers = [];
function moveWindow(window, shiftX, width, shiftY, height) {
var screen = Screen.mainScreen().visibleFrameInRectangle();
var newFrame = {
x: screen.x + screen.width * shiftX,
y: screen.y + screen.height * shiftY,
width: screen.width * width,
height: screen.height * height,
}
window.setFrame(newFrame);
}
function moveFocusedWindow(shiftX, width, shiftY, height) {
moveWindow(Window.focusedWindow(), shiftX, width, shiftY, height);
}
function moveAppWindows(appName, shiftX, width, shiftY, height) {
App.runningApps().forEach(function(app) {
if (app.name() === appName) {
moveWindow(app.mainWindow(), shiftX, width, shiftY, height);
}
});
}
function focusApp(name) {
App.runningApps().forEach(function(app) {
if (app.name() === name) {
app.activate();
app.focus();
}
});
}
handlers.push(Phoenix.bind('left', mod, function () {
moveFocusedWindow(0, 0.5, 0, 1);
}));
handlers.push(Phoenix.bind('right', mod, function () {
moveFocusedWindow(0.5, 0.5, 0, 1);
}));
handlers.push(Phoenix.bind('up', mod, function () {
moveFocusedWindow(0, 1, 0, 0.5);
}));
handlers.push(Phoenix.bind('down', mod, function () {
moveFocusedWindow(0, 1, 0.5, 0.5);
}));
handlers.push(Phoenix.bind('1', mod, function () {
moveFocusedWindow(0, 0.5, 0, 0.5);
}));
handlers.push(Phoenix.bind('2', mod, function () {
moveFocusedWindow(0.5, 0.5, 0, 0.5);
}));
handlers.push(Phoenix.bind('3', mod, function () {
moveFocusedWindow(0, 0.5, 0.5, 0.5);
}));
handlers.push(Phoenix.bind('4', mod, function () {
moveFocusedWindow(0.5, 0.5, 0.5, 0.5);
}));
handlers.push(Phoenix.bind('m', mod, function () {
moveFocusedWindow(0.2, 0.6, 0.2, 0.6);
}));
handlers.push(Phoenix.bind('c', mod, function () {
var screen = Screen.mainScreen().visibleFrameInRectangle();
var window = Window.focusedWindow().frame();
Window.focusedWindow().setFrame({
x: screen.x + (screen.width - window.width) / 2,
y: screen.y + (screen.height - window.height) / 2,
width: window.width,
height: window.height,
});
}));
handlers.push(Phoenix.bind('l', mod, function () {
moveAppWindows('Sublime Text', 0, 0.5, 0, 1);
moveAppWindows('iTerm2', 0.5, 0.5, 0.5, 0.5);
moveAppWindows('Google Chrome', 0, 0.5, 0, 1);
}));
handlers.push(Phoenix.bind('f', mod, function () {
var screen = Screen.mainScreen().visibleFrameInRectangle();
Window.focusedWindow().setFrame(screen);
}));
handlers.push(Phoenix.bind('s', mod, function () {
focusApp('Sublime Text');
}));
handlers.push(Phoenix.bind('t', mod, function () {
focusApp('iTerm2');
}));
handlers.push(Phoenix.bind('w', mod, function () {
focusApp('Google Chrome');
}));
// var h2 = Phoenix.on('appDidLaunch', function(app) {
// Phoenix.notify('whoa! ' + app.name());
// });
function showModal(text) {
var screen = Screen.mainScreen().visibleFrameInRectangle();
var modal = new Modal();
modal.message = text;
var frame = modal.frame();
modal.duration = 0.5;
modal.origin = {
x: screen.x + (screen.width - frame.width) / 2,
y: screen.y + (screen.height - frame.height) / 2,
};
modal.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment