-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathextension.js
41 lines (32 loc) · 969 Bytes
/
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
const St = imports.gi.St;
const Main = imports.ui.main;
const Util = imports.misc.util;
const Shell = imports.gi.Shell;
const app = Shell.AppSystem.get_default().lookup_app("rocketchat.desktop");
let text, button;
function _showRocketChat() {
if(app == null) {
throw new Error("Could not find RocketChat! Make sure that the Desktop entry file 'rocketchat.desktop' is available.");
}
if (app.get_state() == 0) {
Util.spawn(['/opt/Rocket.Chat+/rocketchat']);
}
}
function init() {
button = new St.Bin({ style_class: 'panel-button',
reactive: true,
can_focus: true,
x_fill: true,
y_fill: false,
track_hover: true });
let icon = new St.Icon({ icon_name: 'rocketchat',
icon_size: 25 });
button.set_child(icon);
button.connect('button-press-event', _showRocketChat);
}
function enable() {
Main.panel._rightBox.insert_child_at_index(button, 0);
}
function disable() {
Main.panel._rightBox.remove_child(button);
}