forked from vibou/vibou.gTile
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhotkeys.js
55 lines (51 loc) · 1.53 KB
/
hotkeys.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
// Library imports
const Main = imports.ui.main;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
// Extension imports
const Extension = imports.misc.extensionUtils.getCurrentExtension();
const Settings = Extension.imports.settings;
// Globals
const mySettings = Settings.get();
function bind(key_bindings) {
global.log("Binding keys");
for (var key in key_bindings) {
if (Main.wm.addKeybinding && Shell.ActionMode) { // introduced in 3.16
Main.wm.addKeybinding(
key,
mySettings,
Meta.KeyBindingFlags.NONE,
Shell.ActionMode.NORMAL,
key_bindings[key]
);
}
else if (Main.wm.addKeybinding && Shell.KeyBindingMode) { // introduced in 3.7.5
Main.wm.addKeybinding(
key,
mySettings,
Meta.KeyBindingFlags.NONE,
Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.MESSAGE_TRAY,
key_bindings[key]
);
}
else {
global.display.add_keybinding(
key,
mySettings,
Meta.KeyBindingFlags.NONE,
key_bindings[key]
);
}
}
}
function unbind(key_bindings) {
global.log("Unbinding keys");
for (key in key_bindings) {
if (Main.wm.removeKeybinding) { // introduced in 3.7.2
Main.wm.removeKeybinding(key);
}
else {
global.display.remove_keybinding(key);
}
}
}