Skip to content

Instantly share code, notes, and snippets.

@GabrielMMelo
Last active September 11, 2021 03:38
Show Gist options
  • Save GabrielMMelo/a0ddb75bc0b5bf1e7792ca00728096a4 to your computer and use it in GitHub Desktop.
Save GabrielMMelo/a0ddb75bc0b5bf1e7792ca00728096a4 to your computer and use it in GitHub Desktop.
Phoenix MacOSX window management config file (aka ~/.phoenix)
Phoenix.set({
daemon: true,
openAtLogin: true
});
/* full screen */
Key.on('f', [ 'ctrl', 'shift' ], function () {
var screen = Screen.main().flippedVisibleFrame();
var window = Window.focused();
if (window) {
window.maximise()
}
});
/* half left */
Key.on('h', [ 'ctrl', 'shift' ], function () {
var screen = Screen.main().flippedVisibleFrame();
var window = Window.focused();
if (window) {
window.setTopLeft({
x: screen.x,
y: screen.y,
});
size = window.size();
size.width = screen.width / 2;
size.height = screen.height
window.setSize(size);
}
});
/* half right */
Key.on('l', [ 'ctrl', 'shift' ], function () {
var screen = Screen.main().flippedVisibleFrame();
var window = Window.focused();
if (window) {
window.setTopLeft({
x: screen.x + (screen.width / 2),
y: screen.y
});
size = window.size();
size.width = screen.width / 2;
size.height = screen.height
window.setSize(size);
}
});
/* half down */
Key.on('j', [ 'ctrl', 'shift' ], function () {
var screen = Screen.main().flippedVisibleFrame();
var window = Window.focused();
if (window) {
window.setTopLeft({
x: screen.x,
y: screen.y + (screen.height / 2)
});
size = window.size();
size.width = screen.width;
size.height = screen.height / 2;
window.setSize(size);
}
});
/* half up */
Key.on('k', [ 'ctrl', 'shift' ], function () {
var screen = Screen.main().flippedVisibleFrame();
var window = Window.focused();
if (window) {
window.setTopLeft({
x: screen.x,
y: screen.y
});
size = window.size();
size.width = screen.width;
size.heigth = screen.height / 2;
window.setSize(size);
}
});
/* focus left */
Key.on('h', [ 'ctrl', 'cmd' ], function () {
var screen = Screen.main().flippedVisibleFrame();
var window = Window.focused();
var neighbour = window.focusClosestNeighbour('west')
neighbour.focus()
});
/* focus right */
Key.on('l', [ 'ctrl', 'cmd' ], function () {
var screen = Screen.main().flippedVisibleFrame();
var window = Window.focused();
if (window) {
var neighbour = window.focusClosestNeighbour('east')
neighbour.focus()
}
});
/* focus left */
Key.on('k', [ 'ctrl', 'cmd' ], function () {
var screen = Screen.main().flippedVisibleFrame();
var window = Window.focused();
var neighbour = window.focusClosestNeighbour('north')
neighbour.focus()
});
/* focus right */
Key.on('j', [ 'ctrl', 'cmd' ], function () {
var screen = Screen.main().flippedVisibleFrame();
var window = Window.focused();
if (window) {
var neighbour = window.focusClosestNeighbour('south')
neighbour.focus()
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment