forked from pop-os/cosmic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbus_service.js
45 lines (37 loc) · 1.26 KB
/
dbus_service.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
const { Gio } = imports.gi;
const IFACE = `<node>
<interface name="com.System76.Cosmic">
<method name="GestureLeft"/>
<method name="GestureRight"/>
<method name="GestureUp"/>
<method name="GestureDown"/>
<method name="ToggleApplications"/>
<method name="ToggleLauncher"/>
<method name="ToggleWorkspaces"/>
</interface>
</node>`;
var Service = class {
constructor() {
this.GestureLeft = () => {};
this.GestureRight = () => {};
this.GestureUp = () => {};
this.GestureDown = () => {};
this.ToggleApplications = () => {};
this.ToggleLauncher = () => {};
this.ToggleWorkspaces = () => {};
this.dbus = Gio.DBusExportedObject.wrapJSObject(IFACE, this);
const onBusAcquired = (conn) => {
try {
this.dbus.export(conn, '/com/System76/Cosmic')
} catch (why) {
global.log(`onBusAcquired export failed: ${why}`)
}
};
function onNameAcquired() { }
function onNameLost() { }
this.id = Gio.bus_own_name(Gio.BusType.SESSION, 'com.System76.Cosmic', Gio.BusNameOwnerFlags.NONE, onBusAcquired, onNameAcquired, onNameLost);
}
destroy() {
Gio.bus_unown_name(this.id);
}
}