gex: working quicktoggle example

This commit is contained in:
Luke D. Jones
2023-06-29 20:48:15 +12:00
parent a743bda6e0
commit e325ebed18
3 changed files with 27 additions and 45 deletions

View File

@@ -23,6 +23,7 @@ const QuickMiniLed = GObject.registerClass(
title: 'MiniLED',
iconName: 'selection-mode-symbolic',
toggleMode: true,
checked: asusctlGexInstance.dbus_platform.bios.mini_led_mode,
});
this.label = 'MiniLED';
@@ -35,6 +36,10 @@ const QuickMiniLed = GObject.registerClass(
'clicked', () => this._toggleMode(),
this);
this._settings.bind('mini-led-enabled',
this, 'checked',
Gio.SettingsBindFlags.DEFAULT);
this._sync();
}
@@ -44,14 +49,10 @@ const QuickMiniLed = GObject.registerClass(
}
_sync() {
const checked = asusctlGexInstance.dbus_platform.bios.mini_led_mode;
const checked = asusctlGexInstance.dbus_platform.getMiniLedMode();
if (this.checked !== checked)
this.set(checked);
//@ts-ignore
log(`QuickMiniLed !`, this.checked);
//@ts-ignore
log(`asusctlGexInstance.dbus_platform.bios.mini_led_mode !`, asusctlGexInstance.dbus_platform.bios.mini_led_mode);
this.set({ checked });
// this.set_property('checked', checked);
}
});
@@ -66,7 +67,6 @@ const IndicateMiniLed = GObject.registerClass(
// Showing the indicator when the feature is enabled
this._settings = ExtensionUtils.getSettings();
this._settings.bind('mini-led-enabled',
this._indicator, 'visible',
Gio.SettingsBindFlags.DEFAULT);
@@ -105,11 +105,14 @@ const QuickPanelOd = GObject.registerClass(
}
_toggleMode() {
asusctlGexInstance.dbus_platform.setPanelOd(!asusctlGexInstance.dbus_platform.bios.panel_overdrive);
asusctlGexInstance.dbus_platform.setPanelOd(this.checked);
this._sync();
}
_sync() {
this.set(asusctlGexInstance.dbus_platform.bios.panel_overdrive);
const checked = asusctlGexInstance.dbus_platform.getPanelOd();
if (this.checked !== checked)
this.set({ checked });
}
});
@@ -144,29 +147,15 @@ class Extension {
this._dbus_power = new Power();
this._dbus_anime = new AnimeDbus();
this.dbus_supported.start().then(() => {
//@ts-ignore
log(`DOOOOOM!, supported =`, this.dbus_supported.supported);
});
this.dbus_platform.start().then(() => {
//@ts-ignore
log(`DOOOOOM!, mini_led_mode =`, this.dbus_platform.bios.mini_led_mode);
});
this._dbus_power.start().then(() => {
//@ts-ignore
log(`DOOOOOM!, charge limit =`, this._dbus_power.chargeLimit);
});
this._dbus_anime.start().then(() => {
//@ts-ignore
log(`DOOOOOM!, anime =`, this._dbus_anime.deviceState.display_enabled);
});
this.dbus_supported.start();
this.dbus_platform.start();
this._dbus_power.start();
this._dbus_anime.start();
}
enable() {
this._indicateMiniLed = new IndicateMiniLed();
this._indicateMiniLed.checked = this.dbus_platform.bios.mini_led_mode;
this._indicatePanelOd = new IndicatePanelOd();
}

View File

@@ -24,8 +24,7 @@ export class Platform extends DbusBase {
public getPostBootSound() {
if (this.isRunning()) {
try {
let currentState = this.dbus_proxy.PostBootSoundSync();
this.bios.post_sound = parseInt(currentState) == 1 ? true : false;
this.bios.post_sound = this.dbus_proxy.PostBootSoundSync() == 'true' ? true : false;
} catch (e) {
//@ts-ignore
log(`Failed to get POST Boot Sound state!`, e);
@@ -51,8 +50,7 @@ export class Platform extends DbusBase {
public getGpuMuxMode() {
if (this.isRunning()) {
try {
let currentState = this.dbus_proxy.GpuMuxModeSync();
this.bios.gpu_mux = parseInt(currentState) == 0 ? true : false;
this.bios.gpu_mux = this.dbus_proxy.GpuMuxModeSync() == 'true' ? true : false;
} catch (e) {
//@ts-ignore
log(`Failed to get MUX state!`, e);
@@ -78,8 +76,7 @@ export class Platform extends DbusBase {
public getPanelOd() {
if (this.isRunning()) {
try {
let currentState = this.dbus_proxy.PanelOdSync();
this.bios.panel_overdrive = parseInt(currentState) == 1 ? true : false;
this.bios.panel_overdrive = this.dbus_proxy.PanelOdSync() == 'true' ? true : false;
} catch (e) {
//@ts-ignore
log(`Failed to get Overdrive state!`, e);
@@ -105,14 +102,12 @@ export class Platform extends DbusBase {
public getMiniLedMode() {
if (this.isRunning()) {
try {
this.bios.mini_led_mode = this.dbus_proxy.MiniLedModeSync();
this.bios.mini_led_mode = this.dbus_proxy.MiniLedModeSync() == 'true' ? true : false;
} catch (e) {
//@ts-ignore
log(`Failed to get Overdrive state!`, e);
}
}
//@ts-ignore
log(`MINI LED MODE: !`, this.bios.mini_led_mode);
return this.bios.mini_led_mode;
}
@@ -134,7 +129,7 @@ export class Platform extends DbusBase {
try {
await super.start();
this.bios.post_sound = this.getPostBootSound();
this.getPostBootSound();
this.dbus_proxy.connectSignal(
"NotifyPostBootSound",
(proxy: any = null, _name: string, data: boolean) => {
@@ -145,7 +140,7 @@ export class Platform extends DbusBase {
}
);
this.bios.panel_overdrive = this.getPanelOd();
this.getPanelOd();
this.dbus_proxy.connectSignal(
"NotifyPanelOd",
(proxy: any = null, _name: string, data: boolean) => {
@@ -156,7 +151,7 @@ export class Platform extends DbusBase {
}
);
this.bios.mini_led_mode = this.getMiniLedMode();
this.getMiniLedMode();
this.dbus_proxy.connectSignal(
"NotifyMiniLedMode",
(proxy: any = null, _name: string, data: boolean) => {
@@ -167,7 +162,7 @@ export class Platform extends DbusBase {
}
);
this.bios.gpu_mux = this.getGpuMuxMode();
this.getGpuMuxMode();
this.dbus_proxy.connectSignal(
"NotifyGpuMuxMode",
(proxy: any = null, _name: string, data: boolean) => {