mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
gex: add eslint, cleanup parsing of some stuff
This commit is contained in:
22
desktop-extensions/gnome/.eslintrc.cjs
Normal file
22
desktop-extensions/gnome/.eslintrc.cjs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/* eslint-env node */
|
||||||
|
module.exports = {
|
||||||
|
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
||||||
|
parser: "@typescript-eslint/parser",
|
||||||
|
plugins: ["@typescript-eslint"],
|
||||||
|
root: true,
|
||||||
|
|
||||||
|
"rules": {
|
||||||
|
// enable additional rules
|
||||||
|
"indent": ["error", 4],
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
"quotes": ["error", "double"],
|
||||||
|
"semi": ["error", "always"],
|
||||||
|
|
||||||
|
// override configuration set by extending "eslint:recommended"
|
||||||
|
"no-empty": "warn",
|
||||||
|
"no-cond-assign": ["error", "always"],
|
||||||
|
|
||||||
|
// disable rules from base configurations
|
||||||
|
"for-direction": "off",
|
||||||
|
}
|
||||||
|
};
|
||||||
2122
desktop-extensions/gnome/package-lock.json
generated
2122
desktop-extensions/gnome/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -10,11 +10,12 @@
|
|||||||
"validate": "tsc --noEmit"
|
"validate": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
||||||
|
"@typescript-eslint/parser": "^5.60.1",
|
||||||
"adm-zip": "^0.5.10",
|
"adm-zip": "^0.5.10",
|
||||||
"esbuild": "^0.17.19",
|
"esbuild": "^0.17.19",
|
||||||
"typescript": "^5.0.4"
|
"eslint": "^8.44.0",
|
||||||
},
|
"typescript": "^5.1.6"
|
||||||
"dependencies": {
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -1,20 +1,15 @@
|
|||||||
declare const imports: any;
|
|
||||||
var extensionInstance: any;
|
|
||||||
//@ts-ignore
|
|
||||||
// const Me = imports.misc.extensionUtils.getCurrentExtension();
|
|
||||||
|
|
||||||
// REF: https://gjs.guide/extensions/development/creating.html
|
// REF: https://gjs.guide/extensions/development/creating.html
|
||||||
|
|
||||||
import { AnimeDbus } from './modules/dbus/animatrix';
|
import { AnimeDbus } from "./modules/dbus/animatrix";
|
||||||
import { Power } from './modules/dbus/power';
|
import { Power } from "./modules/dbus/power";
|
||||||
import { Supported } from './modules/dbus/supported';
|
import { Supported } from "./modules/dbus/supported";
|
||||||
import { Platform } from './modules/dbus/platform';
|
import { Platform } from "./modules/dbus/platform";
|
||||||
|
|
||||||
import { QuickPanelOd } from './modules/quick_toggles/panel_od';
|
import { QuickPanelOd } from "./modules/quick_toggles/panel_od";
|
||||||
import { IndicateMiniLed } from './modules/indicators/mini_led';
|
import { IndicateMiniLed } from "./modules/indicators/mini_led";
|
||||||
import { QuickMiniLed } from './modules/quick_toggles/mini_led';
|
import { QuickMiniLed } from "./modules/quick_toggles/mini_led";
|
||||||
import { SliderChargeLevel } from './modules/sliders/charge';
|
import { SliderChargeLevel } from "./modules/sliders/charge";
|
||||||
import { QuickAnimePower } from './modules/quick_toggles/anime_power';
|
import { QuickAnimePower } from "./modules/quick_toggles/anime_power";
|
||||||
|
|
||||||
class Extension {
|
class Extension {
|
||||||
private _indicateMiniLed: typeof IndicateMiniLed;
|
private _indicateMiniLed: typeof IndicateMiniLed;
|
||||||
@@ -103,8 +98,7 @@ class Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@ts-ignore
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
function init() {
|
function init() {
|
||||||
extensionInstance = new Extension();
|
return new Extension();
|
||||||
return extensionInstance;
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
declare const imports: any;
|
import { DbusBase } from "./base";
|
||||||
//@ts-ignore
|
import { DeviceState, AnimBooting, Brightness, AnimAwake, AnimSleeping, AnimShutdown } from "../../bindings/anime";
|
||||||
const Me = imports.misc.extensionUtils.getCurrentExtension();
|
|
||||||
|
|
||||||
import { DbusBase } from './base';
|
|
||||||
import { DeviceState, AnimBooting, Brightness, AnimAwake, AnimSleeping, AnimShutdown } from '../../bindings/anime';
|
|
||||||
|
|
||||||
export class AnimeDbus extends DbusBase {
|
export class AnimeDbus extends DbusBase {
|
||||||
deviceState: DeviceState = {
|
deviceState: DeviceState = {
|
||||||
@@ -19,7 +15,7 @@ export class AnimeDbus extends DbusBase {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super('org-asuslinux-anime-4', '/org/asuslinux/Anime');
|
super("org-asuslinux-anime-4", "/org/asuslinux/Anime");
|
||||||
}
|
}
|
||||||
|
|
||||||
public setEnableDisplay(state: boolean | null) {
|
public setEnableDisplay(state: boolean | null) {
|
||||||
@@ -34,7 +30,7 @@ export class AnimeDbus extends DbusBase {
|
|||||||
return this.dbus_proxy.SetEnableDisplaySync(state);
|
return this.dbus_proxy.SetEnableDisplaySync(state);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`AniMe DBus set power failed!`, e);
|
log("AniMe DBus set power failed!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,73 +44,47 @@ export class AnimeDbus extends DbusBase {
|
|||||||
return this.dbus_proxy.SetBrightnessSync(brightness);
|
return this.dbus_proxy.SetBrightnessSync(brightness);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`AniMe DBus set brightness failed!`, e);
|
log("AniMe DBus set brightness failed!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_parseData(data: any) {
|
||||||
|
if (data.length > 0) {
|
||||||
|
this.deviceState.display_enabled = data[0];
|
||||||
|
this.deviceState.display_brightness = Brightness[data[1] as Brightness];
|
||||||
|
this.deviceState.builtin_anims_enabled = data[2];
|
||||||
|
this.deviceState.builtin_anims.boot = AnimBooting[data[3][0] as AnimBooting];
|
||||||
|
this.deviceState.builtin_anims.awake = AnimAwake[data[3][1] as AnimAwake];
|
||||||
|
this.deviceState.builtin_anims.sleep = AnimSleeping[data[3][2] as AnimSleeping];
|
||||||
|
this.deviceState.builtin_anims.shutdown = AnimShutdown[data[3][2] as AnimShutdown];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public getDeviceState() {
|
public getDeviceState() {
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
try {
|
try {
|
||||||
let _data = this.dbus_proxy.DeviceStateSync();
|
// janky shit going on with DeviceStateSync
|
||||||
if (_data.length > 0) {
|
this._parseData(this.dbus_proxy.DeviceStateSync());
|
||||||
this.deviceState.display_enabled = _data[0];
|
|
||||||
this.deviceState.display_brightness = Brightness[_data[1] as Brightness];
|
|
||||||
this.deviceState.builtin_anims_enabled = _data[2];
|
|
||||||
this.deviceState.builtin_anims.boot = AnimBooting[_data[3][0] as AnimBooting];
|
|
||||||
this.deviceState.builtin_anims.awake = AnimAwake[_data[3][1] as AnimAwake];
|
|
||||||
this.deviceState.builtin_anims.sleep = AnimSleeping[_data[3][2] as AnimSleeping];
|
|
||||||
this.deviceState.builtin_anims.shutdown = AnimShutdown[_data[3][2] as AnimShutdown];
|
|
||||||
// this._parseDeviceStateString(_data);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Failed to fetch DeviceState!`, e);
|
log("Failed to fetch DeviceState!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.deviceState;
|
return this.deviceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
_parseDeviceStateString(input: String) {
|
|
||||||
let valueString: string = '';
|
|
||||||
|
|
||||||
for (const [_key, value] of Object.entries(input)) {
|
|
||||||
//@ts-ignore
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
await super.start();
|
await super.start();
|
||||||
this.getDeviceState();
|
this.getDeviceState();
|
||||||
|
|
||||||
this.dbus_proxy.connectSignal(
|
this.dbus_proxy.connectSignal(
|
||||||
"NotifyDeviceState",
|
"NotifyDeviceState",
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(proxy: any = null, name: string, data: string) => {
|
(proxy: any = null, name: string, data: string) => {
|
||||||
if (proxy) {
|
if (proxy) {
|
||||||
this._parseDeviceStateString(data);
|
// idiot xml parsing mneans the get is not nested while this is
|
||||||
//@ts-ignore
|
this._parseData(data[0]);
|
||||||
log(`NotifyDeviceState has changed to ${data}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
declare const imports: any;
|
declare const imports: any;
|
||||||
//@ts-ignore
|
|
||||||
const Me = imports.misc.extensionUtils.getCurrentExtension();
|
|
||||||
|
|
||||||
import * as Resources from '../resources';
|
import * as Resources from "../resources";
|
||||||
|
|
||||||
const { Gio } = imports.gi;
|
const { Gio } = imports.gi;
|
||||||
|
|
||||||
export class DbusBase {
|
export class DbusBase {
|
||||||
dbus_proxy: any = null; // type: Gio.DbusProxy
|
dbus_proxy: any = null; // type: Gio.DbusProxy
|
||||||
connected: boolean = false;
|
connected = false;
|
||||||
xml_resource: string = '';
|
xml_resource = "";
|
||||||
dbus_path: string = '';
|
dbus_path = "";
|
||||||
|
|
||||||
constructor(resource: string, dbus_path: string) {
|
constructor(resource: string, dbus_path: string) {
|
||||||
this.xml_resource = resource;
|
this.xml_resource = resource;
|
||||||
@@ -21,10 +19,10 @@ export class DbusBase {
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Starting ${this.dbus_path} dbus module`);
|
log(`Starting ${this.dbus_path} dbus module`);
|
||||||
try {
|
try {
|
||||||
let xml = Resources.File.DBus(this.xml_resource);
|
const xml = Resources.File.DBus(this.xml_resource);
|
||||||
this.dbus_proxy = new Gio.DBusProxy.makeProxyWrapper(xml)(
|
this.dbus_proxy = new Gio.DBusProxy.makeProxyWrapper(xml)(
|
||||||
Gio.DBus.system,
|
Gio.DBus.system,
|
||||||
'org.asuslinux.Daemon',
|
"org.asuslinux.Daemon",
|
||||||
this.dbus_path,
|
this.dbus_path,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -33,7 +31,7 @@ export class DbusBase {
|
|||||||
log(`${this.dbus_path} client started successfully.`);
|
log(`${this.dbus_path} client started successfully.`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`${this.xml_resource} dbus init failed!`, e);
|
logError(`${this.xml_resource} dbus init failed!`, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
declare const imports: any;
|
import * as bios from "../../bindings/platform";
|
||||||
//@ts-ignore
|
import { DbusBase } from "./base";
|
||||||
const Me = imports.misc.extensionUtils.getCurrentExtension();
|
|
||||||
|
|
||||||
import * as bios from '../../bindings/platform';
|
|
||||||
import { DbusBase } from './base';
|
|
||||||
|
|
||||||
// TODO: add callbacks for notifications
|
// TODO: add callbacks for notifications
|
||||||
export class Platform extends DbusBase {
|
export class Platform extends DbusBase {
|
||||||
@@ -14,19 +10,19 @@ export class Platform extends DbusBase {
|
|||||||
dgpu_disable: false,
|
dgpu_disable: false,
|
||||||
egpu_enable: false,
|
egpu_enable: false,
|
||||||
mini_led_mode: false
|
mini_led_mode: false
|
||||||
}
|
};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super('org-asuslinux-platform-4', '/org/asuslinux/Platform');
|
super("org-asuslinux-platform-4", "/org/asuslinux/Platform");
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPostBootSound() {
|
public getPostBootSound() {
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
try {
|
try {
|
||||||
this.bios.post_sound = this.dbus_proxy.PostBootSoundSync() == 'true' ? true : false;
|
this.bios.post_sound = this.dbus_proxy.PostBootSoundSync() == "true" ? 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.bios.post_sound;
|
return this.bios.post_sound;
|
||||||
@@ -41,7 +37,7 @@ export class Platform extends DbusBase {
|
|||||||
return this.dbus_proxy.SetPostBootSoundSync(state);
|
return this.dbus_proxy.SetPostBootSoundSync(state);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Platform DBus set Post Boot Sound failed!`, e);
|
log("Platform DBus set Post Boot Sound failed!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,10 +45,10 @@ export class Platform extends DbusBase {
|
|||||||
public getGpuMuxMode() {
|
public getGpuMuxMode() {
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
try {
|
try {
|
||||||
this.bios.gpu_mux = this.dbus_proxy.GpuMuxModeSync() == 'true' ? true : false;
|
this.bios.gpu_mux = this.dbus_proxy.GpuMuxModeSync() == "true" ? true : false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Failed to get MUX state!`, e);
|
log("Failed to get MUX state!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.bios.gpu_mux;
|
return this.bios.gpu_mux;
|
||||||
@@ -67,7 +63,7 @@ export class Platform extends DbusBase {
|
|||||||
return this.dbus_proxy.SetGpuMuxModeSync(!state);
|
return this.dbus_proxy.SetGpuMuxModeSync(!state);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Switching the MUX failed!`, e);
|
log("Switching the MUX failed!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,10 +71,10 @@ export class Platform extends DbusBase {
|
|||||||
public getPanelOd() {
|
public getPanelOd() {
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
try {
|
try {
|
||||||
this.bios.panel_overdrive = this.dbus_proxy.PanelOdSync() == 'true' ? true : false;
|
this.bios.panel_overdrive = this.dbus_proxy.PanelOdSync() == "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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.bios.panel_overdrive;
|
return this.bios.panel_overdrive;
|
||||||
@@ -93,7 +89,7 @@ export class Platform extends DbusBase {
|
|||||||
return this.dbus_proxy.SetPanelOdSync(state);
|
return this.dbus_proxy.SetPanelOdSync(state);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Overdrive DBus set overdrive state failed!`, e);
|
log("Overdrive DBus set overdrive state failed!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,10 +97,10 @@ 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() == 'true' ? true : false;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.bios.mini_led_mode;
|
return this.bios.mini_led_mode;
|
||||||
@@ -119,7 +115,7 @@ export class Platform extends DbusBase {
|
|||||||
return this.dbus_proxy.SetMiniLedModeSync(state);
|
return this.dbus_proxy.SetMiniLedModeSync(state);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`setMiniLedMode failed!`, e);
|
log("setMiniLedMode failed!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +170,7 @@ export class Platform extends DbusBase {
|
|||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Platform DBus init failed!`, e);
|
log("Platform DBus init failed!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
declare const imports: any;
|
import { DbusBase } from "./base";
|
||||||
//@ts-ignore
|
|
||||||
const Me = imports.misc.extensionUtils.getCurrentExtension();
|
|
||||||
|
|
||||||
import { DbusBase } from './base';
|
|
||||||
|
|
||||||
// function getMethods(obj: { [x: string]: { toString: () => string; }; }) {
|
// function getMethods(obj: { [x: string]: { toString: () => string; }; }) {
|
||||||
// var result = [];
|
// var result = [];
|
||||||
@@ -19,11 +15,11 @@ import { DbusBase } from './base';
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
export class Power extends DbusBase {
|
export class Power extends DbusBase {
|
||||||
chargeLimit: number = 100;
|
chargeLimit = 100;
|
||||||
mainsOnline = false;
|
mainsOnline = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super('org-asuslinux-power-4', '/org/asuslinux/Power');
|
super("org-asuslinux-power-4", "/org/asuslinux/Power");
|
||||||
}
|
}
|
||||||
|
|
||||||
public getChargingLimit() {
|
public getChargingLimit() {
|
||||||
@@ -32,7 +28,7 @@ export class Power extends DbusBase {
|
|||||||
this.chargeLimit = this.dbus_proxy.ChargeControlEndThresholdSync();
|
this.chargeLimit = this.dbus_proxy.ChargeControlEndThresholdSync();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Failed to fetch Charging Limit!`, e);
|
log("Failed to fetch Charging Limit!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.chargeLimit;
|
return this.chargeLimit;
|
||||||
@@ -48,7 +44,7 @@ export class Power extends DbusBase {
|
|||||||
return this.dbus_proxy.SetChargeControlEndThresholdSync(limit);
|
return this.dbus_proxy.SetChargeControlEndThresholdSync(limit);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Profile DBus set power profile failed!`, e);
|
log("Profile DBus set power profile failed!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,7 +55,7 @@ export class Power extends DbusBase {
|
|||||||
this.mainsOnline = this.dbus_proxy.MainsOnlineSync();
|
this.mainsOnline = this.dbus_proxy.MainsOnlineSync();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Failed to fetch MainsLonline!`, e);
|
log("Failed to fetch MainsLonline!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.mainsOnline;
|
return this.mainsOnline;
|
||||||
@@ -93,7 +89,7 @@ export class Power extends DbusBase {
|
|||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Charging Limit DBus initialization failed!`, e);
|
log("Charging Limit DBus initialization failed!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,136 +1,103 @@
|
|||||||
declare const global: any, imports: any;
|
import { SupportedFunctions, AdvancedAura } from "../../bindings/platform";
|
||||||
//@ts-ignore
|
import { AuraDevice, AuraModeNum, AuraZone } from "../../bindings/aura";
|
||||||
const Me = imports.misc.extensionUtils.getCurrentExtension();
|
import { DbusBase } from "./base";
|
||||||
|
|
||||||
import { SupportedFunctions, AdvancedAura } from '../../bindings/platform';
|
|
||||||
import { AuraDevice, AuraModeNum, AuraZone } from '../../bindings/aura';
|
|
||||||
import { DbusBase } from './base';
|
|
||||||
|
|
||||||
export class Supported extends DbusBase {
|
export class Supported extends DbusBase {
|
||||||
// False,
|
// False,
|
||||||
// (True,),
|
// (True,),
|
||||||
// (True, True),
|
// (True, True),
|
||||||
// ('X19b6',
|
// ('X19b6',
|
||||||
// True,
|
// True,
|
||||||
// ['Static',
|
// ['Static',
|
||||||
// 'Breathe',
|
// 'Breathe',
|
||||||
// 'Strobe',
|
// 'Strobe',
|
||||||
// 'Rainbow',
|
// 'Rainbow',
|
||||||
// 'Star',
|
// 'Star',
|
||||||
// 'Rain',
|
// 'Rain',
|
||||||
// 'Highlight',
|
// 'Highlight',
|
||||||
// 'Laser',
|
// 'Laser',
|
||||||
// 'Ripple',
|
// 'Ripple',
|
||||||
// 'Pulse',
|
// 'Pulse',
|
||||||
// 'Comet',
|
// 'Comet',
|
||||||
// 'Flash'],
|
// 'Flash'],
|
||||||
// [],
|
// [],
|
||||||
// 2),
|
// 2),
|
||||||
// (False, True, True, True, False, True)
|
// (False, True, True, True, False, True)
|
||||||
|
|
||||||
supported: SupportedFunctions = {
|
supported: SupportedFunctions = {
|
||||||
anime_ctrl: false,
|
anime_ctrl: false,
|
||||||
charge_ctrl: {
|
charge_ctrl: {
|
||||||
charge_level_set: false
|
charge_level_set: false
|
||||||
},
|
},
|
||||||
platform_profile: {
|
platform_profile: {
|
||||||
platform_profile: false,
|
platform_profile: false,
|
||||||
fan_curves: false
|
fan_curves: false
|
||||||
},
|
},
|
||||||
keyboard_led: {
|
keyboard_led: {
|
||||||
dev_id: AuraDevice.Unknown,
|
dev_id: AuraDevice.Unknown,
|
||||||
brightness: false,
|
brightness: false,
|
||||||
basic_modes: [],
|
basic_modes: [],
|
||||||
basic_zones: [],
|
basic_zones: [],
|
||||||
advanced_type: AdvancedAura.None
|
advanced_type: AdvancedAura.None
|
||||||
},
|
},
|
||||||
rog_bios_ctrl: {
|
rog_bios_ctrl: {
|
||||||
post_sound: false,
|
post_sound: false,
|
||||||
gpu_mux: false,
|
gpu_mux: false,
|
||||||
panel_overdrive: false,
|
panel_overdrive: false,
|
||||||
dgpu_disable: false,
|
dgpu_disable: false,
|
||||||
egpu_enable: false,
|
egpu_enable: false,
|
||||||
mini_led_mode: false
|
mini_led_mode: false
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super('org-asuslinux-supported-4', '/org/asuslinux/Supported');
|
|
||||||
}
|
|
||||||
|
|
||||||
public getSupported() {
|
|
||||||
if (this.isRunning()) {
|
|
||||||
try {
|
|
||||||
let _supportedAttributes = this.dbus_proxy.SupportedFunctionsSync();
|
|
||||||
if (_supportedAttributes.length > 0) {
|
|
||||||
let valueString: string = '';
|
|
||||||
|
|
||||||
for (const [_key, value] of Object.entries(_supportedAttributes)) {
|
|
||||||
//@ts-ignore
|
|
||||||
valueString = value.toString();
|
|
||||||
|
|
||||||
switch (parseInt(_key)) {
|
|
||||||
case 0:
|
|
||||||
this.supported.anime_ctrl = (valueString == 'true' ? true : false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
this.supported.charge_ctrl.charge_level_set = (valueString == 'true' ? true : false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
let platformArray = valueString.split(',');
|
|
||||||
this.supported.platform_profile.fan_curves = (platformArray[0] == 'true' ? true : false);
|
|
||||||
this.supported.platform_profile.platform_profile = (platformArray[1] == 'true' ? true : false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
let ledArray = valueString.split(',');
|
|
||||||
// let t: keyof typeof AuraDevice = ledArray[0]; // can't conevert
|
|
||||||
this.supported.keyboard_led.dev_id = AuraDevice[ledArray[0] as AuraDevice];
|
|
||||||
this.supported.keyboard_led.brightness = (ledArray[1] == 'true' ? true : false);
|
|
||||||
this.supported.keyboard_led.basic_modes = ledArray[2].split(',').map(function (value) {
|
|
||||||
return AuraModeNum[value as AuraModeNum]
|
|
||||||
});
|
|
||||||
this.supported.keyboard_led.basic_zones = ledArray[3].split(',').map(function (value) {
|
|
||||||
return AuraZone[value as AuraZone]
|
|
||||||
});
|
|
||||||
this.supported.keyboard_led.advanced_type = AdvancedAura[ledArray[4] as AdvancedAura];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
let biosArray = valueString.split(',');
|
|
||||||
this.supported.rog_bios_ctrl.post_sound = (biosArray[0] == 'true' ? true : false);
|
|
||||||
this.supported.rog_bios_ctrl.gpu_mux = (biosArray[1] == 'true' ? true : false);
|
|
||||||
this.supported.rog_bios_ctrl.panel_overdrive = (biosArray[2] == 'true' ? true : false);
|
|
||||||
this.supported.rog_bios_ctrl.dgpu_disable = (biosArray[3] == 'true' ? true : false);
|
|
||||||
this.supported.rog_bios_ctrl.egpu_enable = (biosArray[4] == 'true' ? true : false);
|
|
||||||
this.supported.rog_bios_ctrl.mini_led_mode = (biosArray[5] == 'true' ? true : false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
};
|
||||||
//@ts-ignore
|
|
||||||
log(`Failed to fetch supported functionalities`, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async start() {
|
constructor() {
|
||||||
try {
|
super("org-asuslinux-supported-4", "/org/asuslinux/Supported");
|
||||||
await super.start();
|
|
||||||
this.getSupported();
|
|
||||||
} catch (e) {
|
|
||||||
//@ts-ignore
|
|
||||||
log(`Supported DBus initialization failed!`, e);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async stop() {
|
public getSupported() {
|
||||||
await super.stop()
|
if (this.isRunning()) {
|
||||||
}
|
try {
|
||||||
|
const _data = this.dbus_proxy.SupportedFunctionsSync();
|
||||||
|
this.supported.anime_ctrl = _data[0];
|
||||||
|
this.supported.charge_ctrl.charge_level_set = _data[1];
|
||||||
|
this.supported.platform_profile.platform_profile = _data[2][0];
|
||||||
|
this.supported.platform_profile.fan_curves = _data[2][1];
|
||||||
|
this.supported.keyboard_led.dev_id = AuraDevice[_data[3][0] as AuraDevice];
|
||||||
|
this.supported.keyboard_led.brightness = _data[3][1];
|
||||||
|
|
||||||
|
this.supported.keyboard_led.basic_modes = _data[3][2].map(function (value: string) {
|
||||||
|
return AuraModeNum[value as AuraModeNum];
|
||||||
|
});
|
||||||
|
|
||||||
|
this.supported.keyboard_led.basic_zones = _data[3][3].map(function (value: string) {
|
||||||
|
return AuraZone[value as AuraZone];
|
||||||
|
});
|
||||||
|
this.supported.keyboard_led.advanced_type = AdvancedAura[_data[3][4] as AdvancedAura];
|
||||||
|
|
||||||
|
this.supported.rog_bios_ctrl.post_sound = _data[4][0];
|
||||||
|
this.supported.rog_bios_ctrl.gpu_mux = _data[4][1];
|
||||||
|
this.supported.rog_bios_ctrl.panel_overdrive = _data[4][2];
|
||||||
|
this.supported.rog_bios_ctrl.dgpu_disable = _data[4][3];
|
||||||
|
this.supported.rog_bios_ctrl.egpu_enable = _data[4][4];
|
||||||
|
this.supported.rog_bios_ctrl.mini_led_mode = _data[4][5];
|
||||||
|
} catch (e) {
|
||||||
|
//@ts-ignore
|
||||||
|
log("Failed to fetch supported functionalities", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async start() {
|
||||||
|
try {
|
||||||
|
await super.start();
|
||||||
|
this.getSupported();
|
||||||
|
} catch (e) {
|
||||||
|
//@ts-ignore
|
||||||
|
log("Supported DBus initialization failed!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async stop() {
|
||||||
|
await super.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -14,12 +14,12 @@ export const IndicateMiniLed = GObject.registerClass(
|
|||||||
|
|
||||||
// Create the icon for the indicator
|
// Create the icon for the indicator
|
||||||
this._indicator = this._addIndicator();
|
this._indicator = this._addIndicator();
|
||||||
this._indicator.icon_name = 'selection-mode-symbolic';
|
this._indicator.icon_name = "selection-mode-symbolic";
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
// Add the indicator to the panel and the toggle to the menu
|
// Add the indicator to the panel and the toggle to the menu
|
||||||
|
|||||||
@@ -14,25 +14,25 @@ export const QuickAnimePower = GObject.registerClass(
|
|||||||
|
|
||||||
constructor(dbus_anime: AnimeDbus) {
|
constructor(dbus_anime: AnimeDbus) {
|
||||||
super({
|
super({
|
||||||
title: 'AniMatrix Power',
|
title: "AniMatrix Power",
|
||||||
iconName: 'selection-mode-symbolic',
|
iconName: "selection-mode-symbolic",
|
||||||
toggleMode: true,
|
toggleMode: true,
|
||||||
});
|
});
|
||||||
this._dbus_anime = dbus_anime;
|
this._dbus_anime = dbus_anime;
|
||||||
this.label = 'AniMatrix Power';
|
this.label = "AniMatrix Power";
|
||||||
this._settings = ExtensionUtils.getSettings();
|
this._settings = ExtensionUtils.getSettings();
|
||||||
|
|
||||||
this.connectObject(
|
this.connectObject(
|
||||||
'destroy', () => this._settings.run_dispose(),
|
"destroy", () => this._settings.run_dispose(),
|
||||||
'clicked', () => this._toggleMode(),
|
"clicked", () => this._toggleMode(),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
this.connect('destroy', () => {
|
this.connect("destroy", () => {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
this._settings.bind('anime-power',
|
this._settings.bind("anime-power",
|
||||||
this, 'checked',
|
this, "checked",
|
||||||
Gio.SettingsBindFlags.DEFAULT);
|
Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
this._sync();
|
this._sync();
|
||||||
|
|||||||
@@ -14,25 +14,25 @@ export const QuickMiniLed = GObject.registerClass(
|
|||||||
|
|
||||||
constructor(dbus_platform: Platform) {
|
constructor(dbus_platform: Platform) {
|
||||||
super({
|
super({
|
||||||
title: 'MiniLED',
|
title: "MiniLED",
|
||||||
iconName: 'selection-mode-symbolic',
|
iconName: "selection-mode-symbolic",
|
||||||
toggleMode: true,
|
toggleMode: true,
|
||||||
});
|
});
|
||||||
this._dbus_platform = dbus_platform;
|
this._dbus_platform = dbus_platform;
|
||||||
this.label = 'MiniLED';
|
this.label = "MiniLED";
|
||||||
this._settings = ExtensionUtils.getSettings();
|
this._settings = ExtensionUtils.getSettings();
|
||||||
|
|
||||||
this.connectObject(
|
this.connectObject(
|
||||||
'destroy', () => this._settings.run_dispose(),
|
"destroy", () => this._settings.run_dispose(),
|
||||||
'clicked', () => this._toggleMode(),
|
"clicked", () => this._toggleMode(),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
this.connect('destroy', () => {
|
this.connect("destroy", () => {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
this._settings.bind('mini-led-enabled',
|
this._settings.bind("mini-led-enabled",
|
||||||
this, 'checked',
|
this, "checked",
|
||||||
Gio.SettingsBindFlags.DEFAULT);
|
Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
this._sync();
|
this._sync();
|
||||||
|
|||||||
@@ -14,25 +14,25 @@ export const QuickPanelOd = GObject.registerClass(
|
|||||||
|
|
||||||
constructor(dbus_platform: Platform) {
|
constructor(dbus_platform: Platform) {
|
||||||
super({
|
super({
|
||||||
title: 'Panel Overdrive',
|
title: "Panel Overdrive",
|
||||||
iconName: 'selection-mode-symbolic',
|
iconName: "selection-mode-symbolic",
|
||||||
toggleMode: true,
|
toggleMode: true,
|
||||||
});
|
});
|
||||||
this._dbus_platform = dbus_platform;
|
this._dbus_platform = dbus_platform;
|
||||||
this.label = 'Panel Overdrive';
|
this.label = "Panel Overdrive";
|
||||||
this._settings = ExtensionUtils.getSettings();
|
this._settings = ExtensionUtils.getSettings();
|
||||||
|
|
||||||
this.connectObject(
|
this.connectObject(
|
||||||
'destroy', () => this._settings.run_dispose(),
|
"destroy", () => this._settings.run_dispose(),
|
||||||
'clicked', () => this._toggleMode(),
|
"clicked", () => this._toggleMode(),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
this.connect('destroy', () => {
|
this.connect("destroy", () => {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
this._settings.bind('panel-od-enabled',
|
this._settings.bind("panel-od-enabled",
|
||||||
this, 'checked',
|
this, "checked",
|
||||||
Gio.SettingsBindFlags.DEFAULT);
|
Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
this._sync();
|
this._sync();
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
declare const global: any, imports: any;
|
declare const imports: any;
|
||||||
//@ts-ignore
|
const Me = imports.misc.extensionUtils.getCurrentExtension();
|
||||||
const ThisModule = imports.misc.extensionUtils.getCurrentExtension();
|
|
||||||
|
|
||||||
const GLib = imports.gi.GLib;
|
const GLib = imports.gi.GLib;
|
||||||
|
|
||||||
export class File {
|
export class File {
|
||||||
public static DBus(name: string) {
|
public static DBus(name: string) {
|
||||||
let file = `${ThisModule.path}/resources/dbus/${name}.xml`;
|
const file = `${Me.path}/resources/dbus/${name}.xml`;
|
||||||
try {
|
try {
|
||||||
let [_ok, bytes] = GLib.file_get_contents(file)
|
const [_ok, bytes] = GLib.file_get_contents(file);
|
||||||
if (!_ok)
|
if (!_ok)
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(`Couldn't read contents of "${file}"`);
|
log(`Couldn't read contents of "${file}"`);
|
||||||
|
|||||||
@@ -13,21 +13,21 @@ export const SliderChargeLevel = GObject.registerClass(
|
|||||||
|
|
||||||
constructor(dbus_power: Power) {
|
constructor(dbus_power: Power) {
|
||||||
super({
|
super({
|
||||||
iconName: 'selection-mode-symbolic',
|
iconName: "selection-mode-symbolic",
|
||||||
});
|
});
|
||||||
this._dbus_power = dbus_power;
|
this._dbus_power = dbus_power;
|
||||||
|
|
||||||
this._sliderChangedId = this.slider.connect('drag-end',
|
this._sliderChangedId = this.slider.connect("drag-end",
|
||||||
this._onSliderChanged.bind(this));
|
this._onSliderChanged.bind(this));
|
||||||
|
|
||||||
// Binding the slider to a GSettings key
|
// Binding the slider to a GSettings key
|
||||||
this._settings = ExtensionUtils.getSettings();
|
this._settings = ExtensionUtils.getSettings();
|
||||||
|
|
||||||
this._settings.connect('changed::charge-level',
|
this._settings.connect("changed::charge-level",
|
||||||
this._onSettingsChanged.bind(this));
|
this._onSettingsChanged.bind(this));
|
||||||
|
|
||||||
// Set an accessible name for the slider
|
// Set an accessible name for the slider
|
||||||
this.slider.accessible_name = 'Charge level';
|
this.slider.accessible_name = "Charge level";
|
||||||
|
|
||||||
this._sync();
|
this._sync();
|
||||||
this._onSettingsChanged();
|
this._onSettingsChanged();
|
||||||
@@ -38,7 +38,7 @@ export const SliderChargeLevel = GObject.registerClass(
|
|||||||
_onSettingsChanged() {
|
_onSettingsChanged() {
|
||||||
// Prevent the slider from emitting a change signal while being updated
|
// Prevent the slider from emitting a change signal while being updated
|
||||||
this.slider.block_signal_handler(this._sliderChangedId);
|
this.slider.block_signal_handler(this._sliderChangedId);
|
||||||
this.slider.value = this._settings.get_uint('charge-level') / 100.0;
|
this.slider.value = this._settings.get_uint("charge-level") / 100.0;
|
||||||
this.slider.unblock_signal_handler(this._sliderChangedId);
|
this.slider.unblock_signal_handler(this._sliderChangedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,15 +46,15 @@ export const SliderChargeLevel = GObject.registerClass(
|
|||||||
// Assuming our GSettings holds values between 0..100, adjust for the
|
// Assuming our GSettings holds values between 0..100, adjust for the
|
||||||
// slider taking values between 0..1
|
// slider taking values between 0..1
|
||||||
const percent = Math.floor(this.slider.value * 100);
|
const percent = Math.floor(this.slider.value * 100);
|
||||||
const stored = Math.floor(this._settings.get_uint('charge-level') / 100.0);
|
const stored = Math.floor(this._settings.get_uint("charge-level") / 100.0);
|
||||||
if (this.slider.value !== stored)
|
if (this.slider.value !== stored)
|
||||||
this._dbus_power.setChargingLimit(percent);
|
this._dbus_power.setChargingLimit(percent);
|
||||||
this._settings.set_uint('charge-level', percent);
|
this._settings.set_uint("charge-level", percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
_sync() {
|
_sync() {
|
||||||
const value = this._dbus_power.getChargingLimit();
|
const value = this._dbus_power.getChargingLimit();
|
||||||
if (this.slider.value !== value / 100)
|
if (this.slider.value !== value / 100)
|
||||||
this._settings.set_uint('charge-level', value);
|
this._settings.set_uint("charge-level", value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user