-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.slate.js
More file actions
229 lines (181 loc) · 5.26 KB
/
Copy path.slate.js
File metadata and controls
229 lines (181 loc) · 5.26 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
// Configs
S.cfga({
"defaultToCurrentScreen" : true,
"secondsBetweenRepeat" : 0.1,
"checkDefaultsOnLoad" : true,
"focusCheckWidthMax" : 3000,
"orderScreensLeftToRight" : true,
"nudgePercentOf": "screenSize",
"resizePercentOf": "screenSize",
"orderScreensLeftToRight": true
});
// Definitions
var key_binds = {};
var ctrlshift = 'ctrl,shift';
var hyper = 'ctrl,cmd,alt';
var shyper = 'shift,ctrl,alt,cmd';
var leftScreenRef = "0";
var rightScreenRef = "1";
// Function definitions and such
// =============================
var focus = function (app_name) {
return S.op('focus', {'app' : app_name});
};
var focus_dir = function (direction) {
return slate.operation('focus', {'direction' : direction});
};
var chain = function(actions) {
return slate.operation('chain', {'operations' : actions});
};
var fullscreen = slate.operation('corner', {
'direction' : 'top-left',
'width' : 'screenSizeX',
'height' : 'screenSizeY'
});
var push_half = function(direction) {
var w = 'screenSizeX/2';
return slate.operation('push', {
'direction' : direction,
'style' : 'bar-resize:'+w
});
};
var push_third = function(direction) {
var w = 'screenSizeX/3';
return slate.operation('push', {
'direction' : direction,
'style' : 'bar-resize:'+w
});
};
var push_two_third = function(direction) {
var w = 'screenSizeX*2/3';
return slate.operation('push', {
'direction' : direction,
'style' : 'bar-resize:'+w
});
};
var push_quarter = function(direction) {
var w = 'screenSizeX/4';
return slate.operation('push', {
'direction' : direction,
'style' : 'bar-resize:'+w
});
};
var resize = function(width, height, anchor) {
if (typeof anchor === 'undefined') anchor = 'top-left';
return S.op('resize', {
'width' : width,
'height' : height,
'anchor' : anchor
});
};
var left_screen_right = slate.operation(
"move",
{
// "screen" : leftScreenRef,
"x" : "screenOriginX+(screenSizeX*2/3)",
"y" : "screenOriginY",
"width" : "screenSizeX/3",
"height" : "screenSizeY"
}
);
var left_screen_left = slate.operation(
"move",
{
// "screen" : leftScreenRef,
"x" : "screenOriginX",
"y" : "screenOriginY",
"width" : "screenSizeX/3",
"height" : "screenSizeY"
}
);
// var real_half_push = function(direction) {
// var w = 'screenSizeX*1/2';
// if (direction === 'left') {
// w = 'screenSizeX*1/2';
// };
// return slate.operation('push', {
// 'direction' : direction,
// 'style' : 'bar-resize:'+w
// });
// };
// var real_third_push = function(direction) {
// var w = 'screenSizeX*1/3';
// if (direction === 'left') {
// w = 'screenSizeX*1/3';
// };
// return slate.operation('push', {
// 'direction' : direction,
// 'style' : 'bar-resize:'+w
// });
// };
// var real_two_third_push = function(direction) {
// var w = 'screenSizeX*2/3';
// if (direction === 'left') {
// w = 'screenSizeX*2/3';
// };
// return slate.operation('push', {
// 'direction' : direction,
// 'style' : 'bar-resize:'+w
// });
// };
// var half_top = function(direction) {
// return slate.operation('corner', {
// 'direction' : 'top-'+direction,
// 'width' : 'screenSizeX/2',
// 'height' : 'screenSizeY/2'
// });
// };
// var half_bottom = function(direction) {
// return slate.operation('corner', {
// 'direction' : 'bottom-'+direction,
// 'width' : 'screenSizeX/2',
// 'height' : 'screenSizeY/2'
// });
// };
// var quarter_push = function(updown, leftright) {
// var width = 'screenSizeX*3/5';
// var height = 'screenSizeY/2';
// var originX = 'screenOriginX';
// var originY = 'screenOriginY';
// if (leftright === 'right') {
// width = 'screenSizeX*2/5';
// originX = 'screenOriginX+screenSizeX*3/5';
// };
// if (updown === 'bottom') {
// originY = 'screenOriginY+screenSizeY/2';
// };
// return slate.operation('move', {
// 'x' : originX,
// 'y' : originY,
// 'width' : width,
// 'height' : height
// });
// };
var chain_half = function(direction){
return chain([
push_half(direction),
push_third(direction),
push_two_third(direction)
])
};
// Binding definitions
// ===================
// Push bindings
// key_binds["right:ctrl;shift"] = S.op("push", { "direction" : "right", "style" : "bar-resize:screenSizeX/2" });
// key_binds["left:ctrl;shift"] = S.op("push", { "direction" : "left", "style" : "bar-resize:screenSizeX/2" });
// key_binds["up:ctrl;shift"] = S.op("push", { "direction" : "up", "style" : "bar-resize:screenSizeY/2" });
// key_binds["down:ctrl;shift"] = S.op("push", { "direction" : "down", "style" : "bar-resize:screenSizeY/2" });
key_binds['f:'+hyper] = fullscreen;
key_binds['h:'+shyper] = chain_half('left');
key_binds['l:'+shyper] = chain_half('right');
// Focus
key_binds['b:'+hyper] = focus('Google Chrome');
key_binds['t:'+hyper] = focus('Terminal');
key_binds['x:'+hyper] = focus('Workplace Chat');
key_binds['a:'+hyper] = focus('Finder');
key_binds['m:'+hyper] = focus('Microsoft Outlook');
key_binds['h:'+ctrlshift] = focus_dir('left');
key_binds['l:'+ctrlshift] = focus_dir('right');
key_binds['j:'+ctrlshift] = focus_dir('down');
key_binds['k:'+ctrlshift] = focus_dir('up');
S.bindAll(key_binds);