-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathextension.js
51 lines (44 loc) · 1.27 KB
/
extension.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
/* -*- mode: js; js-basic-offset: 4; indent-tabs-mode: nil -*- */
import Clutter from "gi://Clutter";
import * as AltTab from "resource:///org/gnome/shell/ui/altTab.js";
let injections = {
WindowSwitcherPopup: {},
AppSwitcherPopup: {},
};
function init(metadata) {}
function mapVimKeys(cb) {
return function (keysym, action) {
switch (keysym) {
case Clutter.KEY_h:
keysym = Clutter.Left || Clutter.KEY_Left;
break;
case Clutter.KEY_l:
keysym = Clutter.Right || Clutter.KEY_Right;
break;
case Clutter.KEY_k:
keysym = Clutter.Up || Clutter.KEY_Up;
break;
case Clutter.KEY_j:
keysym = Clutter.Down || Clutter.KEY_Down;
break;
}
cb.call(this, keysym, action);
};
}
export default class VimAltTab {
enable() {
for (let switcherPopup in injections) {
injections[switcherPopup]["_keyPressHandler"] =
AltTab[switcherPopup].prototype._keyPressHandler;
AltTab[switcherPopup].prototype._keyPressHandler = mapVimKeys(
injections[switcherPopup]["_keyPressHandler"]
);
}
}
disable() {
for (let switcherPopup in injections) {
for (let prop in switcherPopup)
AltTab[switcherPopup].prototype[prop] = switcherPopup[prop];
}
}
}