Skip to content

Instantly share code, notes, and snippets.

@andyHa
Created June 20, 2018 06: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 andyHa/0f7e3ebab503acd70b4fb16e9496ad61 to your computer and use it in GitHub Desktop.
Save andyHa/0f7e3ebab503acd70b4fb16e9496ad61 to your computer and use it in GitHub Desktop.
// Debug using /usr/bin/log stream --process Phoenix
new Key('right', [ 'ctrl', 'cmd' ], function () {
try {
Phoenix.log("Right")
var wnd = Window.focused();
if (!wnd) {
return;
}
if (!wnd.screen()) {
return;
}
var sortedScreens = Screen.all().sort((a, b) => a.frame().x < b.frame().x)
var index = sortedScreens.indexOf(wnd.screen());
if (index < 1) {
wnd.setFrame(wnd.screen().flippedVisibleFrame());
return;
}
wnd.setFrame(sortedScreens[index - 1].flippedVisibleFrame());
} catch(e) {
Phoenix.log(e);
}
});
new Key('left', [ 'ctrl', 'cmd' ], function () {
try {
Phoenix.log("Left")
var wnd = Window.focused();
if (!wnd) {
return;
}
if (!wnd.screen()) {
return;
}
var sortedScreens = Screen.all().sort((a, b) => a.frame().x < b.frame().x)
var index = sortedScreens.indexOf(wnd.screen());
if (index < 0 || index == sortedScreens.length - 1) {
wnd.setFrame(wnd.screen().flippedVisibleFrame());
return;
}
wnd.setFrame(sortedScreens[index + 1].flippedVisibleFrame());
} catch(e) {
Phoenix.log(e);
}
});
new Key('up', [ 'ctrl', 'cmd' ], function () {
try {
Phoenix.log("Up")
var wnd = Window.focused();
wnd.setFrame(wnd.screen().flippedVisibleFrame());
} catch(e) {
Phoenix.log(e);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment