Begin reimplement gex to use generated bindings and dbus xml

This commit is contained in:
Luke D. Jones
2023-06-28 21:54:17 +12:00
parent 439c830311
commit 4d2d5707a1
31 changed files with 2744 additions and 10 deletions

View File

@@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View File

@@ -0,0 +1,118 @@
# asusctl ([-gex]: Gnome extension) -inactive(until v5.0.0)-
## inactive (kind of - update)
~~This project is currently inactive until a new maintainer wants to put some love into it and make it compatible with the newest asusctl versions.~~
ROG Control Center will also have it's own appindicator.
This extension is currently marked as inactive also on extensions.gnome.org and for users not visible anymore.
*UPDATE:*
The origin maintainer (ZaPpPeL) is back from his rabbit-hole! (I'll take care of getting this into a working-state again within the next weeks - stay tuned!)
---
Extension for visualizing [asusctl](https://gitlab.com/asus-linux/asusctl)(`asusd`) settings and status.
*hint:* supergfxctl GPU mode switching moved to another extension to make it platform independent: [supergfxctl-gex](https://gitlab.com/asus-linux/supergfxctl-gex)(`supergfxctl-gex`)
---
## Table of contents
[[_TOC_]]
---
## Extension Features
* Notifications:
* Battery Charge Limit
* Popup Menu with options to:
* if supported by laptop model:
* change the battery charging limit
* change AniMe Matrix brightness
* enable / disable AniMe Matrix
* Extension Settings:
* Enable / disable notifications
* Enable debug message logging
### Waiting for implementation:
* Configuration interface (prefs)
* bind ROG-Button to open prefs (if not `rog-control-center` is used)
* create canvas based fan-curve editing
---
## Icons/Screenshots
_The screenshots below are just examples and might not represent the current used icons._
### Screenshot
![screenshot.png](https://gitlab.com/asus-linux/asusctl-gex/-/raw/main/screenshots/screenshot.png)
**battery charge limit notification:**
![notification.png](https://gitlab.com/asus-linux/asusctl-gex/-/raw/main/screenshots/notification.png)
---
## Requirements
* gnome >= 3.36.0
* [asusctl](https://gitlab.com/asus-linux/asusctl) >= 4.0
---
## Build Instructions
### Dependencies
* nodejs >= 14.0.0
* npm >= 6.14.0
### Building (production)
In a terminal enter the following commands as a user (**do NOT run as root or sudo**):
```bash
git clone https://gitlab.com/asus-linux/asusctl-gex.git /tmp/asusctl-gex && cd /tmp/asusctl-gex
npm install
npm run build && npm run install-user
```
_HINT: You will need to reload the GNOME Shell afterwards. (`Alt + F2` -> `r` on X11, `logout` on Wayland)_
### Building (development)
Instead of the
`npm run build && npm run install-user`
above, use this line instead:
`npm run build && npm run install-dev`
This will remove any production versions and installs the development version instead.
_HINT: You will need to reload the GNOME Shell afterwards. (`Alt + F2` -> `r` on X11, `logout` on Wayland)_ and probably manually enable the extension again.
### Source debugging
`cd` into the directory where you've downloaded the `asusctl-gex` source code and enter the following commands:
```bash
npm install
npm run debug
```
---
## License & Trademarks
**License:** Mozilla Public License Version 2.0 (MPL-2)
**Trademarks:** ASUS and ROG Trademark is either a US registered trademark or trademark of ASUSTeK Computer Inc. in the United States and/or other countries.
Reference to any ASUS products, services, processes, or other information and/or use of ASUS Trademarks does not constitute or imply endorsement, sponsorship, or recommendation thereof by ASUS.
The use of ROG and ASUS trademarks within this website and associated tools and libraries is only to provide a recognisable identifier to users to enable them to associate that these tools will work with ASUS ROG laptops.

View File

@@ -0,0 +1,11 @@
{
"name": "asusctl-gex",
"description": "asusctl-gex is a frontend for some functionalities of asusctl and supergfxctl that were born inside the asus-linux.org community.\n\nasusctl is required.\n\nTo learn more about it, please have a look at:\nhttps://gitlab.com/asus-linux/asusctl\nhttps://gitlab.com/asus-linux/asusctl-gex\n\nhttps://asus-linux.org/",
"uuid": "asusctl-gex@asus-linux.org",
"uuid-dev": "asusctl-gex-dev@asus-linux.org",
"settings-schema": "org.gnome.shell.extensions.asusctl-gex",
"version": "4.3.2",
"shell-version": [
"43", "44"
]
}

1094
desktop-extensions/gnome/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
{
"name": "asusctl-gex",
"version": "4.7.0",
"description": "asusctl-gex is a frontend for some functionalities of asusctl and supergfxctl that were born inside the asus-linux.org community.\n\nasusctl is required.\n\nTo learn more about it, please have a look at:\nhttps://gitlab.com/asus-linux/asusctl\nhttps://gitlab.com/asus-linux/asusctl-gex\n\nhttps://asus-linux.org/",
"dependencies": {
"npm-run-all": "^4.1.5",
"typescript": "^4.3.5"
},
"devDependencies": {},
"scripts": {
"build:clean": "rm -rf _build _target schemas/gschemas.compiled target",
"build:compile": "scripts/compile",
"build:convert": "scripts/convert",
"build:schemas": "glib-compile-schemas schemas",
"build:transpile": "npx tsc",
"build": "run-p build:clean && run-p build:transpile && run-p build:schemas && run-p build:convert && run-p build:compile",
"debug:nested_shell": "run-p build && run-p install-dev && scripts/nested_shell",
"debug": "run-p debug:nested_shell",
"disable": "gnome-extensions disable \"asusctl-gex@asus-linux.org\"",
"enable": "gnome-extensions enable \"asusctl-gex@asus-linux.org\"",
"install-user": "scripts/install",
"install-dev": "scripts/install dev",
"uninstall-local": "scripts/uninstall",
"zip": "scripts/zipit"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gitlab.com/asus-linux/asusctl-gex.git"
},
"keywords": [
"gnome-shell",
"extension",
"asusctl",
"asus",
"rog",
"gnome",
"gjs",
"typescript"
],
"author": "Armas Spann, Marco Laux, Luke Jones",
"license": "MPL-2",
"bugs": {
"url": "https://gitlab.com/asus-linux/asusctl/issues"
},
"homepage": "https://gitlab.com/asus-linux/asusctl/desktop-extensions/gnome#readme"
}

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="org.gnome.shell.extensions.asusctl-gex" path="/org/gnome/shell/extensions/asusctl-gex/" >
<key type="b" name="mini-led-enabled">
<default>true</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 type="b" name="panel-od-enabled">
<default>false</default>
<summary>enable / disable debug messages</summary>
<description>If enabled, various events of the extension will get logged and are available via journalctl.</description>
</key>
<key type="b" name="supernotice">
<default>false</default>
<summary>hide the supergfxctl-gex notice</summary>
</key>
</schema>
</schemalist>

View File

@@ -0,0 +1,11 @@
#!/bin/sh
rm -rf _build
mkdir -p _build/modules
mkdir -p _build/bindings
cp -r target/modules/*js _build/modules/
cp -r target/bindings/*.js _build/bindings/
cp -r metadata.json schemas target/*.js _build
# cp -r icons resources *.css _build
# cp src/prefs.ui _build/
exit 0;

View File

@@ -0,0 +1,27 @@
#!/bin/sh
find target/ -type f -print0 | while IFS= read -r -d $'\0' file; do \
sed -i \
-e 's#export function#function#g' \
-e 's#export var#var#g' \
-e 's#export const#var#g' \
-e 's#Object.defineProperty(exports, "__esModule", { value: true });#var exports = {};#g' \
$file; \
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; \
# 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|from '.\/modules\/(\w+)'|= Me.imports.modules.\1|g" $file; \
sed -i -E "s|from '.\/(\w+)'|= Me.imports.\1|g" $file; \
sed -i -E "s|import \{|var \{|g" $file; \
done
exit 0;

View File

@@ -0,0 +1,45 @@
#!/bin/sh
isdev=false
for arg in "$@"; do
if [ "$arg" = "dev" ]; then
isdev=true
fi;
done
INSTALLBASE=~/.local/share/gnome-shell/extensions
UUID=`grep -E '^[ ]*"uuid":' _build/metadata.json | sed 's@^[ ]*"uuid":[ ]*"\(.\+\)",[ ]*@\1@'`
UUIDDEV=`grep -E '^[ ]*"uuid-dev":' _build/metadata.json | sed 's@^[ ]*"uuid-dev":[ ]*"\(.\+\)",[ ]*@\1@'`
GV=`gnome-shell --version | awk '{print $3}'`
if $isdev
then
sed -i "s/${UUID}/${UUIDDEV}/g" _build/metadata.json
rm -fr "${INSTALLBASE}/${UUID}"
UUID=$UUIDDEV
else
rm -fr "${INSTALLBASE}/${UUIDDEV}"
fi
if [ -d "${INSTALLBASE}/${UUID}" ]; then
rm -rf "${INSTALLBASE}/${UUID}/*"
else
mkdir -p "${INSTALLBASE}/${UUID}"
fi
cp -r _build/* "${INSTALLBASE}/${UUID}/"
gnome-extensions info "${UUID}"
INSTALLED="$?"
if [ "$INSTALLED" -eq 0 ]; then
echo "reset"
gnome-extensions reset "${UUID}"
echo "enable"
gnome-extensions enable "${UUID}"
echo "Please restart GNOME Shell if you are on X11 or logout and login again when you use Wayland."
else
echo "You probably install the extension for the first time. Please restart GNOME Shell or Logout and enable the extension via the Extensions app or extensions.gnome.org."
fi
exit 0;

View File

@@ -0,0 +1,3 @@
#!/bin/bash
MUTTER_DEBUG_DUMMY_MODE_SPECS=1366x768 dbus-run-session -- gnome-shell --nested --wayland
exit 0

View File

@@ -0,0 +1,8 @@
#!/bin/sh
UUID=`grep -E '^[ ]*"uuid":' metadata.json | sed 's@^[ ]*"uuid":[ ]*"\(.\+\)",[ ]*@\1@'`
INSTALLBASE=~/.local/share/gnome-shell/extensions
gnome-extensions disable "$UUID"
rm -rf "$INSTALLBASE/$UUID"
exit 0;

View File

@@ -0,0 +1,7 @@
#!/bin/sh
UUID=`grep -E '^[ ]*"uuid":' metadata.json | sed 's@^[ ]*"uuid":[ ]*"\(.\+\)",[ ]*@\1@'`
VSTRING=`grep -E '^[ ]*"version":' metadata.json | sed 's@^[ ]*"version":[ ]*"\(.\+\)",[ ]*@\1@'`
rm *.zip
cd _build && zip -qr "../$UUID.zip" .
exit 0;

View File

@@ -0,0 +1 @@
../../../bindings/ts

View File

@@ -0,0 +1,158 @@
declare const global: any, imports: any;
//@ts-ignore
const Me = imports.misc.extensionUtils.getCurrentExtension();
// const { GpuMode } = imports.bindings.platform;
// REF: https://gjs.guide/extensions/development/creating.html
const { GObject, Gio } = imports.gi;
const ExtensionUtils = imports.misc.extensionUtils;
const QuickSettings = imports.ui.quickSettings;
// This is the live instance of the Quick Settings menu
const QuickSettingsMenu = imports.ui.main.panel.statusArea.quickSettings;
//@ts-ignore
const ThisModule = imports.misc.extensionUtils.getCurrentExtension();
// const systemConnection = Gio.DBus.system;
// const TestProxy = Gio.DBusProxy.makeProxyWrapper(interfaceXml);
import * as Platform from './bindings/platform';
const QuickMiniLed = GObject.registerClass(
class QuickMiniLed extends QuickSettings.QuickToggle {
_init() {
super._init({
title: 'MiniLED',
iconName: 'selection-mode-symbolic',
toggleMode: true,
});
this.label = 'MiniLED';
// Binding the toggle to a GSettings key
this._settings = ExtensionUtils.getSettings();
this._settings.bind('mini-led-enabled',
this, 'checked',
Gio.SettingsBindFlags.DEFAULT);
}
});
const IndicateMiniLed = GObject.registerClass(
class IndicateMiniLed extends QuickSettings.SystemIndicator {
_init() {
super._init();
// Create the icon for the indicator
this._indicator = this._addIndicator();
this._indicator.icon_name = 'selection-mode-symbolic';
// Showing the indicator when the feature is enabled
this._settings = ExtensionUtils.getSettings();
this._settings.bind('mini-led-enabled',
this._indicator, 'visible',
Gio.SettingsBindFlags.DEFAULT);
// Create the toggle and associate it with the indicator, being sure to
// destroy it along with the indicator
this.quickSettingsItems.push(new QuickMiniLed());
this.connect('destroy', () => {
this.quickSettingsItems.forEach((item: { destroy: () => any; }) => item.destroy());
});
// Add the indicator to the panel and the toggle to the menu
QuickSettingsMenu._indicators.add_child(this);
QuickSettingsMenu._addItems(this.quickSettingsItems);
}
});
const QuickPanelOd = GObject.registerClass(
class QuickPanelOd extends QuickSettings.QuickToggle {
_init() {
super._init({
title: 'Panel Overdrive',
iconName: 'selection-mode-symbolic',
toggleMode: true,
});
this.label = 'Panel Overdrive';
this._settings = ExtensionUtils.getSettings();
this._settings.bind('panel-od-enabled',
this, 'checked',
Gio.SettingsBindFlags.DEFAULT);
}
});
const IndicatePanelOd = GObject.registerClass(
class IndicatePanelOd extends QuickSettings.SystemIndicator {
_init() {
super._init();
this._indicator = this._addIndicator();
this._indicator.icon_name = 'selection-mode-symbolic';
this._settings = ExtensionUtils.getSettings();
this._settings.bind('panel-od-enabled',
this._indicator, 'visible',
Gio.SettingsBindFlags.DEFAULT);
this.quickSettingsItems.push(new QuickPanelOd());
this.connect('destroy', () => {
this.quickSettingsItems.forEach((item: { destroy: () => any; }) => item.destroy());
});
QuickSettingsMenu._indicators.add_child(this);
QuickSettingsMenu._addItems(this.quickSettingsItems);
}
});
function onNameAppeared(_connection: any, name: any, name_owner: any) {
//@ts-ignore
log(`The well-known name ${name} has been owned by ${name_owner}`);
}
// Likewise, this will be invoked when the process that owned the name releases
// the name.
function onNameVanished(_connection: any, name: any) {
//@ts-ignore
log(`The name owner of ${name} has vanished`);
}
const busWatchId = Gio.bus_watch_name(
Gio.BusType.SESSION,
'guide.gjs.Test',
Gio.BusNameWatcherFlags.NONE,
onNameAppeared,
onNameVanished
);
Gio.bus_unwatch_name(busWatchId);
class Extension {
//@ts-ignore
private _naff: Platform.GpuMode;
private _indicateMiniLed: typeof IndicateMiniLed;
private _indicatePanelOd: typeof IndicatePanelOd;
constructor() {
this._indicateMiniLed = null;
this._indicatePanelOd = null;
this._naff = Platform.GpuMode.Discrete;
}
enable() {
this._indicateMiniLed = new IndicateMiniLed();
this._indicatePanelOd = new IndicatePanelOd();
}
disable() {
this._indicateMiniLed.destroy();
this._indicateMiniLed = null;
this._indicatePanelOd.destroy();
this._indicatePanelOd = null;
}
}
//@ts-ignore
function init() {
return new Extension();
}

View File

@@ -0,0 +1,122 @@
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;
export class AnimeDbus {
asusLinuxProxy: any = null; // type: Gio.DbusProxy (donno how to add)
connected: boolean = false;
state: boolean = true;
brightness: number = 255;
constructor() {
// nothing for now
}
// 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 {
// if null, toggle the current state
state = (state == null ? !this.state : state);
if (this.state !== state) {
this.state = state;
}
//@ts-ignore
log(`Setting AniMe Power to ${state}`);
return this.asusLinuxProxy.SetOnOffSync(state);
} catch (e) {
//@ts-ignore
log(`AniMe DBus set power failed!`, e);
}
}
}
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;
}
async start() {
//@ts-ignore
log(`Starting AniMe DBus client...`);
try {
// creating the proxy
let xml = Resources.File.DBus('org-asuslinux-anime-4')
this.asusLinuxProxy = 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) {
//@ts-ignore
log(`AniMe DBus initialization failed!`, e);
}
}
stop() {
//@ts-ignore
log(`Stopping AniMe DBus client...`);
if (this.isRunning()) {
this.connected = false;
this.asusLinuxProxy = null;
this.state = true;
}
}
}

View File

@@ -0,0 +1,149 @@
declare const global: any, imports: any;
declare var asusctlGexInstance: any;
//@ts-ignore
const Me = imports.misc.extensionUtils.getCurrentExtension();
import * as Resources from './resources';
const {Gio, GLib} = imports.gi;
export class ChargingLimit {
asusLinuxProxy: any = null; // type: Gio.DbusProxy (donno how to add)
connected: boolean = false;
lastState: number = 100;
pollerDelayTicks: number = 0;
timeoutChargePoller: number | null = null;
constructor() {
// nothing for now
}
public getChargingLimit() {
if (this.isRunning()) {
try {
let currentState = this.asusLinuxProxy.LimitSync().toString().trim();
return currentState;
} catch (e) {
//@ts-ignore
log(`Failed to fetch Charging Limit!`, e);
}
}
return this.lastState;
}
public setChargingLimit(limit: number) {
if (this.isRunning()) {
try {
if (limit > 0 && this.lastState !== limit) {
// update state
this.lastState = limit;
}
return this.asusLinuxProxy.SetLimitSync(limit);
} catch (e) {
//@ts-ignore
log(`Profile DBus set power profile failed!`, e);
}
}
}
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'
);
this.connected = true;
this.lastState = this.getChargingLimit();
this.asusLinuxProxy.connectSignal(
"NotifyCharge",
(proxy: any = null, name: string, data: string) => {
if (proxy) {
//@ts-ignore
log(`Charging Limit has changed to ${data}% (${name}).`);
this.updateChargingLimit(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;
}
}
}

View File

@@ -0,0 +1,194 @@
declare const global: any, imports: any;
declare var asusctlGexInstance: any;
//@ts-ignore
const Me = imports.misc.extensionUtils.getCurrentExtension();
import * as Resources from './resources';
const { Gio } = imports.gi;
export class Platform {
asusLinuxProxy: any = null; // type: Gio.DbusProxy
connected: boolean = false;
lastStatePostBootSound: boolean = false;
lastStateOverdrive: boolean = false;
lastStateMUX: boolean = false;
constructor() {
// nothing for now
}
public getPostBootSound() {
if (this.isRunning()) {
try {
let currentState = this.asusLinuxProxy.PostBootSoundSync();
return parseInt(currentState) == 1 ? true : false;
} catch (e) {
//@ts-ignore
log(`Failed to get POST Boot Sound state!`, e);
}
}
return this.lastStatePostBootSound;
}
public setPostBootSound(state: boolean) {
if (this.isRunning()) {
try {
if (state !== this.lastStatePostBootSound) {
this.lastStatePostBootSound = state;
}
return this.asusLinuxProxy.SetPostBootSoundSync(state);
} catch (e) {
//@ts-ignore
log(`Platform DBus set Post Boot Sound failed!`, e);
}
}
}
public getMUX() {
if (this.isRunning()) {
try {
let currentState = this.asusLinuxProxy.GpuMuxModeSync();
return parseInt(currentState) == 0 ? true : false;
} catch (e) {
//@ts-ignore
log(`Failed to get MUX state!`, e);
}
}
return this.lastStatePostBootSound;
}
public setMUX(state: boolean) {
if (this.isRunning()) {
try {
if (!state !== this.lastStateMUX) {
this.lastStateMUX = !state;
}
return this.asusLinuxProxy.SetGpuMuxModeSync(!state);
} catch (e) {
//@ts-ignore
log(`Switching the MUX failed!`, e);
}
}
}
public getOverdrive() {
if (this.isRunning()) {
try {
let currentState = this.asusLinuxProxy.PanelOverdriveSync();
return parseInt(currentState) == 1 ? true : false;
} catch (e) {
//@ts-ignore
log(`Failed to get Overdrive state!`, e);
}
}
return this.lastStateOverdrive;
}
public setOverdrive(state: boolean) {
if (this.isRunning()) {
try {
if (state !== this.lastStateOverdrive) {
this.lastStateOverdrive = state;
}
return this.asusLinuxProxy.SetPanelOverdriveSync(state);
} catch (e) {
//@ts-ignore
log(`Overdrive DBus set overdrive state failed!`, e);
}
}
}
isRunning(): boolean {
return this.connected;
}
async start() {
//@ts-ignore
log(`Starting Platform DBus module...`);
try {
let xml = Resources.File.DBus('org-asuslinus-platform-4')
this.asusLinuxProxy = new Gio.DBusProxy.makeProxyWrapper(xml)(
Gio.DBus.system,
'org.asuslinux.Daemon',
'/org/asuslinux/Platform'
);
this.connected = true;
if (asusctlGexInstance.supported.connector.supportedAttributes.bios_toggleSound) {
this.lastStatePostBootSound = this.getPostBootSound();
this.asusLinuxProxy.connectSignal(
"NotifyPostBootSound",
(proxy: any = null, _name: string, data: boolean) => {
if (proxy) {
//@ts-ignore
log(`PostBootSound changed to ${data}`);
asusctlGexInstance.Platform.switchPostBootSound.setToggleState(this.lastStatePostBootSound);
}
}
);
}
if (asusctlGexInstance.supported.connector.supportedAttributes.bios_overdrive) {
this.lastStateOverdrive = this.getOverdrive();
this.asusLinuxProxy.connectSignal(
"NotifyPanelOverdrive",
(proxy: any = null, _name: string, data: boolean) => {
if (proxy) {
//@ts-ignore
log(`Overdrive has changed to ${data}.`);
asusctlGexInstance.Platform.overdriveSwitch.setToggleState(this.lastStateOverdrive);
}
}
);
}
if (asusctlGexInstance.supported.connector.supportedAttributes.bios_toggleMUX) {
this.lastStateMUX = this.getMUX();
this.asusLinuxProxy.connectSignal(
"NotifyGpuMuxMode",
(proxy: any = null, _name: string, data: boolean) => {
if (proxy) {
//@ts-ignore
log(`MUX has changed to ${data}.`);
asusctlGexInstance.Platform.switchMUX.setToggleState(this.lastStateMUX);
// Panel.Actions.notify(
// 'ASUS Notebook Control',
// `MUX Mode has chnged. Please reboot to apply the changes.`,
// 'scalable/reboot.svg',
// 'reboot'
// );
}
}
);
}
} catch (e) {
//@ts-ignore
log(`Overdrive DBus init failed!`, e);
}
}
stop() {
//@ts-ignore
log(`Stopping Overdrive DBus module...`);
if (this.isRunning()) {
this.connected = false;
this.asusLinuxProxy = null;
this.lastStatePostBootSound = false;
this.lastStateOverdrive = false;
}
}
}

View File

@@ -0,0 +1,21 @@
declare const global: any, imports: any;
//@ts-ignore
const ThisModule = imports.misc.extensionUtils.getCurrentExtension();
const GLib = imports.gi.GLib;
export class File {
public static DBus(name: string) {
let file = `${ThisModule.path}/resources/dbus/${name}.xml`;
try {
let [_ok, bytes] = GLib.file_get_contents(file)
if (!_ok)
//@ts-ignore
log(`Couldn't read contents of "${file}"`);
return _ok ? imports.byteArray.toString(bytes) : null;
} catch (e) {
//@ts-ignore
log(`Failed to load "${file}"`, e);
}
}
}

View File

@@ -0,0 +1,163 @@
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;
// False,
// (True,),
// (True, True),
// ('X19b6',
// True,
// ['Static',
// 'Breathe',
// 'Strobe',
// 'Rainbow',
// 'Star',
// 'Rain',
// 'Highlight',
// 'Laser',
// 'Ripple',
// 'Pulse',
// 'Comet',
// 'Flash'],
// [],
// 2),
// (False, True, True, True, False, True)
supportedAttributes: Platform.SupportedFunctions = {
anime_ctrl: false,
charge_ctrl: {
charge_level_set: false
},
platform_profile: {
platform_profile: false,
fan_curves: false
},
keyboard_led: {
dev_id: Aura.AuraDevice.Unknown,
brightness: false,
basic_modes: [],
basic_zones: [],
advanced_type: Platform.AdvancedAura.None
},
rog_bios_ctrl: {
post_sound: false,
gpu_mux: false,
panel_overdrive: false,
dgpu_disable: false,
egpu_enable: false,
mini_led_mode: false
}
};
constructor() {
// nothing for now
}
public getSupported() {
if (this.isRunning()) {
try {
let _supportedAttributes = this.supportedProxy.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.supportedAttributes.anime_ctrl = (valueString == 'true' ? true : false);
break;
case 1:
this.supportedAttributes.charge_ctrl.charge_level_set = (valueString == 'true' ? true : false);
break;
case 2:
let platformArray = valueString.split(',');
this.supportedAttributes.platform_profile.fan_curves = (platformArray[0] == 'true' ? true : false);
this.supportedAttributes.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.supportedAttributes.keyboard_led.dev_id = Aura.AuraDevice[ledArray[0] as Aura.AuraDevice];
this.supportedAttributes.keyboard_led.brightness = (ledArray[1] == 'true' ? true : false);
this.supportedAttributes.keyboard_led.basic_modes = ledArray[2].split(',').map(function (value) {
return Aura.AuraModeNum[value as Aura.AuraModeNum]
});
this.supportedAttributes.keyboard_led.basic_zones = ledArray[3].split(',').map(function (value) {
return Aura.AuraZone[value as Aura.AuraZone]
});
this.supportedAttributes.keyboard_led.advanced_type = Platform.AdvancedAura[ledArray[4] as Platform.AdvancedAura];
break;
case 4:
let biosArray = valueString.split(',');
this.supportedAttributes.rog_bios_ctrl.post_sound = (biosArray[0] == 'true' ? true : false);
this.supportedAttributes.rog_bios_ctrl.gpu_mux = (biosArray[1] == 'true' ? true : false);
this.supportedAttributes.rog_bios_ctrl.panel_overdrive = (biosArray[2] == 'true' ? true : false);
this.supportedAttributes.rog_bios_ctrl.dgpu_disable = (biosArray[3] == 'true' ? true : false);
this.supportedAttributes.rog_bios_ctrl.egpu_enable = (biosArray[4] == 'true' ? true : false);
this.supportedAttributes.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);
}
}
}
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;
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;
}
}
}

View File

@@ -0,0 +1,26 @@
{
"compileOnSave": true,
"compilerOptions": {
"target": "es2019",
// "module": "ES2015",
// "moduleResolution": "node",
// "rootDir": "./",
"strict": true,
"outDir": "./target",
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true,
"lib": [ "es2019" ],
"pretty": true,
"sourceMap": true,
"declaration": true,
"removeComments": true,
"incremental": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"allowJs": true
},
"include": [
"src/*.ts",
"src/**/*.ts"
]
}