-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.conductor.js
102 lines (83 loc) · 2.83 KB
/
.conductor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var modifiers = ["ctrl", "cmd"];
var padding = 2;
function windowToGrid(win, x, y, width, height) {
var screen = win.screen().frameIncludingDockAndMenu();
win.setFrame({
x: Math.round(x * screen.width) + padding + screen.x,
y: Math.round(y * screen.height) + padding + screen.y,
width: Math.round(width * screen.width) - (2 * padding),
height: Math.round(height * screen.height) - (2 * padding)
});
}
function toGrid(x, y, width, height) {
windowToGrid(Window.focusedWindow(), x, y, width, height);
}
Window.fullScreen = function() {
toGrid(0, 0, 1, 1);
}
Window.leftHalf = function() {
toGrid(0, 0, 0.5, 1);
}
Window.rightHalf = function() {
toGrid(0.5, 0, 0.5, 1);
}
Window.topLeft = function() {
toGrid(0, 0, 0.5, 0.5);
}
Window.bottomLeft = function() {
toGrid(0, 0.5, 0.5, 0.5);
}
Window.topRight = function() {
toGrid(0.5, 0, 0.5, 0.5);
}
Window.bottomRight = function() {
toGrid(0.5, 0.5, 0.5, 0.5);
}
function center() {
var win = Window.focusedWindow();
var sframe = win.screen().frameWithoutDockOrMenu();
var frame = win.frame();
frame.x = sframe.x + ((sframe.width / 2) - (frame.width / 2));
frame.y = sframe.y + ((sframe.height / 2) - (frame.height / 2));
win.setFrame(frame);
}
function left() {
var win = Window.focusedWindow();
var frame = win.frame();
frame.x = 0;
win.setFrame(frame);
}
function right() {
var win = Window.focusedWindow();
var sframe = win.screen().frameWithoutDockOrMenu();
var frame = win.frame();
frame.x = sframe.width - frame.width;
win.setFrame(frame);
}
function push() {
var win = Window.focusedWindow();
var frame = win.frame();
var nextScreen = win.screen().nextScreen();
var screenFrame = nextScreen.frameWithoutDockOrMenu();
win.setFrame({
x: screenFrame.x,
y: screenFrame.y,
width: frame.width,
height: frame.height
});
}
api.bind('u', modifiers, function() { center() });
api.bind('i', modifiers, function() { left() });
api.bind('o', modifiers, function() { right() });
api.bind('p', modifiers, function() { push() });
api.bind('k', modifiers, function() { Window.fullScreen() });
api.bind('h', modifiers, function() { Window.leftHalf() });
api.bind('l', modifiers, function() { Window.rightHalf() });
api.bind('n', modifiers, function() { Window.topLeft() });
api.bind('m', modifiers, function() { Window.bottomLeft() });
api.bind(',', modifiers, function() { Window.topRight() });
api.bind('.', modifiers, function() { Window.bottomRight() });
api.bind('y', ["shift", "cmd"], function () { api.launch("iTerm"); });
api.bind('RETURN', ["shift", "cmd"], function () { api.launch("Messages"); })
api.bind('t', ["shift", "cmd"], function () { api.launch("Tweetbot"); });
api.bind('u', ["shift", "cmd"], function () { api.launch("Slack"); });