-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
48 lines (37 loc) · 1.22 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
const St = imports.gi.St;
const Gio = imports.gi.Gio;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
class Extension {
constructor() {
this._indicator = null;
}
enable() {
log(`enabling ${Me.metadata.name}`);
let indicatorName = `${Me.metadata.name} Indicator`;
// Create a panel button
this._indicator = new PanelMenu.Button(0.0, indicatorName, false);
// Add an icon
let icon = new St.Icon({
gicon: new Gio.ThemedIcon({ name: "face-laugh-symbolic" }),
style_class: "system-status-icon",
});
this._indicator.add_child(icon);
// `Main.panel` is the actual panel you see at the top of the screen,
// not a class constructor.
Main.panel.addToStatusArea(indicatorName, this._indicator);
}
// REMINDER: It's required for extensions to clean up after themselves when
// they are disabled. This is required for approval during review!
disable() {
log(`disabling ${Me.metadata.name}`);
this._indicator.destroy();
this._indicator = null;
}
}
function init() {
log(`initializing ${Me.metadata.name}`);
return new Extension();
}