diff --git a/bindings/dbus-xml/org-asuslinux-anime-4.xml b/bindings/dbus-xml/org-asuslinux-anime-4.xml
index ecf879cd..f75c27a1 100644
--- a/bindings/dbus-xml/org-asuslinux-anime-4.xml
+++ b/bindings/dbus-xml/org-asuslinux-anime-4.xml
@@ -52,14 +52,14 @@
Get the device state as stored by asusd
-->
-
+
-
+
diff --git a/desktop-extensions/gnome/src/extension.ts b/desktop-extensions/gnome/src/extension.ts
index 1bdc3d11..adef57fb 100644
--- a/desktop-extensions/gnome/src/extension.ts
+++ b/desktop-extensions/gnome/src/extension.ts
@@ -18,7 +18,8 @@ const ThisModule = imports.misc.extensionUtils.getCurrentExtension();
// const TestProxy = Gio.DBusProxy.makeProxyWrapper(interfaceXml);
import * as Platform from './bindings/platform';
-import { ChargingLimit } from './modules/charge_dbus';
+import { AnimeDbus } from './modules/anime_dbus';
+import { Power } from './modules/power_dbus';
import { Supported } from './modules/supported_dbus';
const QuickMiniLed = GObject.registerClass(
@@ -135,7 +136,8 @@ class Extension {
private _naff: Platform.GpuMode;
private _indicateMiniLed: typeof IndicateMiniLed;
private _indicatePanelOd: typeof IndicatePanelOd;
- private _dbus_charge!: ChargingLimit;
+ private _dbus_charge!: Power;
+ private _dbus_anime!: AnimeDbus;
private _dbus_supported!: Supported;
constructor() {
@@ -147,16 +149,21 @@ class Extension {
enable() {
this._indicateMiniLed = new IndicateMiniLed();
this._indicatePanelOd = new IndicatePanelOd();
- this._dbus_charge = new ChargingLimit();
+ this._dbus_charge = new Power();
this._dbus_charge.start().then(() => {
//@ts-ignore
- log(`DOOOOOM!, charge limit =`, this._dbus_charge.lastState);
+ log(`DOOOOOM!, charge limit =`, this._dbus_charge.chargeLimit);
});
this._dbus_supported = new Supported();
this._dbus_supported.start().then(() => {
//@ts-ignore
log(`DOOOOOM!, supported =`, this._dbus_supported.supported);
});
+ this._dbus_anime = new AnimeDbus();
+ this._dbus_anime.start().then(() => {
+ //@ts-ignore
+ log(`DOOOOOM!, anime =`, this._dbus_anime.deviceState.display_enabled);
+ });
}
disable() {
diff --git a/desktop-extensions/gnome/src/modules/anime_dbus.ts b/desktop-extensions/gnome/src/modules/anime_dbus.ts
index 9cf21662..387e41af 100644
--- a/desktop-extensions/gnome/src/modules/anime_dbus.ts
+++ b/desktop-extensions/gnome/src/modules/anime_dbus.ts
@@ -1,33 +1,37 @@
declare const global: any, imports: any;
declare var asusctlGexInstance: any;
//@ts-ignore
-const ThisModule = imports.misc.extensionUtils.getCurrentExtension();
-
-import * as Resources from './resources';
-
-const { Gio } = imports.gi;
+const Me = imports.misc.extensionUtils.getCurrentExtension();
import { DbusBase } from '../modules/dbus';
+import { DeviceState, AnimBooting, Brightness, AnimAwake, AnimSleeping, AnimShutdown } from '../bindings/anime';
export class AnimeDbus extends DbusBase {
- state: boolean = true;
- brightness: number = 255;
+ deviceState: DeviceState = {
+ display_enabled: false,
+ display_brightness: Brightness.Med,
+ builtin_anims_enabled: false,
+ builtin_anims: {
+ boot: AnimBooting.GlitchConstruction,
+ awake: AnimAwake.BinaryBannerScroll,
+ sleep: AnimSleeping.BannerSwipe,
+ shutdown: AnimShutdown.GlitchOut
+ },
+ };
constructor() {
super('org-asuslinux-anime-4', '/org/asuslinux/Anime');
}
- public setOnOffState(state: boolean | null) {
+ public setEnableDisplay(state: boolean | null) {
if (this.isRunning()) {
try {
// if null, toggle the current state
- state = (state == null ? !this.state : state);
+ state = (state == null ? !this.deviceState.display_enabled : state);
- if (this.state !== state) {
- this.state = state;
+ if (this.deviceState.display_enabled !== state) {
+ this.deviceState.display_enabled = state;
}
- //@ts-ignore
- log(`Setting AniMe Power to ${state}`);
return this.dbus_proxy.SetOnOffSync(state);
} catch (e) {
//@ts-ignore
@@ -36,16 +40,13 @@ export class AnimeDbus extends DbusBase {
}
}
- public setBrightness(brightness: number) {
+ public setBrightness(brightness: Brightness) {
if (this.isRunning()) {
try {
- if (this.brightness !== brightness) {
- this.brightness = brightness;
+ if (this.deviceState.display_brightness !== brightness) {
+ this.deviceState.display_brightness = brightness;
}
- //@ts-ignore
- log(`Setting AniMe Brightness to ${brightness}`);
return this.dbus_proxy.SetBrightnessSync(brightness);
- // Panel.Actions.spawnCommandLine(`asusctl anime leds -b ${brightness}`);
} catch (e) {
//@ts-ignore
log(`AniMe DBus set brightness failed!`, e);
@@ -53,40 +54,65 @@ export class AnimeDbus extends DbusBase {
}
}
- async start() {
- //@ts-ignore
- log(`Starting AniMe DBus client...`);
+ _parseDeviceState(input: String) {
+ let valueString: string = '';
- try {
- // creating the proxy
- let xml = Resources.File.DBus('org-asuslinux-anime-4')
- this.dbus_proxy = new Gio.DBusProxy.makeProxyWrapper(xml)(
- Gio.DBus.system,
- 'org.asuslinux.Daemon',
- '/org/asuslinux/Anime'
- );
-
- this.connected = true;
-
- // currently there is no DBUS method because this can't be read from
- // hardware (as to @fluke).
- // https://gitlab.com/asus-linux/asusctl/-/issues/138
- /*
- this.asusLinuxProxy.connectSignal(
- "NotifyCharge",
- (proxy: any = null, name: string, data: string) => {
- if (proxy) {
- Log.info(`AniMe Power State has changed to ${data}% (${name}).`);
- }
- }
- );
- */
- } catch (e) {
+ for (const [_key, value] of Object.entries(input)) {
//@ts-ignore
- log(`AniMe DBus initialization failed!`, e);
+ valueString = value.toString();
+
+ switch (parseInt(_key)) {
+ case 0:
+ this.deviceState.display_enabled = (valueString == 'true' ? true : false);
+ break;
+ case 1:
+ this.deviceState.display_brightness = Brightness[valueString as Brightness];
+ break;
+ case 2:
+ this.deviceState.builtin_anims_enabled = (valueString == 'true' ? true : false);
+ break;
+ case 3:
+ let anims = valueString.split(',');
+ this.deviceState.builtin_anims.boot = AnimBooting[anims[0] as AnimBooting];
+ this.deviceState.builtin_anims.awake = AnimAwake[anims[1] as AnimAwake];
+ this.deviceState.builtin_anims.sleep = AnimSleeping[anims[2] as AnimSleeping];
+ this.deviceState.builtin_anims.shutdown = AnimShutdown[anims[3] as AnimShutdown];
+ break;
+ }
}
}
+ public getDeviceState() {
+ if (this.isRunning()) {
+ try {
+ let _data = this.dbus_proxy.DeviceStateSync();
+ if (_data.length > 0) {
+ this._parseDeviceState(_data);
+ }
+ } catch (e) {
+ //@ts-ignore
+ log(`Failed to fetch DeviceState!`, e);
+ }
+ }
+ return this.deviceState;
+ }
+
+ async start() {
+ await super.start();
+ this.getDeviceState();
+
+ this.dbus_proxy.connectSignal(
+ "NotifyDeviceState",
+ (proxy: any = null, name: string, data: string) => {
+ if (proxy) {
+ this._parseDeviceState(data);
+ //@ts-ignore
+ log(`NotifyDeviceState has changed to ${data}% (${name}).`);
+ }
+ }
+ );
+ }
+
async stop() {
await super.stop();
}
diff --git a/desktop-extensions/gnome/src/modules/platform_dbus.ts b/desktop-extensions/gnome/src/modules/platform_dbus.ts
index c7f4a4fd..de7686cb 100644
--- a/desktop-extensions/gnome/src/modules/platform_dbus.ts
+++ b/desktop-extensions/gnome/src/modules/platform_dbus.ts
@@ -6,6 +6,7 @@ const Me = imports.misc.extensionUtils.getCurrentExtension();
import * as bios from '../bindings/platform';
import { DbusBase } from '../modules/dbus';
+// TODO: add callbacks for notifications
export class Platform extends DbusBase {
bios: bios.RogBiosSupportedFunctions = asusctlGexInstance.supported.connector.supported;
@@ -17,7 +18,7 @@ export class Platform extends DbusBase {
if (this.isRunning()) {
try {
let currentState = this.dbus_proxy.PostBootSoundSync();
- return parseInt(currentState) == 1 ? true : false;
+ this.bios.post_sound = parseInt(currentState) == 1 ? true : false;
} catch (e) {
//@ts-ignore
log(`Failed to get POST Boot Sound state!`, e);
@@ -40,20 +41,20 @@ export class Platform extends DbusBase {
}
}
- public getMUX() {
+ public getGpuMuxMode() {
if (this.isRunning()) {
try {
let currentState = this.dbus_proxy.GpuMuxModeSync();
- return parseInt(currentState) == 0 ? true : false;
+ this.bios.gpu_mux = parseInt(currentState) == 0 ? true : false;
} catch (e) {
//@ts-ignore
log(`Failed to get MUX state!`, e);
}
}
- return this.bios.post_sound;
+ return this.bios.gpu_mux;
}
- public setMUX(state: boolean) {
+ public setGpuMuxMode(state: boolean) {
if (this.isRunning()) {
try {
if (!state !== this.bios.gpu_mux) {
@@ -67,11 +68,11 @@ export class Platform extends DbusBase {
}
}
- public getOverdrive() {
+ public getPanelOd() {
if (this.isRunning()) {
try {
- let currentState = this.dbus_proxy.PanelOverdriveSync();
- return parseInt(currentState) == 1 ? true : false;
+ let currentState = this.dbus_proxy.PanelOdSync();
+ this.bios.panel_overdrive = parseInt(currentState) == 1 ? true : false;
} catch (e) {
//@ts-ignore
log(`Failed to get Overdrive state!`, e);
@@ -80,13 +81,40 @@ export class Platform extends DbusBase {
return this.bios.panel_overdrive;
}
- public setOverdrive(state: boolean) {
+ public setPanelOd(state: boolean) {
if (this.isRunning()) {
try {
if (state !== this.bios.panel_overdrive) {
this.bios.panel_overdrive = state;
}
- return this.dbus_proxy.SetPanelOverdriveSync(state);
+ return this.dbus_proxy.SetPanelOdSync(state);
+ } catch (e) {
+ //@ts-ignore
+ log(`Overdrive DBus set overdrive state failed!`, e);
+ }
+ }
+ }
+
+ public getMiniLedMode() {
+ if (this.isRunning()) {
+ try {
+ let currentState = this.dbus_proxy.MiniLedModeSync();
+ this.bios.mini_led_mode = parseInt(currentState) == 1 ? true : false;
+ } catch (e) {
+ //@ts-ignore
+ log(`Failed to get Overdrive state!`, e);
+ }
+ }
+ return this.bios.mini_led_mode;
+ }
+
+ public setMiniLedMode(state: boolean) {
+ if (this.isRunning()) {
+ try {
+ if (state !== this.bios.mini_led_mode) {
+ this.bios.mini_led_mode = state;
+ }
+ return this.dbus_proxy.SetMiniLedModeSync(state);
} catch (e) {
//@ts-ignore
log(`Overdrive DBus set overdrive state failed!`, e);
@@ -98,57 +126,53 @@ export class Platform extends DbusBase {
try {
await super.start();
- if (asusctlGexInstance.supported.connector.supportedAttributes.bios_toggleSound) {
- this.bios.post_sound = this.getPostBootSound();
- this.dbus_proxy.connectSignal(
- "NotifyPostBootSound",
- (proxy: any = null, _name: string, data: boolean) => {
- if (proxy) {
- //@ts-ignore
- log(`PostBootSound changed to ${data}`);
- asusctlGexInstance.Platform.switchPostBootSound.setToggleState(this.bios.post_sound);
- }
+ this.bios.post_sound = this.getPostBootSound();
+ this.dbus_proxy.connectSignal(
+ "NotifyPostBootSound",
+ (proxy: any = null, _name: string, data: boolean) => {
+ if (proxy) {
+ //@ts-ignore
+ log(`PostBootSound changed to ${data}`);
}
- );
- }
+ }
+ );
- if (asusctlGexInstance.supported.connector.supportedAttributes.bios_overdrive) {
- this.bios.panel_overdrive = this.getOverdrive();
- this.dbus_proxy.connectSignal(
- "NotifyPanelOverdrive",
- (proxy: any = null, _name: string, data: boolean) => {
- if (proxy) {
- //@ts-ignore
- log(`Overdrive has changed to ${data}.`);
- asusctlGexInstance.Platform.overdriveSwitch.setToggleState(this.bios.panel_overdrive);
- }
+ this.bios.panel_overdrive = this.getPanelOd();
+ this.dbus_proxy.connectSignal(
+ "NotifyPanelOd",
+ (proxy: any = null, _name: string, data: boolean) => {
+ if (proxy) {
+ //@ts-ignore
+ log(`NotifyPanelOd has changed to ${data}.`);
}
- );
- }
+ }
+ );
- if (asusctlGexInstance.supported.connector.supportedAttributes.bios_toggleMUX) {
- this.bios.gpu_mux = this.getMUX();
- this.dbus_proxy.connectSignal(
- "NotifyGpuMuxMode",
- (proxy: any = null, _name: string, data: boolean) => {
- if (proxy) {
- //@ts-ignore
- log(`MUX has changed to ${data}.`);
- asusctlGexInstance.Platform.switchMUX.setToggleState(this.bios.gpu_mux);
-
- // Panel.Actions.notify(
- // 'ASUS Notebook Control',
- // `MUX Mode has chnged. Please reboot to apply the changes.`,
- // 'scalable/reboot.svg',
- // 'reboot'
- // );
- }
+ this.bios.panel_overdrive = this.getMiniLedMode();
+ this.dbus_proxy.connectSignal(
+ "NotifyMiniLedMode",
+ (proxy: any = null, _name: string, data: boolean) => {
+ if (proxy) {
+ //@ts-ignore
+ log(`MiniLedMode has changed to ${data}.`);
}
- );
- }
+ }
+ );
+
+ this.bios.gpu_mux = this.getGpuMuxMode();
+ this.dbus_proxy.connectSignal(
+ "NotifyGpuMuxMode",
+ (proxy: any = null, _name: string, data: boolean) => {
+ if (proxy) {
+ //@ts-ignore
+ log(`MUX has changed to ${data}.`);
+ }
+ }
+ );
+
} catch (e) {
//@ts-ignore
- log(`Overdrive DBus init failed!`, e);
+ log(`Platform DBus init failed!`, e);
}
}
@@ -156,5 +180,7 @@ export class Platform extends DbusBase {
await super.stop();
this.bios.post_sound = false;
this.bios.panel_overdrive = false;
+ this.bios.mini_led_mode = false;
+ this.bios.gpu_mux = false;
}
}
\ No newline at end of file
diff --git a/desktop-extensions/gnome/src/modules/charge_dbus.ts b/desktop-extensions/gnome/src/modules/power_dbus.ts
similarity index 62%
rename from desktop-extensions/gnome/src/modules/charge_dbus.ts
rename to desktop-extensions/gnome/src/modules/power_dbus.ts
index 4fb28029..e8f979f8 100644
--- a/desktop-extensions/gnome/src/modules/charge_dbus.ts
+++ b/desktop-extensions/gnome/src/modules/power_dbus.ts
@@ -19,8 +19,9 @@ import { DbusBase } from '../modules/dbus';
// return result;
// }
-export class ChargingLimit extends DbusBase {
- lastState: number = 100;
+export class Power extends DbusBase {
+ chargeLimit: number = 100;
+ mainsOnline = false;
constructor() {
super('org-asuslinux-power-4', '/org/asuslinux/Power');
@@ -29,21 +30,21 @@ export class ChargingLimit extends DbusBase {
public getChargingLimit() {
if (this.isRunning()) {
try {
- this.lastState = this.dbus_proxy.ChargeControlEndThresholdSync();
+ this.chargeLimit = this.dbus_proxy.ChargeControlEndThresholdSync();
} catch (e) {
//@ts-ignore
log(`Failed to fetch Charging Limit!`, e);
}
}
- return this.lastState;
+ return this.chargeLimit;
}
public setChargingLimit(limit: number) {
if (this.isRunning()) {
try {
- if (limit > 0 && this.lastState !== limit) {
+ if (limit > 0 && this.chargeLimit !== limit) {
// update state
- this.lastState = limit;
+ this.chargeLimit = limit;
}
return this.dbus_proxy.SetChargeControlEndThresholdSync(limit);
} catch (e) {
@@ -53,6 +54,18 @@ export class ChargingLimit extends DbusBase {
}
}
+ public getMainsOnline() {
+ if (this.isRunning()) {
+ try {
+ this.mainsOnline = this.dbus_proxy.MainsOnlineSync();
+ } catch (e) {
+ //@ts-ignore
+ log(`Failed to fetch MainsLonline!`, e);
+ }
+ }
+ return this.mainsOnline;
+ }
+
async start() {
try {
await super.start();
@@ -64,7 +77,18 @@ export class ChargingLimit extends DbusBase {
if (proxy) {
//@ts-ignore
log(`Charging Limit has changed to ${data}% (${name}).`);
- this.lastState = parseInt(data);
+ this.chargeLimit = parseInt(data);
+ }
+ }
+ );
+
+ this.dbus_proxy.connectSignal(
+ "NotifyMainsOnline",
+ (proxy: any = null, name: string, data: string) => {
+ if (proxy) {
+ //@ts-ignore
+ log(`NotifyMainsOnline has changed to ${data}% (${name}).`);
+ this.mainsOnline = parseInt(data) == 1 ? true : false;
}
}
);
diff --git a/desktop-extensions/gnome/tsconfig.json b/desktop-extensions/gnome/tsconfig.json
index 97023ada..ddda0ca7 100644
--- a/desktop-extensions/gnome/tsconfig.json
+++ b/desktop-extensions/gnome/tsconfig.json
@@ -3,7 +3,7 @@
"compilerOptions": {
"target": "es2019",
// "module": "ES2015",
- // "moduleResolution": "node",
+ "moduleResolution": "node",
// "rootDir": "./",
"strict": true,
"outDir": "./target",