2018-07-06 19:35:22 +02:00
|
|
|
// Support flag to branch KBDs depending on presence of Ergodox keyboard.
|
2017-05-22 17:22:30 +02:00
|
|
|
|
2018-07-06 19:35:22 +02:00
|
|
|
// Since the Ergodox has complicated modifier keys like "hyper" and "meh" key,
|
|
|
|
// we should prefer to use these when that keyboard is attached because it
|
|
|
|
// reduces the potential for collisions for Emacs KBDs. This becomes
|
|
|
|
// problematic, however, when the Ergodox is not attached because these keys are
|
|
|
|
// unavailable. Slate KBDs. Under these circumstances, potential collisions
|
|
|
|
// with Emacs KBDs is acceptable.
|
2017-05-22 17:22:30 +02:00
|
|
|
|
2018-07-17 00:34:58 +02:00
|
|
|
var ergodox_attached = true;
|
2018-01-08 21:14:01 +01:00
|
|
|
|
2018-07-06 19:35:22 +02:00
|
|
|
var HYPER = ":alt;shift;cmd;ctrl";
|
|
|
|
var MEH = ":alt;shift;ctrl";
|
|
|
|
|
|
|
|
var modal_key = ergodox_attached ? HYPER : ":ctrl;shift";
|
|
|
|
var resize_key = ergodox_attached ? MEH : ":alt;shift";
|
2017-05-22 17:22:30 +02:00
|
|
|
|
|
|
|
// Configs
|
|
|
|
S.cfga({
|
2017-09-15 17:57:01 +02:00
|
|
|
defaultToCurrentScreen: true,
|
|
|
|
secondsBetweenRepeat: 0.1,
|
|
|
|
checkDefaultsOnLoad: true,
|
2018-07-06 19:35:22 +02:00
|
|
|
focusCheckWidthMax: 3000
|
2017-05-22 17:22:30 +02:00
|
|
|
});
|
|
|
|
|
2018-01-08 21:14:01 +01:00
|
|
|
// window resizing bindings
|
|
|
|
var window_resizing_bindings = {
|
2018-07-06 19:35:22 +02:00
|
|
|
";": {
|
|
|
|
x: "screenSizeX/3*2 + screenOriginX+20",
|
|
|
|
y: "screenOriginY+20",
|
|
|
|
width: "screenSizeX/3 - 40",
|
|
|
|
height: "screenSizeY-100"
|
2018-01-08 21:14:01 +01:00
|
|
|
},
|
2018-07-06 19:35:22 +02:00
|
|
|
g: {
|
|
|
|
x: "screenOriginX+20",
|
|
|
|
y: "screenOriginY+20",
|
|
|
|
width: "screenSizeX/3*2 - 40",
|
|
|
|
height: "screenSizeY-100"
|
2018-01-08 21:14:01 +01:00
|
|
|
},
|
2018-07-06 19:35:22 +02:00
|
|
|
o: {
|
|
|
|
x: "screenSizeX / 2 + screenOriginX + 20",
|
|
|
|
y: "screenOriginY + 20",
|
|
|
|
width: "screenSizeX / 2 - 40",
|
|
|
|
height: "(screenSizeY - 120) / 2"
|
2018-01-08 21:14:01 +01:00
|
|
|
},
|
2018-07-06 19:35:22 +02:00
|
|
|
",": {
|
|
|
|
x: "screenSizeX / 2 + screenOriginX + 20",
|
|
|
|
y: "(screenSizeY - 120) / 2 + 20 + 20",
|
|
|
|
width: "screenSizeX / 2 - 40",
|
|
|
|
height: "(screenSizeY - 120) / 2"
|
2018-01-08 21:14:01 +01:00
|
|
|
},
|
2018-07-06 19:35:22 +02:00
|
|
|
h: {
|
|
|
|
x: "screenOriginX+20",
|
|
|
|
y: "screenOriginY+20",
|
|
|
|
width: "screenSizeX*0.5 - 40",
|
|
|
|
height: "screenSizeY-100"
|
2018-01-08 21:14:01 +01:00
|
|
|
},
|
2018-07-06 19:35:22 +02:00
|
|
|
j: {
|
|
|
|
x: "screenOriginX+screenSizeX/6",
|
|
|
|
y: "screenOriginY+20",
|
|
|
|
width: "2*screenSizeX/3",
|
|
|
|
height: "screenSizeY - 100"
|
2018-01-08 21:14:01 +01:00
|
|
|
},
|
2018-07-06 19:35:22 +02:00
|
|
|
k: {
|
|
|
|
x: "screenOriginX+20",
|
|
|
|
y: "screenOriginY+20",
|
|
|
|
width: "screenSizeX - 40",
|
|
|
|
height: "screenSizeY - 100"
|
2018-01-08 21:14:01 +01:00
|
|
|
},
|
2018-07-06 19:35:22 +02:00
|
|
|
l: {
|
|
|
|
x: "screenSizeX/2 + screenOriginX+20",
|
|
|
|
y: "screenOriginY+20",
|
|
|
|
width: "screenSizeX*0.5 - 40",
|
|
|
|
height: "screenSizeY-100"
|
|
|
|
}
|
|
|
|
};
|
2017-05-26 17:24:04 +02:00
|
|
|
|
2018-07-06 19:35:22 +02:00
|
|
|
var window_resizing_bindings = Object.keys(window_resizing_bindings).reduce(
|
|
|
|
function(acc, kbd) {
|
|
|
|
acc[kbd + resize_key] = S.op("move", window_resizing_bindings[kbd]);
|
|
|
|
return acc;
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
);
|
2018-01-08 21:14:01 +01:00
|
|
|
|
|
|
|
S.bnda(window_resizing_bindings);
|
2017-05-22 17:22:30 +02:00
|
|
|
|
2017-05-26 17:24:04 +02:00
|
|
|
// Moves applications across multiple screens
|
2018-07-06 19:35:22 +02:00
|
|
|
var throwLeft = slate.operation("throw", {
|
|
|
|
screen: "0",
|
|
|
|
width: "screenSizeX",
|
|
|
|
height: "screenSizeY"
|
|
|
|
});
|
|
|
|
var throwRight = slate.operation("throw", {
|
|
|
|
screen: "1",
|
|
|
|
width: "screenSizeX",
|
|
|
|
height: "screenSizeY"
|
|
|
|
});
|
2017-05-22 17:22:30 +02:00
|
|
|
|
2018-07-06 19:35:22 +02:00
|
|
|
slate.bind("1:ctrl", throwLeft);
|
|
|
|
slate.bind("2:ctrl", throwRight);
|
2017-05-22 17:22:30 +02:00
|
|
|
|
|
|
|
var focus_apps = {
|
2018-07-06 19:35:22 +02:00
|
|
|
1: "1Password",
|
|
|
|
i: "iTunes",
|
|
|
|
a: "Atom",
|
|
|
|
h: "Dash",
|
|
|
|
e: "Emacs",
|
|
|
|
t: "iTerm2",
|
|
|
|
m: "Messages",
|
|
|
|
s: "Spotify",
|
|
|
|
c: "Google Chrome",
|
|
|
|
l: "LimeChat",
|
|
|
|
k: "Slack",
|
|
|
|
w: "Wireshark",
|
|
|
|
p: "Tomato One",
|
|
|
|
d: "Discord"
|
2017-05-22 17:22:30 +02:00
|
|
|
};
|
|
|
|
|
2017-05-26 17:24:04 +02:00
|
|
|
Object.keys(focus_apps).forEach(function(key) {
|
|
|
|
app = focus_apps[key];
|
2018-07-06 19:35:22 +02:00
|
|
|
S.bind(key + modal_key, S.op("focus", { app: app }));
|
2017-05-22 17:22:30 +02:00
|
|
|
});
|