-
Notifications
You must be signed in to change notification settings - Fork 14
/
extension.js
96 lines (84 loc) · 2.39 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
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
// Library imports
const Gio = imports.gi.Gio;
const Lang = imports.lang;
const Main = imports.ui.main;
const Util = imports.misc.util;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
// const Tweener = imports.ui.tweener.tweener;
// Extension imports
const Utils = imports.misc.extensionUtils.getCurrentExtension().imports.utils;
const mySettings = Utils.getSettings();
// Globals
const key_bindings = {
'key': function(){
_startTilix();
}
};
let text, button;
function init(extensionMeta) {
button = new St.Bin({
style_class: 'panel-button',
reactive: true,
can_focus: true,
track_hover: true
});
let icon = new St.Icon({
icon_name: 'com.gexperts.Tilix-symbolic',
style_class: 'system-status-icon'
});
button.set_child(icon);
button.connect('button-press-event', _startTilix);
}
function _startTilix() {
try {
Util.trySpawnCommandLine('env GDK_BACKEND=x11 tilix --quake');
} catch(err) {
Main.notify("Couldn't start tilix, is it installed?");
}
}
function enable() {
let key;
for (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]
);
}
}
Main.panel._rightBox.insert_child_at_index(button, 0);
}
function disable() {
let key;
for (key in key_bindings) {
if (Main.wm.removeKeybinding) { // introduced in 3.7.2
Main.wm.removeKeybinding(key);
}
else {
global.display.remove_keybinding(key);
}
}
Main.panel._rightBox.remove_child(button);
}