mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
gex: rename gnome-44, add gnome-45
This commit is contained in:
49
desktop-extensions/gnome-45/src/modules/dbus/base.ts
Normal file
49
desktop-extensions/gnome-45/src/modules/dbus/base.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import * as Resources from "../resources";
|
||||
import Gio from 'gi://Gio';
|
||||
|
||||
export class DbusBase {
|
||||
dbus_proxy: any = null; // type: Gio.DbusProxy
|
||||
connected = false;
|
||||
xml_resource = "";
|
||||
dbus_path = "";
|
||||
|
||||
constructor(resource: string, dbus_path: string) {
|
||||
this.xml_resource = resource;
|
||||
this.dbus_path = dbus_path;
|
||||
}
|
||||
|
||||
async start() {
|
||||
//@ts-ignore
|
||||
log(`Starting ${this.dbus_path} dbus module`);
|
||||
try {
|
||||
const xml = Resources.File.DBus(this.xml_resource);
|
||||
this.dbus_proxy = new Gio.DBusProxy.makeProxyWrapper(xml)(
|
||||
Gio.DBus.system,
|
||||
"org.asuslinux.Daemon",
|
||||
this.dbus_path,
|
||||
);
|
||||
|
||||
this.connected = true;
|
||||
//@ts-ignore
|
||||
log(`${this.dbus_path} client started successfully.`);
|
||||
} catch (e) {
|
||||
//@ts-ignore
|
||||
logError(`${this.xml_resource} dbus init failed!`, e);
|
||||
}
|
||||
}
|
||||
|
||||
async stop() {
|
||||
//@ts-ignore
|
||||
log(`Stopping ${this.xml_resource} dbus module`);
|
||||
|
||||
if (this.connected) {
|
||||
this.dbus_proxy.destroy();
|
||||
this.connected = false;
|
||||
this.dbus_proxy = null;
|
||||
}
|
||||
}
|
||||
|
||||
isRunning(): boolean {
|
||||
return this.connected;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user