mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
gex: map more of dbus methods and notifs
This commit is contained in:
@@ -10,6 +10,9 @@ export class AuraDbus extends DbusBase {
|
|||||||
x1866: [],
|
x1866: [],
|
||||||
x19b6: []
|
x19b6: []
|
||||||
};
|
};
|
||||||
|
// TODO: interface or something to enforce requirement of "sync()" method
|
||||||
|
public notifyAuraModeSubscribers: any[] = [];
|
||||||
|
public notifyAuraPowerSubscribers: any[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("org-asuslinux-aura-4", "/org/asuslinux/Aura");
|
super("org-asuslinux-aura-4", "/org/asuslinux/Aura");
|
||||||
@@ -28,19 +31,31 @@ export class AuraDbus extends DbusBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_parsePowerStates(data: any[]) {
|
||||||
|
const power: AuraPowerDev = {
|
||||||
|
tuf: [],
|
||||||
|
x1866: [],
|
||||||
|
x19b6: []
|
||||||
|
};
|
||||||
|
|
||||||
|
power.tuf = data[0].map((value: string) => {
|
||||||
|
return AuraDevTuf[value as AuraDevTuf];
|
||||||
|
});
|
||||||
|
power.x1866 = data[1].map((value: string) => {
|
||||||
|
return AuraDevRog1[value as AuraDevRog1];
|
||||||
|
});
|
||||||
|
power.x19b6 = data[2].map((value: string) => {
|
||||||
|
return AuraDevRog2[value as AuraDevRog2];
|
||||||
|
});
|
||||||
|
|
||||||
|
return power;
|
||||||
|
}
|
||||||
|
|
||||||
public getLedPower() {
|
public getLedPower() {
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
try {
|
try {
|
||||||
const data = this.dbus_proxy.LedPowerSync();
|
const data = this.dbus_proxy.LedPowerSync();
|
||||||
this.leds_powered.tuf = data[0].map((value: string) => {
|
this.leds_powered = this._parsePowerStates(data);
|
||||||
return AuraDevTuf[value as AuraDevTuf];
|
|
||||||
});
|
|
||||||
this.leds_powered.x1866 = data[1].map((value: string) => {
|
|
||||||
return AuraDevRog1[value as AuraDevRog1];
|
|
||||||
});
|
|
||||||
this.leds_powered.x19b6 = data[2].map((value: string) => {
|
|
||||||
return AuraDevRog2[value as AuraDevRog2];
|
|
||||||
});
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log("LED power tuf: " + this.leds_powered.tuf);
|
log("LED power tuf: " + this.leds_powered.tuf);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
@@ -67,6 +82,37 @@ export class AuraDbus extends DbusBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setLedMode(mode: AuraEffect) {
|
||||||
|
if (this.isRunning()) {
|
||||||
|
try {
|
||||||
|
this.dbus_proxy.SetLedModeSync(mode);
|
||||||
|
} catch (e) {
|
||||||
|
//@ts-ignore
|
||||||
|
log("Failed to fetch supported functionalities", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_parseAuraEffect(data: any[]) {
|
||||||
|
const aura: AuraEffect = {
|
||||||
|
mode: AuraModeNum[data[0] as AuraModeNum],
|
||||||
|
zone: AuraZone[data[1] as AuraZone],
|
||||||
|
colour1: {
|
||||||
|
r: parseInt(data[2][0]),
|
||||||
|
g: parseInt(data[2][1]),
|
||||||
|
b: parseInt(data[2][2]),
|
||||||
|
},
|
||||||
|
colour2: {
|
||||||
|
r: parseInt(data[3][0]),
|
||||||
|
g: parseInt(data[3][1]),
|
||||||
|
b: parseInt(data[3][2]),
|
||||||
|
},
|
||||||
|
speed: Speed[data[4] as Speed],
|
||||||
|
direction: Direction[data[5] as Direction],
|
||||||
|
};
|
||||||
|
return aura;
|
||||||
|
}
|
||||||
|
|
||||||
// Return a list of the available modes, and the current settings for each
|
// Return a list of the available modes, and the current settings for each
|
||||||
public getLedModes() {
|
public getLedModes() {
|
||||||
// {'Breathe': ('Breathe', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
// {'Breathe': ('Breathe', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
||||||
@@ -77,23 +123,8 @@ export class AuraDbus extends DbusBase {
|
|||||||
try {
|
try {
|
||||||
const _data = this.dbus_proxy.LedModesSync();
|
const _data = this.dbus_proxy.LedModesSync();
|
||||||
for (const key in _data[0]) {
|
for (const key in _data[0]) {
|
||||||
const value = _data[0][key];
|
const data = _data[0][key];
|
||||||
const aura: AuraEffect = {
|
const aura: AuraEffect = this._parseAuraEffect(data);
|
||||||
mode: AuraModeNum[value[0] as AuraModeNum],
|
|
||||||
zone: AuraZone[value[1] as AuraZone],
|
|
||||||
colour1: {
|
|
||||||
r: parseInt(value[2][0]),
|
|
||||||
g: parseInt(value[2][1]),
|
|
||||||
b: parseInt(value[2][2]),
|
|
||||||
},
|
|
||||||
colour2: {
|
|
||||||
r: parseInt(value[3][0]),
|
|
||||||
g: parseInt(value[3][1]),
|
|
||||||
b: parseInt(value[3][2]),
|
|
||||||
},
|
|
||||||
speed: Speed[value[4] as Speed],
|
|
||||||
direction: Direction[value[5] as Direction],
|
|
||||||
};
|
|
||||||
this.aura_modes.set(AuraModeNum[key as AuraModeNum], aura);
|
this.aura_modes.set(AuraModeNum[key as AuraModeNum], aura);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,6 +147,59 @@ export class AuraDbus extends DbusBase {
|
|||||||
this.getLedPower();
|
this.getLedPower();
|
||||||
this.getLedMode();
|
this.getLedMode();
|
||||||
this.getLedModes();
|
this.getLedModes();
|
||||||
|
|
||||||
|
//@ts-ignore
|
||||||
|
log("Current LED mode data:", this.aura_modes.get(this.current_aura_mode)?.speed);
|
||||||
|
|
||||||
|
this.dbus_proxy.connectSignal(
|
||||||
|
"NotifyLed",
|
||||||
|
(proxy: any = null, name: string, data: any) => {
|
||||||
|
if (proxy) {
|
||||||
|
const aura: AuraEffect = this._parseAuraEffect(data[0]);
|
||||||
|
this.current_aura_mode = aura.mode;
|
||||||
|
this.aura_modes.set(aura.mode, aura);
|
||||||
|
//@ts-ignore
|
||||||
|
log("LED data has changed to ", aura.mode, aura.zone, aura.colour1.r, aura.speed, aura.direction);
|
||||||
|
this.notifyAuraModeSubscribers.forEach(sub => {
|
||||||
|
sub.sync();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.dbus_proxy.connectSignal(
|
||||||
|
"NotifyPowerStates",
|
||||||
|
(proxy: any = null, name: string, data: any) => {
|
||||||
|
if (proxy) {
|
||||||
|
const power: AuraPowerDev = this._parsePowerStates(data[0]);
|
||||||
|
this.leds_powered = power;
|
||||||
|
switch (this.device) {
|
||||||
|
case AuraDevice.Tuf:
|
||||||
|
//@ts-ignore
|
||||||
|
log("LED power has changed to ", this.leds_powered.tuf);
|
||||||
|
break;
|
||||||
|
case AuraDevice.X1854:
|
||||||
|
case AuraDevice.X1869:
|
||||||
|
case AuraDevice.X18c6:
|
||||||
|
//@ts-ignore
|
||||||
|
log("LED power has changed to ", this.leds_powered.x1866);
|
||||||
|
break;
|
||||||
|
case AuraDevice.X19b6:
|
||||||
|
case AuraDevice.X1a30:
|
||||||
|
//@ts-ignore
|
||||||
|
log("LED power has changed to ", this.leds_powered.x19b6);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
log("LED power has changed to ", this.leds_powered.x19b6);
|
||||||
|
this.notifyAuraPowerSubscribers.forEach(sub => {
|
||||||
|
sub.sync();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log("Supported DBus initialization failed!", e);
|
log("Supported DBus initialization failed!", e);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const AuraMenuToggle = GObject.registerClass(
|
|||||||
|
|
||||||
constructor(dbus_aura: AuraDbus) {
|
constructor(dbus_aura: AuraDbus) {
|
||||||
super({
|
super({
|
||||||
title: "Laptop",
|
title: "Aura Modes",
|
||||||
iconName: "selection-mode-symbolic",
|
iconName: "selection-mode-symbolic",
|
||||||
toggleMode: true,
|
toggleMode: true,
|
||||||
});
|
});
|
||||||
@@ -28,7 +28,7 @@ export const AuraMenuToggle = GObject.registerClass(
|
|||||||
"destroy", () => this._settings.run_dispose(),
|
"destroy", () => this._settings.run_dispose(),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
this.menu.setHeader("selection-mode-symbolic", "Laptop features");
|
this.menu.setHeader("selection-mode-symbolic", this._dbus_aura.current_aura_mode);
|
||||||
|
|
||||||
this._settings = ExtensionUtils.getSettings();
|
this._settings = ExtensionUtils.getSettings();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user