gex: trial of dbus mthods

This commit is contained in:
Luke D. Jones
2023-06-29 12:58:11 +12:00
parent fc8879ac24
commit 6b058c9922
16 changed files with 181 additions and 468 deletions

View File

@@ -122,12 +122,15 @@ bindings:
typeshare ./rog-platform/src/ --lang=typescript --output-file=bindings/ts/platform.ts
introspect:
dbus-send --system --type=method_call --print-reply --dest=org.asuslinux.Daemon /org/asuslinux/Aura org.freedesktop.DBus.Introspectable.Introspect > bindings/dbus-xml/org-asuslinux-aura-4.xml
dbus-send --system --type=method_call --print-reply --dest=org.asuslinux.Daemon /org/asuslinux/Anime org.freedesktop.DBus.Introspectable.Introspect > bindings/dbus-xml/org-asuslinux-anime-4.xml
dbus-send --system --type=method_call --print-reply --dest=org.asuslinux.Daemon /org/asuslinux/Platform org.freedesktop.DBus.Introspectable.Introspect > bindings/dbus-xml/org-asuslinux-platform-4.xml
dbus-send --system --type=method_call --print-reply --dest=org.asuslinux.Daemon /org/asuslinux/Power org.freedesktop.DBus.Introspectable.Introspect > bindings/dbus-xml/org-asuslinux-power-4.xml
dbus-send --system --type=method_call --print-reply --dest=org.asuslinux.Daemon /org/asuslinux/Profile org.freedesktop.DBus.Introspectable.Introspect > bindings/dbus-xml/org-asuslinux-profile-4.xml
dbus-send --system --type=method_call --print-reply --dest=org.asuslinux.Daemon /org/asuslinux/Supported org.freedesktop.DBus.Introspectable.Introspect > bindings/dbus-xml/org-asuslinux-supported-4.xml
gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Aura -x > bindings/dbus-xml/org-asuslinux-aura-4.xml
gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Anime -x > bindings/dbus-xml/org-asuslinux-anime-4.xml
gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Platform -x > bindings/dbus-xml/org-asuslinux-platform-4.xml
gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Power -x > bindings/dbus-xml/org-asuslinux-power-4.xml
gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Profile -x > bindings/dbus-xml/org-asuslinux-profile-4.xml
gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Supported -x > bindings/dbus-xml/org-asuslinux-supported-4.xml
xmlstarlet ed -L -O -d '//interface[@name="org.freedesktop.DBus.Introspectable"]' bindings/dbus-xml/org-asuslinux-*
xmlstarlet ed -L -O -d '//interface[@name="org.freedesktop.DBus.Properties"]' bindings/dbus-xml/org-asuslinux-*
xmlstarlet ed -L -O -d '//interface[@name="org.freedesktop.DBus.Peer"]' bindings/dbus-xml/org-asuslinux-*
build:
ifeq ($(VENDORED),1)

View File

@@ -15,8 +15,10 @@ pub struct SupportedFunctions(rog_platform::supported::SupportedFunctions);
#[dbus_interface(name = "org.asuslinux.Daemon")]
impl SupportedFunctions {
pub fn supported_functions(&self) -> &rog_platform::supported::SupportedFunctions {
&self.0
pub fn supported_functions(
&self,
) -> zbus::fdo::Result<&rog_platform::supported::SupportedFunctions> {
Ok(&self.0)
}
#[dbus_interface(out_args("answer", "question"))]

View File

@@ -1,13 +1,5 @@
method return time=1687861003.317863 sender=:1.463 -> destination=:1.470 serial=9 reply_serial=2
string "
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg type="s" direction="out"/>
</method>
</interface>
<interface name="org.asuslinux.Daemon">
<!--
Writes a data stream of length. Will force system thread to exit until
@@ -70,36 +62,4 @@ method return time=1687861003.317863 sender=:1.463 -> destination=:1.470 serial=
<arg name="data" type="(bsb(ssss))"/>
</signal>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg type="v" direction="out"/>
</method>
<method name="Set">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method>
<method name="GetAll">
<arg name="interface_name" type="s" direction="in"/>
<arg type="a{sv}" direction="out"/>
</method>
<!--
Emits the `org.freedesktop.DBus.Properties.PropertiesChanged` signal.
-->
<signal name="PropertiesChanged">
<arg name="interface_name" type="s"/>
<arg name="changed_properties" type="a{sv}"/>
<arg name="invalidated_properties" type="as"/>
</signal>
</interface>
<interface name="org.freedesktop.DBus.Peer">
<method name="Ping">
</method>
<method name="GetMachineId">
<arg type="s" direction="out"/>
</method>
</interface>
</node>
"

View File

@@ -1,32 +1,5 @@
method return time=1687861003.313639 sender=:1.463 -> destination=:1.469 serial=8 reply_serial=2
string "
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg type="v" direction="out"/>
</method>
<method name="Set">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method>
<method name="GetAll">
<arg name="interface_name" type="s" direction="in"/>
<arg type="a{sv}" direction="out"/>
</method>
<!--
Emits the `org.freedesktop.DBus.Properties.PropertiesChanged` signal.
-->
<signal name="PropertiesChanged">
<arg name="interface_name" type="s"/>
<arg name="changed_properties" type="a{sv}"/>
<arg name="invalidated_properties" type="as"/>
</signal>
</interface>
<interface name="org.asuslinux.Daemon">
<!--
Set the keyboard brightness level (0-3)
@@ -130,17 +103,4 @@ method return time=1687861003.313639 sender=:1.463 -> destination=:1.469 serial=
-->
<property name="LedBrightness" type="n" access="read"/>
</interface>
<interface name="org.freedesktop.DBus.Peer">
<method name="Ping">
</method>
<method name="GetMachineId">
<arg type="s" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg type="s" direction="out"/>
</method>
</interface>
</node>
"

View File

@@ -1,7 +1,4 @@
method return time=1687861003.321770 sender=:1.463 -> destination=:1.471 serial=10 reply_serial=2
string "
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.asuslinux.Daemon">
<method name="SetGpuMuxMode">
@@ -67,41 +64,4 @@ method return time=1687861003.321770 sender=:1.463 -> destination=:1.471 serial=
<arg name="enable" type="b"/>
</signal>
</interface>
<interface name="org.freedesktop.DBus.Peer">
<method name="Ping">
</method>
<method name="GetMachineId">
<arg type="s" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg type="v" direction="out"/>
</method>
<method name="Set">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method>
<method name="GetAll">
<arg name="interface_name" type="s" direction="in"/>
<arg type="a{sv}" direction="out"/>
</method>
<!--
Emits the `org.freedesktop.DBus.Properties.PropertiesChanged` signal.
-->
<signal name="PropertiesChanged">
<arg name="interface_name" type="s"/>
<arg name="changed_properties" type="a{sv}"/>
<arg name="invalidated_properties" type="as"/>
</signal>
</interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg type="s" direction="out"/>
</method>
</interface>
</node>
"

View File

@@ -1,13 +1,5 @@
method return time=1687861003.325159 sender=:1.463 -> destination=:1.472 serial=11 reply_serial=2
string "
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg type="s" direction="out"/>
</method>
</interface>
<interface name="org.asuslinux.Daemon">
<method name="SetChargeControlEndThreshold">
<arg name="limit" type="y" direction="in"/>
@@ -25,36 +17,4 @@ method return time=1687861003.325159 sender=:1.463 -> destination=:1.472 serial=
<arg name="on" type="b"/>
</signal>
</interface>
<interface name="org.freedesktop.DBus.Peer">
<method name="Ping">
</method>
<method name="GetMachineId">
<arg type="s" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg type="v" direction="out"/>
</method>
<method name="Set">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method>
<method name="GetAll">
<arg name="interface_name" type="s" direction="in"/>
<arg type="a{sv}" direction="out"/>
</method>
<!--
Emits the `org.freedesktop.DBus.Properties.PropertiesChanged` signal.
-->
<signal name="PropertiesChanged">
<arg name="interface_name" type="s"/>
<arg name="changed_properties" type="a{sv}"/>
<arg name="invalidated_properties" type="as"/>
</signal>
</interface>
</node>
"

View File

@@ -1,32 +1,5 @@
method return time=1687861003.328608 sender=:1.463 -> destination=:1.473 serial=12 reply_serial=2
string "
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg type="v" direction="out"/>
</method>
<method name="Set">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method>
<method name="GetAll">
<arg name="interface_name" type="s" direction="in"/>
<arg type="a{sv}" direction="out"/>
</method>
<!--
Emits the `org.freedesktop.DBus.Properties.PropertiesChanged` signal.
-->
<signal name="PropertiesChanged">
<arg name="interface_name" type="s"/>
<arg name="changed_properties" type="a{sv}"/>
<arg name="invalidated_properties" type="as"/>
</signal>
</interface>
<interface name="org.asuslinux.Daemon">
<!--
Fetch profile names
@@ -104,17 +77,4 @@ method return time=1687861003.328608 sender=:1.463 -> destination=:1.473 serial=
<arg name="profile" type="s"/>
</signal>
</interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg type="s" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Peer">
<method name="Ping">
</method>
<method name="GetMachineId">
<arg type="s" direction="out"/>
</method>
</interface>
</node>
"

View File

@@ -1,52 +1,12 @@
method return time=1687945851.162246 sender=:1.3354 -> destination=:1.3359 serial=8 reply_serial=2
string "
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.DBus.Peer">
<method name="Ping">
</method>
<method name="GetMachineId">
<arg type="s" direction="out"/>
</method>
</interface>
<interface name="org.asuslinux.Daemon">
<method name="SupportedFunctions">
<arg type="(b(b)(bb)(sbasass)(bbbbbb))" direction="out"/>
<arg type="b(b)(bb)(sbasass)(bbbbbb)" direction="out"/>
</method>
<method name="MeaningOfLife">
<arg name="answer" type="i" direction="out"/>
<arg name="question" type="s" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg type="v" direction="out"/>
</method>
<method name="Set">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method>
<method name="GetAll">
<arg name="interface_name" type="s" direction="in"/>
<arg type="a{sv}" direction="out"/>
</method>
<!--
Emits the `org.freedesktop.DBus.Properties.PropertiesChanged` signal.
-->
<signal name="PropertiesChanged">
<arg name="interface_name" type="s"/>
<arg name="changed_properties" type="a{sv}"/>
<arg name="invalidated_properties" type="as"/>
</signal>
</interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg type="s" direction="out"/>
</method>
</interface>
</node>
"

View File

@@ -2,9 +2,11 @@
rm -rf _build
mkdir -p _build/modules
mkdir -p _build/bindings
mkdir -p _build/resources
cp -r target/modules/*js _build/modules/
cp -r target/bindings/*.js _build/bindings/
cp -r metadata.json schemas target/*.js _build
cp -r ../../bindings/dbus-xml _build/resources/dbus
# cp -r icons resources *.css _build
# cp src/prefs.ui _build/

View File

@@ -9,17 +9,20 @@ find target/ -type f -print0 | while IFS= read -r -d $'\0' file; do \
sed -i -E 's|export class (\w+)|var \1 = class \1|g' $file; \
sed -i -E "s|import \* as (\w+) from '.\/(\w+)\/(\w+)'|const \1 = Me.imports.\2.\3|g" $file; \
sed -i -E "s|import \* as (\w+) from '..\/(\w+)\/(\w+)'|const \1 = Me.imports.\2.\3|g" $file; \
# root
sed -i -E "s|import \* as (\w+) from '..\/(\w+)'|const \1 = Me.imports.\2|g" $file; \
# nested by one dir
sed -i -E "s|import \* as (\w+) from '.\/(\w+)\/(\w+)'|const \1 = Me.imports.\2.\3|g" $file; \
# root
sed -i -E "s|import \* as (\w+) from '.\/(\w+)'|const \1 = Me.imports.\2|g" $file; \
sed -i -E "s|import \* as (\w+) from '..\/(\w+)'|const \1 = Me.imports.\2|g" $file; \
sed -i -E "s|from '.\/modules\/(\w+)'|= Me.imports.modules.\1|g" $file; \
sed -i -E "s|from '..\/modules\/(\w+)'|= Me.imports.modules.\1|g" $file; \
sed -i -E "s|from '.\/bindings\/(\w+)'|= Me.imports.bindings.\1|g" $file; \
sed -i -E "s|from '..\/bindings\/(\w+)'|= Me.imports.bindings.\1|g" $file; \
sed -i -E "s|from '.\/(\w+)'|= Me.imports.\1|g" $file; \
sed -i -E "s|from '..\/(\w+)'|= Me.imports.\1|g" $file; \
sed -i -E "s|import \{|var \{|g" $file; \
done

View File

@@ -18,6 +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 { Supported } from './modules/supported_dbus';
const QuickMiniLed = GObject.registerClass(
class QuickMiniLed extends QuickSettings.QuickToggle {
@@ -133,6 +135,9 @@ class Extension {
private _naff: Platform.GpuMode;
private _indicateMiniLed: typeof IndicateMiniLed;
private _indicatePanelOd: typeof IndicatePanelOd;
private _dbus_charge!: ChargingLimit;
private _dbus_supported!: Supported;
constructor() {
this._indicateMiniLed = null;
this._indicatePanelOd = null;
@@ -142,6 +147,16 @@ class Extension {
enable() {
this._indicateMiniLed = new IndicateMiniLed();
this._indicatePanelOd = new IndicatePanelOd();
this._dbus_charge = new ChargingLimit();
this._dbus_charge.start().then(() => {
//@ts-ignore
log(`DOOOOOM!, charge limit =`, this._dbus_charge.lastState);
});
this._dbus_supported = new Supported();
this._dbus_supported.start().then(() => {
//@ts-ignore
log(`DOOOOOM!, supported =`, this._dbus_supported.supported);
});
}
disable() {
@@ -149,6 +164,9 @@ class Extension {
this._indicateMiniLed = null;
this._indicatePanelOd.destroy();
this._indicatePanelOd = null;
this._dbus_charge.stop();
this._dbus_supported.stop();
}
}

View File

@@ -5,36 +5,18 @@ const ThisModule = imports.misc.extensionUtils.getCurrentExtension();
import * as Resources from './resources';
const {Gio} = imports.gi;
const { Gio } = imports.gi;
export class AnimeDbus {
asusLinuxProxy: any = null; // type: Gio.DbusProxy (donno how to add)
connected: boolean = false;
import { DbusBase } from '../modules/dbus';
export class AnimeDbus extends DbusBase {
state: boolean = true;
brightness: number = 255;
constructor() {
// nothing for now
super('org-asuslinux-anime-4', '/org/asuslinux/Anime');
}
// 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
// public getOnOffState() {
// if (this.isRunning()) {
// try {
// let currentState = this.asusLinuxProxy.AwakeEnabled;
// return currentState;
// } catch (e) {
// log(`Failed to fetch AniMe!`, e);
// }
// }
// return this.state;
// }
public setOnOffState(state: boolean | null) {
if (this.isRunning()) {
try {
@@ -46,7 +28,7 @@ export class AnimeDbus {
}
//@ts-ignore
log(`Setting AniMe Power to ${state}`);
return this.asusLinuxProxy.SetOnOffSync(state);
return this.dbus_proxy.SetOnOffSync(state);
} catch (e) {
//@ts-ignore
log(`AniMe DBus set power failed!`, e);
@@ -55,24 +37,20 @@ export class AnimeDbus {
}
public setBrightness(brightness: number) {
if (this.isRunning()) {
try {
if (this.brightness !== brightness) {
this.brightness = brightness;
}
//@ts-ignore
log(`Setting AniMe Brightness to ${brightness}`);
return this.asusLinuxProxy.SetBrightnessSync(brightness);
// Panel.Actions.spawnCommandLine(`asusctl anime leds -b ${brightness}`);
} catch (e) {
//@ts-ignore
log(`AniMe DBus set brightness failed!`, e);
}
}
}
isRunning(): boolean {
return this.connected;
if (this.isRunning()) {
try {
if (this.brightness !== brightness) {
this.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);
}
}
}
async start() {
@@ -82,7 +60,7 @@ export class AnimeDbus {
try {
// creating the proxy
let xml = Resources.File.DBus('org-asuslinux-anime-4')
this.asusLinuxProxy = new Gio.DBusProxy.makeProxyWrapper(xml)(
this.dbus_proxy = new Gio.DBusProxy.makeProxyWrapper(xml)(
Gio.DBus.system,
'org.asuslinux.Daemon',
'/org/asuslinux/Anime'
@@ -109,14 +87,7 @@ export class AnimeDbus {
}
}
stop() {
//@ts-ignore
log(`Stopping AniMe DBus client...`);
if (this.isRunning()) {
this.connected = false;
this.asusLinuxProxy = null;
this.state = true;
}
async stop() {
await super.stop();
}
}

View File

@@ -3,33 +3,38 @@ declare var asusctlGexInstance: any;
//@ts-ignore
const Me = imports.misc.extensionUtils.getCurrentExtension();
import * as Resources from './resources';
import { DbusBase } from '../modules/dbus';
const {Gio, GLib} = imports.gi;
// function getMethods(obj: { [x: string]: { toString: () => string; }; }) {
// var result = [];
// for (var id in obj) {
// try {
// if (typeof(obj[id]) == "function") {
// result.push(id + ": " + obj[id].toString());
// }
// } catch (err) {
// result.push(id + ": inaccessible");
// }
// }
// return result;
// }
export class ChargingLimit {
asusLinuxProxy: any = null; // type: Gio.DbusProxy (donno how to add)
connected: boolean = false;
export class ChargingLimit extends DbusBase {
lastState: number = 100;
pollerDelayTicks: number = 0;
timeoutChargePoller: number | null = null;
constructor() {
// nothing for now
super('org-asuslinux-power-4', '/org/asuslinux/Power');
}
public getChargingLimit() {
if (this.isRunning()) {
try {
let currentState = this.asusLinuxProxy.LimitSync().toString().trim();
return currentState;
this.lastState = this.dbus_proxy.ChargeControlEndThresholdSync();
} catch (e) {
//@ts-ignore
log(`Failed to fetch Charging Limit!`, e);
}
}
return this.lastState;
}
@@ -40,7 +45,7 @@ export class ChargingLimit {
// update state
this.lastState = limit;
}
return this.asusLinuxProxy.SetLimitSync(limit);
return this.dbus_proxy.SetChargeControlEndThresholdSync(limit);
} catch (e) {
//@ts-ignore
log(`Profile DBus set power profile failed!`, e);
@@ -48,102 +53,28 @@ export class ChargingLimit {
}
}
updateChargingLimit(curState: number) {
// return false;
if (curState > 0 && this.lastState !== curState) {
// disable the signal handler so we don't run in an infinite loop
// of notifying, setting, notifying, setting...
asusctlGexInstance.chargingLimit.chargingLimitSlider.block_signal_handler(asusctlGexInstance.chargingLimit._sliderChangedId);
asusctlGexInstance.chargingLimit.chargingLimitSlider.value = curState/100;
asusctlGexInstance.chargingLimit.chargingLimitSlider.unblock_signal_handler(asusctlGexInstance.chargingLimit._sliderChangedId);
asusctlGexInstance.chargingLimit.chargeLimitLabel.set_text(`${curState}%`);
// update state
this.lastState = curState;
}
}
pollerChargingLimit() {
if(this.isRunning() && this.pollerDelayTicks <= 0){
try {
let currentLimit = this.getChargingLimit();
if (currentLimit !== this.lastState){
this.updateChargingLimit(currentLimit);
// Panel.Actions.notify(
// 'ASUS Notebook Control',
// `Charging Limit changed to ${currentLimit}%`,
// 'scalable/battery-symbolic.svg'
// );
}
} catch (e) {
//@ts-ignore
log(`Charging Limit poller init failed!`, e);
} finally {
return this.isRunning() ? GLib.SOURCE_CONTINUE : GLib.SOURCE_REMOVE;
}
} else if (this.isRunning() && this.pollerDelayTicks > 0) {
this.pollerDelayTicks--;
return GLib.SOURCE_CONTINUE;
} else {
return GLib.SOURCE_REMOVE;
}
}
isRunning(): boolean {
return this.connected;
}
async start() {
//@ts-ignore
log(`Starting Charging Limit DBus client...`);
try {
// creating the proxy
let xml = Resources.File.DBus('org-asuslinux-charge-4')
this.asusLinuxProxy = new Gio.DBusProxy.makeProxyWrapper(xml)(
Gio.DBus.system,
'org.asuslinux.Daemon',
'/org/asuslinux/Charge'
);
await super.start();
this.getChargingLimit();
this.connected = true;
this.lastState = this.getChargingLimit();
this.asusLinuxProxy.connectSignal(
"NotifyCharge",
this.dbus_proxy.connectSignal(
"NotifyChargeControlEndThreshold",
(proxy: any = null, name: string, data: string) => {
if (proxy) {
//@ts-ignore
log(`Charging Limit has changed to ${data}% (${name}).`);
this.updateChargingLimit(parseInt(data));
this.lastState = parseInt(data);
}
}
);
try {
this.timeoutChargePoller = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 5, this.pollerChargingLimit.bind(this));
} catch (e) {
//@ts-ignore
log(`Charging Limit DBus Poller initialization failed!`, e);
}
} catch (e) {
//@ts-ignore
log(`Charging Limit DBus initialization failed!`, e);
}
}
stop() {
//@ts-ignore
log(`Stopping Charging Limit DBus client...`);
if (this.isRunning()) {
this.connected = false;
this.asusLinuxProxy = null;
this.lastState = 100;
GLib.Source.remove(this.timeoutChargePoller);
this.timeoutChargePoller = null;
}
async stop() {
await super.stop();
}
}

View File

@@ -0,0 +1,54 @@
declare const global: any, imports: any;
//@ts-ignore
const Me = imports.misc.extensionUtils.getCurrentExtension();
import * as Resources from '../modules/resources';
const { Gio } = imports.gi;
export class DbusBase {
dbus_proxy: any = null; // type: Gio.DbusProxy
connected: boolean = false;
xml_resource: string = '';
dbus_path: string = '';
constructor(resource: string, dbus_path: string) {
this.xml_resource = resource;
this.dbus_path = dbus_path;
}
async start() {
//@ts-ignore
log(`Starting ${this.dbus_path} dbus module`);
try {
let xml = Resources.File.DBus(this.xml_resource);
this.dbus_proxy = new Gio.DBusProxy.makeProxyWrapper(xml)(
Gio.DBus.system,
'org.asuslinux.Daemon',
this.dbus_path,
);
this.connected = true;
//@ts-ignore
log(`${this.dbus_path} client started successfully.`);
} catch (e) {
//@ts-ignore
log(`${this.xml_resource} dbus init failed!`, e);
}
}
async stop() {
//@ts-ignore
log(`Stopping ${this.xml_resource} dbus module`);
if (this.connected) {
this.dbus_proxy.destroy();
this.connected = false;
this.dbus_proxy = null;
}
}
isRunning(): boolean {
return this.connected;
}
}

View File

@@ -3,20 +3,20 @@ declare var asusctlGexInstance: any;
//@ts-ignore
const Me = imports.misc.extensionUtils.getCurrentExtension();
import * as Bios from '../bindings/platform';
import * as Dbus from './dbus';
import * as bios from '../bindings/platform';
import { DbusBase } from '../modules/dbus';
export class Platform extends Dbus.DbusClass {
bios: Bios.RogBiosSupportedFunctions = asusctlGexInstance.supported.connector.supported;
export class Platform extends DbusBase {
bios: bios.RogBiosSupportedFunctions = asusctlGexInstance.supported.connector.supported;
constructor() {
super('org-asuslinus-platform-4', '/org/asuslinux/Platform');
super('org-asuslinux-platform-4', '/org/asuslinux/Platform');
}
public getPostBootSound() {
if (this.isRunning()) {
try {
let currentState = this.asusLinuxProxy.PostBootSoundSync();
let currentState = this.dbus_proxy.PostBootSoundSync();
return parseInt(currentState) == 1 ? true : false;
} catch (e) {
//@ts-ignore
@@ -32,7 +32,7 @@ export class Platform extends Dbus.DbusClass {
if (state !== this.bios.post_sound) {
this.bios.post_sound = state;
}
return this.asusLinuxProxy.SetPostBootSoundSync(state);
return this.dbus_proxy.SetPostBootSoundSync(state);
} catch (e) {
//@ts-ignore
log(`Platform DBus set Post Boot Sound failed!`, e);
@@ -43,7 +43,7 @@ export class Platform extends Dbus.DbusClass {
public getMUX() {
if (this.isRunning()) {
try {
let currentState = this.asusLinuxProxy.GpuMuxModeSync();
let currentState = this.dbus_proxy.GpuMuxModeSync();
return parseInt(currentState) == 0 ? true : false;
} catch (e) {
//@ts-ignore
@@ -59,7 +59,7 @@ export class Platform extends Dbus.DbusClass {
if (!state !== this.bios.gpu_mux) {
this.bios.gpu_mux = !state;
}
return this.asusLinuxProxy.SetGpuMuxModeSync(!state);
return this.dbus_proxy.SetGpuMuxModeSync(!state);
} catch (e) {
//@ts-ignore
log(`Switching the MUX failed!`, e);
@@ -70,7 +70,7 @@ export class Platform extends Dbus.DbusClass {
public getOverdrive() {
if (this.isRunning()) {
try {
let currentState = this.asusLinuxProxy.PanelOverdriveSync();
let currentState = this.dbus_proxy.PanelOverdriveSync();
return parseInt(currentState) == 1 ? true : false;
} catch (e) {
//@ts-ignore
@@ -86,7 +86,7 @@ export class Platform extends Dbus.DbusClass {
if (state !== this.bios.panel_overdrive) {
this.bios.panel_overdrive = state;
}
return this.asusLinuxProxy.SetPanelOverdriveSync(state);
return this.dbus_proxy.SetPanelOverdriveSync(state);
} catch (e) {
//@ts-ignore
log(`Overdrive DBus set overdrive state failed!`, e);
@@ -94,17 +94,13 @@ export class Platform extends Dbus.DbusClass {
}
}
isRunning(): boolean {
return this.connected;
}
async start() {
try {
super.start();
await super.start();
if (asusctlGexInstance.supported.connector.supportedAttributes.bios_toggleSound) {
this.bios.post_sound = this.getPostBootSound();
this.asusLinuxProxy.connectSignal(
this.dbus_proxy.connectSignal(
"NotifyPostBootSound",
(proxy: any = null, _name: string, data: boolean) => {
if (proxy) {
@@ -118,7 +114,7 @@ export class Platform extends Dbus.DbusClass {
if (asusctlGexInstance.supported.connector.supportedAttributes.bios_overdrive) {
this.bios.panel_overdrive = this.getOverdrive();
this.asusLinuxProxy.connectSignal(
this.dbus_proxy.connectSignal(
"NotifyPanelOverdrive",
(proxy: any = null, _name: string, data: boolean) => {
if (proxy) {
@@ -132,7 +128,7 @@ export class Platform extends Dbus.DbusClass {
if (asusctlGexInstance.supported.connector.supportedAttributes.bios_toggleMUX) {
this.bios.gpu_mux = this.getMUX();
this.asusLinuxProxy.connectSignal(
this.dbus_proxy.connectSignal(
"NotifyGpuMuxMode",
(proxy: any = null, _name: string, data: boolean) => {
if (proxy) {
@@ -157,7 +153,7 @@ export class Platform extends Dbus.DbusClass {
}
async stop() {
super.stop();
await super.stop();
this.bios.post_sound = false;
this.bios.panel_overdrive = false;
}

View File

@@ -2,17 +2,11 @@ declare const global: any, imports: any;
//@ts-ignore
const Me = imports.misc.extensionUtils.getCurrentExtension();
import * as Resources from './resources';
import * as Platform from '../bindings/platform';
import * as Aura from '../bindings/aura';
const { Gio } = imports.gi;
export class Supported {
supportedProxy: any = null; // type: Gio.DbusProxy (donno how to add)
connectedSupported: boolean = false;
import { SupportedFunctions, AdvancedAura } from '../bindings/platform';
import { AuraDevice, AuraModeNum, AuraZone } from '../bindings/aura';
import { DbusBase } from '../modules/dbus';
export class Supported extends DbusBase {
// False,
// (True,),
// (True, True),
@@ -34,7 +28,7 @@ export class Supported {
// 2),
// (False, True, True, True, False, True)
supported: Platform.SupportedFunctions = {
supported: SupportedFunctions = {
anime_ctrl: false,
charge_ctrl: {
charge_level_set: false
@@ -44,11 +38,11 @@ export class Supported {
fan_curves: false
},
keyboard_led: {
dev_id: Aura.AuraDevice.Unknown,
dev_id: AuraDevice.Unknown,
brightness: false,
basic_modes: [],
basic_zones: [],
advanced_type: Platform.AdvancedAura.None
advanced_type: AdvancedAura.None
},
rog_bios_ctrl: {
post_sound: false,
@@ -61,13 +55,13 @@ export class Supported {
};
constructor() {
// nothing for now
super('org-asuslinux-supported-4', '/org/asuslinux/Supported');
}
public getSupported() {
if (this.isRunning()) {
try {
let _supportedAttributes = this.supportedProxy.SupportedFunctionsSync();
let _supportedAttributes = this.dbus_proxy.SupportedFunctionsSync();
if (_supportedAttributes.length > 0) {
let valueString: string = '';
@@ -93,15 +87,15 @@ export class Supported {
case 3:
let ledArray = valueString.split(',');
// let t: keyof typeof AuraDevice = ledArray[0]; // can't conevert
this.supported.keyboard_led.dev_id = Aura.AuraDevice[ledArray[0] as Aura.AuraDevice];
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 Aura.AuraModeNum[value as Aura.AuraModeNum]
return AuraModeNum[value as AuraModeNum]
});
this.supported.keyboard_led.basic_zones = ledArray[3].split(',').map(function (value) {
return Aura.AuraZone[value as Aura.AuraZone]
return AuraZone[value as AuraZone]
});
this.supported.keyboard_led.advanced_type = Platform.AdvancedAura[ledArray[4] as Platform.AdvancedAura];
this.supported.keyboard_led.advanced_type = AdvancedAura[ledArray[4] as AdvancedAura];
break;
case 4:
@@ -126,38 +120,17 @@ export class Supported {
}
}
isRunning(): boolean {
return this.connectedSupported;
}
async start() {
try {
// creating the proxy
let xml = Resources.File.DBus('org-asuslinux-supported-4');
this.supportedProxy = new Gio.DBusProxy.makeProxyWrapper(xml)(
Gio.DBus.system,
'org.asuslinux.Daemon',
'/org/asuslinux/Supported'
);
this.connectedSupported = true;
await super.start();
this.getSupported();
//@ts-ignore
log(`Supported Daemon client started successfully.`);
} catch (e) {
//@ts-ignore
log(`Supported DBus initialization failed!`, e);
}
}
stop() {
//@ts-ignore
log(`Stopping Supported DBus client...`);
if (this.isRunning()) {
this.connectedSupported = false;
this.supportedProxy = null;
}
async stop() {
await super.stop()
}
}