mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
gex: working quicktoggle example
This commit is contained in:
@@ -2,9 +2,7 @@
|
|||||||
<schemalist>
|
<schemalist>
|
||||||
<schema id="org.gnome.shell.extensions.asusctl-gex" path="/org/gnome/shell/extensions/asusctl-gex/" >
|
<schema id="org.gnome.shell.extensions.asusctl-gex" path="/org/gnome/shell/extensions/asusctl-gex/" >
|
||||||
<key type="b" name="mini-led-enabled">
|
<key type="b" name="mini-led-enabled">
|
||||||
<default>true</default>
|
<default>false</default>
|
||||||
<summary>enable / disable notifications</summary>
|
|
||||||
<description>If enabled, notifications will show up on in various scenarios (when the GPU mode, power profile or charging limit is changed. Those notifications are not only triggered by the extension itself but react on DBUS signals from asusd, supergfxd and power-profiles-daemon.</description>
|
|
||||||
</key>
|
</key>
|
||||||
<key type="b" name="panel-od-enabled">
|
<key type="b" name="panel-od-enabled">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ const QuickMiniLed = GObject.registerClass(
|
|||||||
title: 'MiniLED',
|
title: 'MiniLED',
|
||||||
iconName: 'selection-mode-symbolic',
|
iconName: 'selection-mode-symbolic',
|
||||||
toggleMode: true,
|
toggleMode: true,
|
||||||
|
checked: asusctlGexInstance.dbus_platform.bios.mini_led_mode,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.label = 'MiniLED';
|
this.label = 'MiniLED';
|
||||||
@@ -35,6 +36,10 @@ const QuickMiniLed = GObject.registerClass(
|
|||||||
'clicked', () => this._toggleMode(),
|
'clicked', () => this._toggleMode(),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
|
this._settings.bind('mini-led-enabled',
|
||||||
|
this, 'checked',
|
||||||
|
Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
this._sync();
|
this._sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,14 +49,10 @@ const QuickMiniLed = GObject.registerClass(
|
|||||||
}
|
}
|
||||||
|
|
||||||
_sync() {
|
_sync() {
|
||||||
const checked = asusctlGexInstance.dbus_platform.bios.mini_led_mode;
|
const checked = asusctlGexInstance.dbus_platform.getMiniLedMode();
|
||||||
if (this.checked !== checked)
|
if (this.checked !== checked)
|
||||||
this.set(checked);
|
this.set({ checked });
|
||||||
|
// this.set_property('checked', checked);
|
||||||
//@ts-ignore
|
|
||||||
log(`QuickMiniLed !`, this.checked);
|
|
||||||
//@ts-ignore
|
|
||||||
log(`asusctlGexInstance.dbus_platform.bios.mini_led_mode !`, asusctlGexInstance.dbus_platform.bios.mini_led_mode);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,7 +67,6 @@ const IndicateMiniLed = GObject.registerClass(
|
|||||||
|
|
||||||
// Showing the indicator when the feature is enabled
|
// Showing the indicator when the feature is enabled
|
||||||
this._settings = ExtensionUtils.getSettings();
|
this._settings = ExtensionUtils.getSettings();
|
||||||
|
|
||||||
this._settings.bind('mini-led-enabled',
|
this._settings.bind('mini-led-enabled',
|
||||||
this._indicator, 'visible',
|
this._indicator, 'visible',
|
||||||
Gio.SettingsBindFlags.DEFAULT);
|
Gio.SettingsBindFlags.DEFAULT);
|
||||||
@@ -105,11 +105,14 @@ const QuickPanelOd = GObject.registerClass(
|
|||||||
}
|
}
|
||||||
|
|
||||||
_toggleMode() {
|
_toggleMode() {
|
||||||
asusctlGexInstance.dbus_platform.setPanelOd(!asusctlGexInstance.dbus_platform.bios.panel_overdrive);
|
asusctlGexInstance.dbus_platform.setPanelOd(this.checked);
|
||||||
|
this._sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
_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_power = new Power();
|
||||||
this._dbus_anime = new AnimeDbus();
|
this._dbus_anime = new AnimeDbus();
|
||||||
|
|
||||||
this.dbus_supported.start().then(() => {
|
this.dbus_supported.start();
|
||||||
//@ts-ignore
|
this.dbus_platform.start();
|
||||||
log(`DOOOOOM!, supported =`, this.dbus_supported.supported);
|
this._dbus_power.start();
|
||||||
});
|
this._dbus_anime.start();
|
||||||
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
this._indicateMiniLed = new IndicateMiniLed();
|
this._indicateMiniLed = new IndicateMiniLed();
|
||||||
|
this._indicateMiniLed.checked = this.dbus_platform.bios.mini_led_mode;
|
||||||
this._indicatePanelOd = new IndicatePanelOd();
|
this._indicatePanelOd = new IndicatePanelOd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ export class Platform extends DbusBase {
|
|||||||
public getPostBootSound() {
|
public getPostBootSound() {
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
try {
|
try {
|
||||||
let currentState = this.dbus_proxy.PostBootSoundSync();
|
this.bios.post_sound = this.dbus_proxy.PostBootSoundSync() == 'true' ? true : false;
|
||||||
this.bios.post_sound = parseInt(currentState) == 1 ? true : false;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Failed to get POST Boot Sound state!`, e);
|
log(`Failed to get POST Boot Sound state!`, e);
|
||||||
@@ -51,8 +50,7 @@ export class Platform extends DbusBase {
|
|||||||
public getGpuMuxMode() {
|
public getGpuMuxMode() {
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
try {
|
try {
|
||||||
let currentState = this.dbus_proxy.GpuMuxModeSync();
|
this.bios.gpu_mux = this.dbus_proxy.GpuMuxModeSync() == 'true' ? true : false;
|
||||||
this.bios.gpu_mux = parseInt(currentState) == 0 ? true : false;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Failed to get MUX state!`, e);
|
log(`Failed to get MUX state!`, e);
|
||||||
@@ -78,8 +76,7 @@ export class Platform extends DbusBase {
|
|||||||
public getPanelOd() {
|
public getPanelOd() {
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
try {
|
try {
|
||||||
let currentState = this.dbus_proxy.PanelOdSync();
|
this.bios.panel_overdrive = this.dbus_proxy.PanelOdSync() == 'true' ? true : false;
|
||||||
this.bios.panel_overdrive = parseInt(currentState) == 1 ? true : false;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Failed to get Overdrive state!`, e);
|
log(`Failed to get Overdrive state!`, e);
|
||||||
@@ -105,14 +102,12 @@ export class Platform extends DbusBase {
|
|||||||
public getMiniLedMode() {
|
public getMiniLedMode() {
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
try {
|
try {
|
||||||
this.bios.mini_led_mode = this.dbus_proxy.MiniLedModeSync();
|
this.bios.mini_led_mode = this.dbus_proxy.MiniLedModeSync() == 'true' ? true : false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Failed to get Overdrive state!`, e);
|
log(`Failed to get Overdrive state!`, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@ts-ignore
|
|
||||||
log(`MINI LED MODE: !`, this.bios.mini_led_mode);
|
|
||||||
return this.bios.mini_led_mode;
|
return this.bios.mini_led_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +129,7 @@ export class Platform extends DbusBase {
|
|||||||
try {
|
try {
|
||||||
await super.start();
|
await super.start();
|
||||||
|
|
||||||
this.bios.post_sound = this.getPostBootSound();
|
this.getPostBootSound();
|
||||||
this.dbus_proxy.connectSignal(
|
this.dbus_proxy.connectSignal(
|
||||||
"NotifyPostBootSound",
|
"NotifyPostBootSound",
|
||||||
(proxy: any = null, _name: string, data: boolean) => {
|
(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(
|
this.dbus_proxy.connectSignal(
|
||||||
"NotifyPanelOd",
|
"NotifyPanelOd",
|
||||||
(proxy: any = null, _name: string, data: boolean) => {
|
(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(
|
this.dbus_proxy.connectSignal(
|
||||||
"NotifyMiniLedMode",
|
"NotifyMiniLedMode",
|
||||||
(proxy: any = null, _name: string, data: boolean) => {
|
(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(
|
this.dbus_proxy.connectSignal(
|
||||||
"NotifyGpuMuxMode",
|
"NotifyGpuMuxMode",
|
||||||
(proxy: any = null, _name: string, data: boolean) => {
|
(proxy: any = null, _name: string, data: boolean) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user