-
Notifications
You must be signed in to change notification settings - Fork 0
/
applet.js
executable file
·51 lines (42 loc) · 1.3 KB
/
applet.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
const Lang = imports.lang;
const Applet = imports.ui.applet;
const GLib = imports.gi.GLib;
const Gettext = imports.gettext;
const UUID = "killdota@appi147";
Gettext.bindtextdomain(UUID, GLib.get_home_dir() + "./local/share/locale");
function _(str) {
return Gettext.dgettext(UUID, str)
}
function MyApplet(orientation) {
this._init(orientation);
}
MyApplet.prototype = {
__proto__: Applet.IconApplet.prototype,
_init: function(orientation) {
Applet.IconApplet.prototype._init.call(this, orientation);
try {
this.set_applet_icon_name("window-close");
this.set_applet_tooltip(_("Click here to kill Dota"));
this.actor.connect('button-release-event', Lang.bind(this, this._onButtonReleaseEvent));
}
catch (e) {
global.logError(e);
}
},
_onButtonReleaseEvent: function(actor, event) {
if (this._applet_enabled) {
if (event.get_button() == 1) {
if (!this._draggable.inhibit) {
return false;
} else {
GLib.spawn_command_line_async('pkill -9 dota');
}
}
}
return true;
}
};
function main(metadata, orientation) {
let myApplet = new MyApplet(orientation);
return myApplet;
}