mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
Compare commits
162 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22e26adfb6 | ||
|
|
4730e645ba | ||
|
|
d203fab70d | ||
|
|
792fae3ed7 | ||
|
|
e443ab00c9 | ||
|
|
aee54f5756 | ||
|
|
00904e9603 | ||
|
|
b1212585e2 | ||
|
|
faca084cff | ||
|
|
89dc0b3501 | ||
|
|
ea988279a8 | ||
|
|
219bd559b6 | ||
|
|
ad1ef9b8a2 | ||
|
|
59795c605c | ||
|
|
a36ac2b6d3 | ||
|
|
a20837f252 | ||
|
|
1353fe3fdb | ||
|
|
770bd12a5c | ||
|
|
af2f5592f0 | ||
|
|
9686c41ac4 | ||
|
|
fbdb0514d2 | ||
|
|
1f5650d26b | ||
|
|
14db97c476 | ||
|
|
66a501ecf6 | ||
|
|
6b129763d4 | ||
|
|
a0368d4345 | ||
|
|
f2f090a88f | ||
|
|
6c7e1a6467 | ||
|
|
92ca7bc70d | ||
|
|
dd1e6b845b | ||
|
|
882fa9bed8 | ||
|
|
9c7dfb4030 | ||
|
|
f855908c82 | ||
|
|
293a087b8a | ||
|
|
fd72a04bb8 | ||
|
|
f131a3fa70 | ||
|
|
ccf8d8df91 | ||
|
|
b970d364f7 | ||
|
|
1da68ea69d | ||
|
|
e62e7e8eca | ||
|
|
1b1d10c461 | ||
|
|
14ea0f6d83 | ||
|
|
5107a6c39c | ||
|
|
2c77ec9e24 | ||
|
|
817a66bdf1 | ||
|
|
664a3d5533 | ||
|
|
37bc5e45b9 | ||
|
|
a18692ef1e | ||
|
|
1b023d0f5f | ||
|
|
74f74e73c4 | ||
|
|
9c7df9ad39 | ||
|
|
94adf5d24d | ||
|
|
8dbdb68175 | ||
|
|
89002eb5ec | ||
|
|
dc9ef8cf54 | ||
|
|
667697d042 | ||
|
|
bc92fa11f9 | ||
|
|
f5d5681b49 | ||
|
|
1c8e50843b | ||
|
|
487d140bd5 | ||
|
|
661ea8d3bf | ||
|
|
28d1ed6ab3 | ||
|
|
903b978e86 | ||
|
|
519f6bd46b | ||
|
|
a94a8ca28d | ||
|
|
f9dca2da5d | ||
|
|
df88ff1acb | ||
|
|
cb5aa0f170 | ||
|
|
4ea79f966e | ||
|
|
b8bc1a01b3 | ||
|
|
0e5d1815bd | ||
|
|
64e8cb65d0 | ||
|
|
7122fbaca8 | ||
|
|
3142353f98 | ||
|
|
484ca692ad | ||
|
|
1ebdfada96 | ||
|
|
3bc9dfcda1 | ||
|
|
895e5d2ca3 | ||
|
|
564992719e | ||
|
|
a737d240be | ||
|
|
d89c1ebf26 | ||
|
|
be7686bb46 | ||
|
|
4f70055f85 | ||
|
|
91ca049298 | ||
|
|
635d0378ac | ||
|
|
1c729316f7 | ||
|
|
4701c019a8 | ||
|
|
ca0d8bda4b | ||
|
|
a271ffbb10 | ||
|
|
00babaf949 | ||
|
|
2f844ac151 | ||
|
|
5178bf1d1a | ||
|
|
116afb9b6c | ||
|
|
4468a58487 | ||
|
|
2f73577e91 | ||
|
|
c1cffc8f59 | ||
|
|
6d8f85c154 | ||
|
|
0674e7f61c | ||
|
|
fde2f3ba15 | ||
|
|
70493d1a93 | ||
|
|
c20d0a76a0 | ||
|
|
e6952e241a | ||
|
|
b40812928a | ||
|
|
8cdc9773c9 | ||
|
|
8d30282edf | ||
|
|
4ba44560a9 | ||
|
|
cdc9ca7b58 | ||
|
|
7eae7c5664 | ||
|
|
739a0ffa63 | ||
|
|
637360095c | ||
|
|
4b34ab83fb | ||
|
|
ac605cbc00 | ||
|
|
4b38e5daa6 | ||
|
|
1c007b4216 | ||
|
|
193f9dfa1e | ||
|
|
1366422d96 | ||
|
|
4e778a3d28 | ||
|
|
be05508110 | ||
|
|
9119229d41 | ||
|
|
5c43c31331 | ||
|
|
014604724f | ||
|
|
7d076368e9 | ||
|
|
5d6ed5c365 | ||
|
|
a2b8f0f93c | ||
|
|
5fe8416c65 | ||
|
|
1b4d7a95af | ||
|
|
e8627fde4c | ||
|
|
6b0edc6da1 | ||
|
|
f6ad631a0f | ||
|
|
f6393a3926 | ||
|
|
d51384c3a1 | ||
|
|
78f18959fb | ||
|
|
7a661a585e | ||
|
|
f4f7a1e648 | ||
|
|
b6e3e5e823 | ||
|
|
41b1bd23d6 | ||
|
|
69458a0595 | ||
|
|
5fd107df27 | ||
|
|
2558057e9f | ||
|
|
8111daaf1d | ||
|
|
672acb234f | ||
|
|
9725062fb9 | ||
|
|
c7b1624313 | ||
|
|
67b97f1d43 | ||
|
|
6498fd1349 | ||
|
|
e371229b6c | ||
|
|
0fac33a8ff | ||
|
|
b0da062577 | ||
|
|
ca41bd59de | ||
|
|
efcad3f6f9 | ||
|
|
fa2255cbaf | ||
|
|
02b9bac899 | ||
|
|
a1fcf5023c | ||
|
|
2f8ea80e6d | ||
|
|
b798cf6a4e | ||
|
|
3da848d131 | ||
|
|
a88c33c201 | ||
|
|
7b0f037cba | ||
|
|
91b1456d06 | ||
|
|
c3b02a2bb0 | ||
|
|
8e4b7d53f4 | ||
|
|
a44145f487 |
@@ -2,11 +2,17 @@
|
||||
|
||||
set -e
|
||||
|
||||
echo 'find -name \*.slint | xargs slint-tr-extractor -o rog-control-center/translations/en/rog-control-center.po'
|
||||
find -name \*.slint | xargs slint-tr-extractor -o rog-control-center/translations/en/rog-control-center.po
|
||||
|
||||
echo '+cargo +nightly fmt --all -- --check'
|
||||
cargo +nightly fmt --all -- --check
|
||||
|
||||
echo '+cargo clippy --all -- -D warnings'
|
||||
cargo clippy --all -- -D warnings
|
||||
|
||||
echo '+cargo test --all'
|
||||
cargo test --all
|
||||
cargo test --all -- --test-threads=1
|
||||
|
||||
echo '+cargo cranky'
|
||||
cargo cranky
|
||||
cargo cranky
|
||||
|
||||
@@ -17,7 +17,7 @@ image: rust:latest
|
||||
- target/release/.cargo-lock
|
||||
|
||||
before_script:
|
||||
- apt-get update -qq && apt-get install -y -qq libudev-dev libgtk-3-dev grep llvm clang libclang-dev libsdl2-dev libsdl2-gfx-dev
|
||||
- apt-get update -qq && apt-get install -y -qq libinput-dev libseat-dev libudev-dev libgtk-3-dev grep llvm clang libclang-dev libsdl2-dev libsdl2-gfx-dev
|
||||
|
||||
stages:
|
||||
- format
|
||||
@@ -52,7 +52,7 @@ test:
|
||||
<<: *rust_cache
|
||||
script:
|
||||
- mkdir -p .git/hooks > /dev/null
|
||||
- cargo test --all
|
||||
- cargo test --all -- --test-threads=1
|
||||
|
||||
release:
|
||||
only:
|
||||
@@ -63,8 +63,8 @@ release:
|
||||
- make && make vendor
|
||||
artifacts:
|
||||
paths:
|
||||
- vendor_asusctl*.tar.xz
|
||||
- cargo-config
|
||||
- vendor_asusctl*.tar.xz
|
||||
- cargo-config
|
||||
|
||||
pages:
|
||||
stage: deploy
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
## Issue description
|
||||
|
||||
(** I can not support distros which are outdated by default. This includes Ubuntu at least 50% of the time, and definitely includes Mint. **)
|
||||
(Summarize the bug encountered)
|
||||
|
||||
## Steps to reproduce
|
||||
@@ -16,9 +17,16 @@
|
||||
|
||||
## Relevant logs and/or screenshots
|
||||
|
||||
(run `journalctl -b -u supergfxd > ~/supergfxd.log` and attach `~/supergfxd.log`)
|
||||
(run `journalctl -b -u asusd > ~/asusd.log` and attach `~/asusd.log`)
|
||||
|
||||
(Paste any relevant logs - use code blocks (```) to format console output, logs, and code, as
|
||||
it's very hard to read otherwise.)
|
||||
|
||||
## System details
|
||||
|
||||
- Distro:
|
||||
- Kernel: (`uname -r`)
|
||||
- Desktop:
|
||||
- Xorg or wayland: ??
|
||||
|
||||
/label ~bug ~reproducable ~needs-investigation
|
||||
|
||||
480
CHANGELOG.md
480
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
4153
Cargo.lock
generated
4153
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
72
Cargo.toml
72
Cargo.toml
@@ -1,25 +1,57 @@
|
||||
[workspace]
|
||||
members = ["asusctl", "asusd", "asusd-user", "config-traits", "cpuctl", "dmi-id", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center", "simulators"]
|
||||
default-members = ["asusctl", "asusd", "asusd-user", "cpuctl", "rog-control-center"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
version = "5.0.8"
|
||||
rust-version = "1.75"
|
||||
version = "6.0.10"
|
||||
rust-version = "1.77"
|
||||
license = "MPL-2.0"
|
||||
readme = "README.md"
|
||||
authors = ["Luke <luke@ljones.dev>"]
|
||||
repository = "https://gitlab.com/asus-linux/asusctl"
|
||||
homepage = "https://gitlab.com/asus-linux/asusctl"
|
||||
description = "Laptop feature control for ASUS ROG laptops and others"
|
||||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"asusctl",
|
||||
"asusd",
|
||||
"asusd-user",
|
||||
"config-traits",
|
||||
"cpuctl",
|
||||
"dmi-id",
|
||||
"rog-platform",
|
||||
"rog-dbus",
|
||||
"rog-anime",
|
||||
"rog-aura",
|
||||
"rog-profiles",
|
||||
"rog-control-center",
|
||||
"rog-slash",
|
||||
"simulators",
|
||||
]
|
||||
default-members = [
|
||||
"asusctl",
|
||||
"asusd",
|
||||
"asusd-user",
|
||||
"cpuctl",
|
||||
"rog-control-center",
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
tokio = { version = "^1.23.0", default-features = false, features = ["macros", "sync"]}
|
||||
tokio = { version = "^1.36.0", default-features = false, features = [
|
||||
"macros",
|
||||
"sync",
|
||||
"time",
|
||||
"rt-multi-thread",
|
||||
] }
|
||||
concat-idents = "^1.1"
|
||||
dirs = "^4.0"
|
||||
smol = "^1.3"
|
||||
mio = "0.8.11"
|
||||
|
||||
zbus = "~3.14.1"
|
||||
logind-zbus = { version = "~3.1" } #, default-features = false, features = ["non_blocking"] }
|
||||
zbus = "4.2"
|
||||
logind-zbus = { version = "4.0.3" } #, default-features = false, features = ["non_blocking"] }
|
||||
|
||||
serde = "^1.0"
|
||||
serde_derive = "^1.0"
|
||||
serde_json = "^1.0"
|
||||
toml = "^0.5.10"
|
||||
ron = "*"
|
||||
typeshare = "1.0.0"
|
||||
|
||||
@@ -28,7 +60,7 @@ env_logger = "^0.10.0"
|
||||
|
||||
glam = { version = "^0.22", features = ["serde"] }
|
||||
gumdrop = "^0.8"
|
||||
udev = "^0.7"
|
||||
udev = { version = "^0.8", features = ["mio"] }
|
||||
rusb = "^0.9"
|
||||
inotify = "^0.10.0"
|
||||
|
||||
@@ -37,9 +69,9 @@ pix = "^0.13"
|
||||
tinybmp = "^0.4.0"
|
||||
gif = "^0.12.0"
|
||||
|
||||
versions = "4.1"
|
||||
versions = "6.2"
|
||||
|
||||
notify-rust = { git = "https://github.com/flukejones/notify-rust.git", default-features = false, features = ["z"] }
|
||||
notify-rust = { version = "4.11.0", features = ["z", "async"] }
|
||||
|
||||
[profile.release]
|
||||
# thin = 57s, asusd = 9.0M
|
||||
@@ -48,11 +80,15 @@ lto = "fat"
|
||||
debug = false
|
||||
opt-level = 3
|
||||
panic = "abort"
|
||||
#codegen-units = 1
|
||||
codegen-units = 1
|
||||
|
||||
[profile.dev]
|
||||
debug = true
|
||||
opt-level = 1
|
||||
codegen-units = 16
|
||||
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 1
|
||||
codegen-units = 16
|
||||
|
||||
[profile.bench]
|
||||
debug = false
|
||||
@@ -61,4 +97,4 @@ opt-level = 3
|
||||
[workspace.dependencies.cargo-husky]
|
||||
version = "1"
|
||||
default-features = false
|
||||
features = ["user-hooks"]
|
||||
features = ["user-hooks"]
|
||||
|
||||
37
MANUAL.md
37
MANUAL.md
@@ -1,5 +1,7 @@
|
||||
# asusctrl manual
|
||||
|
||||
**NOTE:** this manual is in need of an update in some places. If you find issues please file issue reports.
|
||||
|
||||
`asusd` is a utility for Linux to control many aspects of various ASUS laptops
|
||||
but can also be used with non-asus laptops with reduced features.
|
||||
|
||||
@@ -8,11 +10,10 @@ but can also be used with non-asus laptops with reduced features.
|
||||
- `asusd`: The main system daemon. It is autostarted by a udev rule and systemd unit.
|
||||
- `asusd-user`: The user level daemon. Currently will run an anime sequence, with RGB keyboard sequences soon.
|
||||
- `asusctl`: The CLI for interacting with the system daemon
|
||||
- `asus-notify`: A notification daemon with a user systemd unit that can be enabled.
|
||||
|
||||
## `asusd`
|
||||
|
||||
`asusd` is the main system-level daemon which will control/load/save various settings in a safe way for the user, along with exposing a *safe* dbus interface for these interactions. This section covers only the daemon plus the various configuration file options.
|
||||
`asusd` is the main system-level daemon which will control/load/save various settings in a safe way for the user, along with exposing a _safe_ dbus interface for these interactions. This section covers only the daemon plus the various configuration file options.
|
||||
|
||||
The functionality that `asusd` exposes is:
|
||||
|
||||
@@ -56,6 +57,7 @@ Almost all modern ASUS laptops have charging limit control now. This can be cont
|
||||
```json
|
||||
"bat_charge_limit": 80,
|
||||
```
|
||||
|
||||
where the number is a percentage.
|
||||
|
||||
### Bios control
|
||||
@@ -63,7 +65,7 @@ where the number is a percentage.
|
||||
Some options that you find in Armory Crate are available under this controller, so far there is:
|
||||
|
||||
- POST sound: this is the sound you hear on bios boot post
|
||||
- GPU MUX: this controls if the dGPU is the *only* GPU, making it the main GPU and disabling the iGPU
|
||||
- GPU MUX: this controls if the dGPU is the _only_ GPU, making it the main GPU and disabling the iGPU
|
||||
|
||||
These options are not written to the config file as they are stored in efivars. The only way to change these is to use the exposed safe dbus methods, or use the `asusctl` CLI tool.
|
||||
|
||||
@@ -72,6 +74,7 @@ These options are not written to the config file as they are stored in efivars.
|
||||
asusctl can support setting a power profile via platform_profile drivers. This requires [power-profiles-daemon](https://gitlab.freedesktop.org/hadess/power-profiles-daemon) v0.10.0 minimum. It also requires the kernel patch for platform_profile support to be applied form [here](https://lkml.org/lkml/2021/8/18/1022) - this patch is merged to 5.15 kernel upstream.
|
||||
|
||||
A common use of asusctl is to bind the `fn+f5` (fan) key to `asusctl profile -n` to cycle through the 3 profiles:
|
||||
|
||||
1. Balanced
|
||||
2. Performance
|
||||
3. Quiet
|
||||
@@ -97,7 +100,7 @@ There is one more controller; the support controller. The sole pupose of this co
|
||||
|
||||
## asusd-user
|
||||
|
||||
`asusd-user` is a usermode daemon. The intended purpose is to provide a method for users to run there own custom per-key keyboard effects and modes, AniMe sequences, and possibly their own profiles - all without overwriting the *base* system config. As such some parts of the system daemon will migrate to the user daemon over time with the expectation that the Linux system runs both.
|
||||
`asusd-user` is a usermode daemon. The intended purpose is to provide a method for users to run there own custom per-key keyboard effects and modes, AniMe sequences, and possibly their own profiles - all without overwriting the _base_ system config. As such some parts of the system daemon will migrate to the user daemon over time with the expectation that the Linux system runs both.
|
||||
|
||||
As of now only AniMe is active in this with configuration in `~/.config/rog/`. On first run defaults are created that are intended to work as examples.
|
||||
|
||||
@@ -177,6 +180,7 @@ An Aura config itself is a file with contents:
|
||||
```
|
||||
|
||||
If your laptop supports multizone, `"led"` can also be `"Zone": <one of the following>`
|
||||
|
||||
- `SingleZone` // Keyboards with only one zone
|
||||
- `ZonedKbLeft` // keyboard left
|
||||
- `ZonedKbLeftMid` // keyboard left-middle
|
||||
@@ -238,6 +242,7 @@ Each object in the array can be one of:
|
||||
##### AsusAnimation
|
||||
|
||||
`AsusAnimation` is specifically for running the gif files that Armory Crate comes with. `asusctl` includes all of these in `/usr/share/asusd/anime/asus/`
|
||||
|
||||
```json
|
||||
"AsusAnimation": {
|
||||
"file": "<FILE_PATH>",
|
||||
@@ -260,7 +265,7 @@ Virtually the same as `AsusAnimation` but for png files, typically created in th
|
||||
|
||||
##### ImageAnimation
|
||||
|
||||
`ImageAnimation` can play *any* gif of any size.
|
||||
`ImageAnimation` can play _any_ gif of any size.
|
||||
|
||||
```json
|
||||
"ImageAnimation": {
|
||||
@@ -319,6 +324,7 @@ Must be full path: `"/usr/share/asusd/anime/asus/gaming/Controller.gif"` or `/ho
|
||||
**<FLOAT>**
|
||||
|
||||
A number from 0.0-1.0.
|
||||
|
||||
- `brightness`: If it is brightness it is combined with the system daemon global brightness
|
||||
- `scale`: 1.0 is the original size with lower number shrinking, larger growing
|
||||
- `angle`: Rotation angle in radians
|
||||
@@ -327,6 +333,7 @@ A number from 0.0-1.0.
|
||||
**<TIME>**
|
||||
|
||||
Time is the length of time to run the gif for:
|
||||
|
||||
```json
|
||||
"time": {
|
||||
"Time": {
|
||||
@@ -335,17 +342,23 @@ Time is the length of time to run the gif for:
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
A cycle is how many gif loops to run:
|
||||
|
||||
```json
|
||||
"time": {
|
||||
"Cycles": 2
|
||||
},
|
||||
```
|
||||
|
||||
`Infinite` means that this gif will never end:
|
||||
|
||||
```json
|
||||
"time": "Infinite",
|
||||
```
|
||||
|
||||
`Fade` allows an image or gif to fade in and out, and remain at max brightness to n time:
|
||||
|
||||
```json
|
||||
"time": {
|
||||
"Fade": {
|
||||
@@ -364,6 +377,7 @@ A cycle is how many gif loops to run:
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
`show_for` can be `null`, if it is `null` then the `show_for` becomes `gif_time_length - fade_in - fade_out`.
|
||||
This is period for which the gif or image will be max brightness (as set).
|
||||
|
||||
@@ -404,26 +418,19 @@ asusctl <command> <subcommand> --help
|
||||
|
||||
To switch to next/previous Aura modes you will need to bind both the aura keys (if available) to one of:
|
||||
**Next**
|
||||
|
||||
```
|
||||
asusctl led-mode -n
|
||||
```
|
||||
|
||||
**Previous**
|
||||
|
||||
```
|
||||
asusctl led-mode -p
|
||||
```
|
||||
|
||||
To switch Fan/Thermal profiles you need to bind the Fn+F5 key to `asusctl profile -n`.
|
||||
|
||||
## User NOTIFICATIONS via dbus
|
||||
|
||||
If you have a notifications handler set up, or are using KDE or Gnome then you
|
||||
can enable the user service to get basic notifications when something changes.
|
||||
|
||||
```
|
||||
systemctl --user enable asus-notify.service
|
||||
systemctl --user start asus-notify.service
|
||||
```
|
||||
|
||||
# License & Trademarks
|
||||
|
||||
Mozilla Public License 2 (MPL-2.0)
|
||||
|
||||
16
Makefile
16
Makefile
@@ -1,4 +1,4 @@
|
||||
VERSION := $(shell /usr/bin/grep -Pm1 'version = "(\d.\d.\d)"' Cargo.toml | cut -d'"' -f2)
|
||||
VERSION := $(shell /usr/bin/grep -Pm1 'version = "(\d+.\d+.\d+)"' Cargo.toml | cut -d'"' -f2)
|
||||
|
||||
INSTALL = install
|
||||
INSTALL_PROGRAM = ${INSTALL} -D -m 0755
|
||||
@@ -23,10 +23,10 @@ STRIP_BINARIES ?= 0
|
||||
|
||||
DEBUG ?= 0
|
||||
ifeq ($(DEBUG),0)
|
||||
ARGS += --release
|
||||
ARGS += --release --features "rog-control-center/x11"
|
||||
TARGET = release
|
||||
else
|
||||
ARGS += --profile dev
|
||||
ARGS += --profile dev --features "rog-control-center/x11"
|
||||
TARGET = debug
|
||||
endif
|
||||
|
||||
@@ -123,14 +123,8 @@ bindings:
|
||||
typeshare ./rog-profiles/src/ --lang=typescript --output-file=bindings/ts/profiles.ts
|
||||
typeshare ./rog-platform/src/ --lang=typescript --output-file=bindings/ts/platform.ts
|
||||
|
||||
introspect:
|
||||
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/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/FanCurves -x > bindings/dbus-xml/org-asuslinux-fan-curves-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-*
|
||||
translate:
|
||||
find -name \*.slint | xargs slint-tr-extractor -o rog-control-center/translations/en/rog-control-center.po
|
||||
|
||||
build:
|
||||
ifeq ($(VENDORED),1)
|
||||
|
||||
75
README.md
75
README.md
@@ -11,7 +11,13 @@ Now includes a GUI, `rog-control-center`.
|
||||
|
||||
## Kernel support
|
||||
|
||||
**The minimum supported kernel version is 6.6**
|
||||
**The minimum supported kernel version is 6.10**, which will contain the patches from [here](https://lore.kernel.org/platform-driver-x86/20240404001652.86207-1-luke@ljones.dev/). This is especially required for 2023+ devices and possibly some lat 2022 devices.
|
||||
|
||||
Z13 devices will need [these](https://lore.kernel.org/linux-input/20240416090402.31057-1-luke@ljones.dev/T/#t)
|
||||
|
||||
## X11 support
|
||||
|
||||
X11 is not supported at all, as in I will not help you with X11 issues if there are any due to limited time and it being unmaintained itself. You can however build `rog-control-center` with it enabled `cargo build --features "rog-control-center/x11"`.
|
||||
|
||||
## Goals
|
||||
|
||||
@@ -31,7 +37,7 @@ See the [rog-aura readme](./rog-aura/README.md) for more details.
|
||||
|
||||
## Discord
|
||||
|
||||
[Discord server link](https://discord.gg/WTHnqabm)
|
||||
[](https://discord.gg/z8y99XqPb7)
|
||||
|
||||
## SUPPORTED LAPTOPS
|
||||
|
||||
@@ -41,7 +47,9 @@ to this:
|
||||
```
|
||||
Bus 001 Device 002: ID 0b05:1866 ASUSTek Computer, Inc. N-KEY Device
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
Bus 003 Device 002: ID 0b05:19b6 ASUSTek Computer, Inc. [unknown]
|
||||
```
|
||||
@@ -51,49 +59,32 @@ and AniMe parts should work regardless of your latop make.
|
||||
|
||||
## Implemented
|
||||
|
||||
- [X] System daemon
|
||||
- [X] GUI app (includes tray and notifications)
|
||||
- [X] Setting/modifying built-in LED modes
|
||||
- [X] Per-key LED setting
|
||||
- [X] Fancy LED modes (See examples) (currently being reworked)
|
||||
- [X] AniMatrix display on G14 and M16 models that include it
|
||||
- [X] Set battery charge limit (with kernel supporting this)
|
||||
- [X] Fan curve control on supported laptops (G14/G15, some TUF like FA507)
|
||||
- [X] Toggle bios setting for boot/POST sound
|
||||
- [X] Toggle GPU MUX (g-sync, or called MUX on 2022+ laptops)
|
||||
The list is a bit outdated as many features have been enabled in the Linux kernel with upstream patches and then supported in asusctl suite.
|
||||
|
||||
- [x] System daemon
|
||||
- [x] GUI app (includes tray and notifications)
|
||||
- [x] Setting/modifying built-in LED modes
|
||||
- [x] Per-key LED setting
|
||||
- [x] Fancy LED modes (See examples) (currently being reworked)
|
||||
- [x] AniMatrix display on G14 and M16 models that include it
|
||||
- [x] Set battery charge limit (with kernel supporting this)
|
||||
- [x] Fan curve control on supported laptops (G14/G15, some TUF like FA507)
|
||||
- [x] Toggle bios setting for boot/POST sound
|
||||
- [x] Toggle GPU MUX (g-sync, or called MUX on 2022+ laptops)
|
||||
|
||||
# GUI
|
||||
|
||||
A gui is now in the repo - ROG Control Center. At this time it is still a WIP, but it has almost all features in place already.
|
||||
|
||||

|
||||

|
||||

|
||||
**NOTE**: Xorg is not supported.
|
||||
|
||||
# BUILDING
|
||||
|
||||
Requirements are rust >= 1.75 installed from rustup.io if the distro provided version is too old, and `make`.
|
||||
|
||||
**Ubuntu (unsuported):**
|
||||
|
||||
apt install libgtk-3-dev libpango1.0-dev libgdk-pixbuf-2.0-dev libglib2.0-dev cmake libclang-dev libudev-dev libayatana-appindicator3-1
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
source "$HOME/.cargo/env"
|
||||
make
|
||||
sudo make install
|
||||
|
||||
**popos (unsuported):**
|
||||
|
||||
sudo apt install cmake libclang-dev libudev-dev libgtk-3-dev libclang-dev libglib2.0-dev libatkmm-1.6-dev libpangomm-1.4-dev librust-gdk-pixbuf-dev
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
source "$HOME/.cargo/env"
|
||||
make
|
||||
sudo make install
|
||||
|
||||
Rust and cargo are required, they can be installed from [rustup.rs](https://rustup.rs/) or from the distro repos if newer than 1.75.
|
||||
|
||||
**fedora:**
|
||||
|
||||
dnf install cmake clang-devel systemd-devel glib2-devel cairo-devel atkmm-devel pangomm-devel gdk-pixbuf2-devel gtk3-devel libappindicator-gtk3
|
||||
dnf install cmake clang-devel libinput-devel libseat-devel libgbm-devel libxkbcommon-devel systemd-devel libdrm-devel expat-devel pcre2-devel libzstd-devel gtk3-devel
|
||||
make
|
||||
sudo make install
|
||||
|
||||
@@ -102,28 +93,34 @@ Requirements are rust >= 1.75 installed from rustup.io if the distro provided ve
|
||||
Works with KDE Plasma (without GTK packages)
|
||||
|
||||
zypper in -t pattern devel_basis
|
||||
zypper in rustup make cmake systemd-devel clang-devel llvm-devel gdk-pixbuf-devel cairo-devel pango-devel freetype-devel gtk3-devel libexpat-devel libayatana-indicator3-7
|
||||
zypper in rustup make cmake clang-devel libinput-devel libseat-devel libgbm-devel libxkbcommon-devel systemd-devel libdrm-devel expat-devel pcre2-devel libzstd-devel gtk3-devel
|
||||
make
|
||||
sudo make install
|
||||
|
||||
**Ubuntu, Popos (unsuported):**
|
||||
|
||||
instructions removed as outdated
|
||||
|
||||
## Installing
|
||||
|
||||
- Fedora copr = https://copr.fedorainfracloud.org/coprs/lukenukem/asus-linux/
|
||||
- openSUSE = https://download.opensuse.org/repositories/home:/luke_nukem:/asus/
|
||||
- Ubuntu = not supported due to packaging woes, but you can build and install on your own.
|
||||
|
||||
=======
|
||||
|
||||
The default init method is to use the udev rule, this ensures that the service is
|
||||
started when the device is initialised and ready.
|
||||
|
||||
You may also need to activate the service for debian install. If running Pop!\_OS, I suggest disabling `system76-power` gnome-shell extension and systemd service.
|
||||
|
||||
## Upgrading
|
||||
|
||||
If you are upgrading from a previous installed version, you will need to restart the service or reboot.
|
||||
|
||||
```
|
||||
$ systemctl daemon-reload && systemctl restart asusd
|
||||
```
|
||||
|
||||
You may also need to activate the service for debian install. If running Pop!_OS, I suggest disabling `system76-power` gnome-shell extension and systemd service.
|
||||
|
||||
## Uninstalling
|
||||
|
||||
Run `sudo make uninstall` in the source repo, and remove `/etc/asusd/`.
|
||||
@@ -140,7 +137,7 @@ Dbus introsepction XML requires with `make introspection` requires `anime_sim` t
|
||||
|
||||
## AniMe Matrix simulator
|
||||
|
||||
A simulator using SDL2 can be built using `cargo build --package rog_simulators` and run with `./target/debug/anime_sim`. Once started `asusd` will need restarting to pick it up. If running this sim on a laptop *with* the display, the simulated display will be used instead of the physical display.
|
||||
A simulator using SDL2 can be built using `cargo build --package rog_simulators` and run with `./target/debug/anime_sim`. Once started `asusd` will need restarting to pick it up. If running this sim on a laptop _with_ the display, the simulated display will be used instead of the physical display.
|
||||
|
||||
## Supporting more laptops
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
[package]
|
||||
name = "asusctl"
|
||||
license = "MPL-2.0"
|
||||
authors = ["Luke D Jones <luke@ljones.dev>"]
|
||||
edition = "2021"
|
||||
license.workspace = true
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
rog_anime = { path = "../rog-anime" }
|
||||
rog_slash = { path = "../rog-slash" }
|
||||
rog_aura = { path = "../rog-aura" }
|
||||
rog_dbus = { path = "../rog-dbus" }
|
||||
rog_profiles = { path = "../rog-profiles" }
|
||||
@@ -14,14 +18,11 @@ rog_platform = { path = "../rog-platform" }
|
||||
asusd = { path = "../asusd" }
|
||||
dmi_id = { path = "../dmi-id" }
|
||||
|
||||
ron.workspace = true
|
||||
gumdrop.workspace = true
|
||||
toml.workspace = true
|
||||
zbus.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
gif.workspace = true
|
||||
tinybmp.workspace = true
|
||||
glam.workspace = true
|
||||
rog_dbus = { path = "../rog-dbus" }
|
||||
tokio = { version = "^1.23.0", default-features = false, features = ["macros", "sync", "rt", "time"]}
|
||||
|
||||
cargo-husky.workspace = true
|
||||
cargo-husky.workspace = true
|
||||
|
||||
@@ -3,12 +3,14 @@ use std::error::Error;
|
||||
use std::path::Path;
|
||||
use std::process::exit;
|
||||
|
||||
use rog_anime::usb::get_anime_type;
|
||||
use rog_anime::usb::get_maybe_anime_type;
|
||||
use rog_anime::{AnimeDiagonal, AnimeType};
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let (client, _) = RogDbusClientBlocking::new().unwrap();
|
||||
let conn = Connection::system().unwrap();
|
||||
let proxy = AnimeProxyBlocking::new(&conn).unwrap();
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() != 3 {
|
||||
@@ -24,13 +26,9 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
AnimeType::GA401,
|
||||
)?;
|
||||
|
||||
let anime_type = get_anime_type()?;
|
||||
let anime_type = get_maybe_anime_type()?;
|
||||
|
||||
client
|
||||
.proxies()
|
||||
.anime()
|
||||
.write(matrix.into_data_buffer(anime_type)?)
|
||||
.unwrap();
|
||||
proxy.write(matrix.into_data_buffer(anime_type)?).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
||||
use rog_anime::usb::get_anime_type;
|
||||
use rog_anime::usb::get_maybe_anime_type;
|
||||
use rog_anime::{AnimeDiagonal, AnimeType};
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
// In usable data:
|
||||
// Top row start at 1, ends at 32
|
||||
@@ -11,7 +12,8 @@ use rog_dbus::RogDbusClientBlocking;
|
||||
// 74w x 36h diagonal used by the windows app
|
||||
|
||||
fn main() {
|
||||
let (client, _) = RogDbusClientBlocking::new().unwrap();
|
||||
let conn = Connection::system().unwrap();
|
||||
let proxy = AnimeProxyBlocking::new(&conn).unwrap();
|
||||
|
||||
for step in (2..50).rev() {
|
||||
let mut matrix = AnimeDiagonal::new(AnimeType::GA401, None);
|
||||
@@ -27,10 +29,8 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
let anime_type = get_anime_type().unwrap();
|
||||
client
|
||||
.proxies()
|
||||
.anime()
|
||||
let anime_type = get_maybe_anime_type().unwrap();
|
||||
proxy
|
||||
.write(matrix.into_data_buffer(anime_type).unwrap())
|
||||
.unwrap();
|
||||
sleep(Duration::from_millis(300));
|
||||
|
||||
@@ -2,12 +2,14 @@ use std::env;
|
||||
use std::path::Path;
|
||||
use std::thread::sleep;
|
||||
|
||||
use rog_anime::usb::get_anime_type;
|
||||
use rog_anime::usb::get_maybe_anime_type;
|
||||
use rog_anime::{ActionData, ActionLoader, Sequences};
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
fn main() {
|
||||
let (client, _) = RogDbusClientBlocking::new().unwrap();
|
||||
let conn = Connection::system().unwrap();
|
||||
let proxy = AnimeProxyBlocking::new(&conn).unwrap();
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() != 3 {
|
||||
@@ -17,7 +19,7 @@ fn main() {
|
||||
|
||||
let path = Path::new(&args[1]);
|
||||
let brightness = args[2].parse::<f32>().unwrap();
|
||||
let anime_type = get_anime_type().unwrap();
|
||||
let anime_type = get_maybe_anime_type().unwrap();
|
||||
let mut seq = Sequences::new(anime_type);
|
||||
seq.insert(
|
||||
0,
|
||||
@@ -33,11 +35,7 @@ fn main() {
|
||||
for action in seq.iter() {
|
||||
if let ActionData::Animation(frames) = action {
|
||||
for frame in frames.frames() {
|
||||
client
|
||||
.proxies()
|
||||
.anime()
|
||||
.write(frame.frame().clone())
|
||||
.unwrap();
|
||||
proxy.write(frame.frame().clone()).unwrap();
|
||||
sleep(frame.delay());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use rog_anime::usb::get_anime_type;
|
||||
use rog_anime::usb::get_maybe_anime_type;
|
||||
use rog_anime::{AnimeDataBuffer, AnimeGrid};
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
// In usable data:
|
||||
// Top row start at 1, ends at 32
|
||||
@@ -10,8 +11,10 @@ use rog_dbus::RogDbusClientBlocking;
|
||||
// 74w x 36h diagonal used by the windows app
|
||||
|
||||
fn main() {
|
||||
let (client, _) = RogDbusClientBlocking::new().unwrap();
|
||||
let anime_type = get_anime_type().unwrap();
|
||||
let conn = Connection::system().unwrap();
|
||||
let proxy = AnimeProxyBlocking::new(&conn).unwrap();
|
||||
|
||||
let anime_type = get_maybe_anime_type().unwrap();
|
||||
let mut matrix = AnimeGrid::new(anime_type);
|
||||
let tmp = matrix.get_mut();
|
||||
|
||||
@@ -43,5 +46,5 @@ fn main() {
|
||||
|
||||
let matrix = <AnimeDataBuffer>::try_from(matrix).unwrap();
|
||||
|
||||
client.proxies().anime().write(matrix).unwrap();
|
||||
proxy.write(matrix).unwrap();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
use rog_anime::usb::get_anime_type;
|
||||
use rog_anime::usb::get_maybe_anime_type;
|
||||
use rog_anime::AnimeDataBuffer;
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
// In usable data:
|
||||
// Top row start at 1, ends at 32
|
||||
|
||||
fn main() {
|
||||
let (client, _) = RogDbusClientBlocking::new().unwrap();
|
||||
let anime_type = get_anime_type().unwrap();
|
||||
let conn = Connection::system().unwrap();
|
||||
let proxy = AnimeProxyBlocking::new(&conn).unwrap();
|
||||
let anime_type = get_maybe_anime_type().unwrap();
|
||||
let mut matrix = AnimeDataBuffer::new(anime_type);
|
||||
matrix.data_mut()[1] = 100; // start = 1
|
||||
for n in matrix.data_mut()[2..32].iter_mut() {
|
||||
@@ -127,5 +129,5 @@ fn main() {
|
||||
matrix.data_mut()[1244] = 100; // end
|
||||
println!("{:?}", &matrix);
|
||||
|
||||
client.proxies().anime().write(matrix).unwrap();
|
||||
proxy.write(matrix).unwrap();
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ use std::error::Error;
|
||||
use std::path::Path;
|
||||
use std::process::exit;
|
||||
|
||||
use rog_anime::usb::get_anime_type;
|
||||
use rog_anime::usb::get_maybe_anime_type;
|
||||
use rog_anime::{AnimeDataBuffer, AnimeImage, Vec2};
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let (client, _) = RogDbusClientBlocking::new().unwrap();
|
||||
let conn = Connection::system().unwrap();
|
||||
let proxy = AnimeProxyBlocking::new(&conn).unwrap();
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() != 7 {
|
||||
@@ -18,7 +20,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
let anime_type = get_anime_type()?;
|
||||
let anime_type = get_maybe_anime_type()?;
|
||||
let matrix = AnimeImage::from_png(
|
||||
Path::new(&args[1]),
|
||||
args[2].parse::<f32>().unwrap(),
|
||||
@@ -31,11 +33,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
anime_type,
|
||||
)?;
|
||||
|
||||
client
|
||||
.proxies()
|
||||
.anime()
|
||||
.write(<AnimeDataBuffer>::try_from(&matrix)?)
|
||||
.unwrap();
|
||||
proxy.write(<AnimeDataBuffer>::try_from(&matrix)?).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -7,12 +7,14 @@ use std::process::exit;
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
||||
use rog_anime::usb::get_anime_type;
|
||||
use rog_anime::usb::get_maybe_anime_type;
|
||||
use rog_anime::{AnimeDataBuffer, AnimeImage, Vec2};
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let (client, _) = RogDbusClientBlocking::new().unwrap();
|
||||
let conn = Connection::system().unwrap();
|
||||
let proxy = AnimeProxyBlocking::new(&conn).unwrap();
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() != 7 {
|
||||
@@ -21,7 +23,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
let anime_type = get_anime_type()?;
|
||||
let anime_type = get_maybe_anime_type()?;
|
||||
let mut matrix = AnimeImage::from_png(
|
||||
Path::new(&args[1]),
|
||||
args[2].parse::<f32>().unwrap(),
|
||||
@@ -41,11 +43,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
matrix.update();
|
||||
|
||||
client
|
||||
.proxies()
|
||||
.anime()
|
||||
.write(<AnimeDataBuffer>::try_from(&matrix)?)
|
||||
.unwrap();
|
||||
proxy.write(<AnimeDataBuffer>::try_from(&matrix)?).unwrap();
|
||||
sleep(Duration::from_micros(500));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
//! Using a combination of key-colour array plus a key layout to generate
|
||||
//! outputs.
|
||||
|
||||
use rog_aura::advanced::LedCode;
|
||||
use rog_aura::effects::{AdvancedEffects, Effect};
|
||||
use rog_aura::layouts::KeyLayout;
|
||||
use rog_aura::keyboard::{KeyLayout, LedCode};
|
||||
use rog_aura::Colour;
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
use rog_dbus::zbus_aura::AuraProxyBlocking;
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let layout = KeyLayout::default_layout();
|
||||
|
||||
let (client, _) = RogDbusClientBlocking::new().unwrap();
|
||||
let conn = Connection::system().unwrap();
|
||||
let proxy = AuraProxyBlocking::new(&conn).unwrap();
|
||||
|
||||
let mut seq = AdvancedEffects::new(true);
|
||||
|
||||
@@ -62,7 +63,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
seq.next_state(&layout);
|
||||
let packets = seq.create_packets();
|
||||
|
||||
client.proxies().aura().direct_addressing_raw(packets)?;
|
||||
proxy.direct_addressing_raw(packets)?;
|
||||
std::thread::sleep(std::time::Duration::from_millis(33));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ pub struct LedPowerCommand1 {
|
||||
pub help: bool,
|
||||
#[options(meta = "", help = "Control if LEDs enabled while awake <true/false>")]
|
||||
pub awake: Option<bool>,
|
||||
#[options(meta = "", help = "Use with awake option <true/false>")]
|
||||
pub keyboard: Option<bool>,
|
||||
#[options(meta = "", help = "Use with awake option <true/false>")]
|
||||
pub lightbar: Option<bool>,
|
||||
#[options(help = "Use with awake option, if excluded defaults to false")]
|
||||
pub keyboard: bool,
|
||||
#[options(help = "Use with awake option, if excluded defaults to false")]
|
||||
pub lightbar: bool,
|
||||
#[options(meta = "", help = "Control boot animations <true/false>")]
|
||||
pub boot: Option<bool>,
|
||||
#[options(meta = "", help = "Control suspend animations <true/false>")]
|
||||
@@ -87,6 +87,7 @@ impl FromStr for LedBrightness {
|
||||
}
|
||||
}
|
||||
}
|
||||
#[allow(clippy::to_string_trait_impl)]
|
||||
impl ToString for LedBrightness {
|
||||
fn to_string(&self) -> String {
|
||||
let s = match self.level {
|
||||
@@ -214,29 +215,29 @@ pub struct MultiColourSpeed {
|
||||
#[derive(Options)]
|
||||
pub enum SetAuraBuiltin {
|
||||
#[options(help = "set a single static colour")]
|
||||
Static(SingleColour),
|
||||
Static(SingleColour), // 0
|
||||
#[options(help = "pulse between one or two colours")]
|
||||
Breathe(TwoColourSpeed),
|
||||
Breathe(TwoColourSpeed), // 1
|
||||
#[options(help = "strobe through all colours")]
|
||||
Strobe(SingleSpeed),
|
||||
Strobe(SingleSpeed), // 2
|
||||
#[options(help = "rainbow cycling in one of four directions")]
|
||||
Rainbow(SingleSpeedDirection),
|
||||
Rainbow(SingleSpeedDirection), // 3
|
||||
#[options(help = "rain pattern mimicking raindrops")]
|
||||
Stars(TwoColourSpeed),
|
||||
Stars(TwoColourSpeed), // 4
|
||||
#[options(help = "rain pattern of three preset colours")]
|
||||
Rain(SingleSpeed),
|
||||
Rain(SingleSpeed), // 5
|
||||
#[options(help = "pressed keys are highlighted to fade")]
|
||||
Highlight(SingleColourSpeed),
|
||||
Highlight(SingleColourSpeed), // 6
|
||||
#[options(help = "pressed keys generate horizontal laser")]
|
||||
Laser(SingleColourSpeed),
|
||||
Laser(SingleColourSpeed), // 7
|
||||
#[options(help = "pressed keys ripple outwards like a splash")]
|
||||
Ripple(SingleColourSpeed),
|
||||
Ripple(SingleColourSpeed), // 8
|
||||
#[options(help = "set a rapid pulse")]
|
||||
Pulse(SingleColour),
|
||||
Pulse(SingleColour), // 10
|
||||
#[options(help = "set a vertical line zooming from left")]
|
||||
Comet(SingleColour),
|
||||
Comet(SingleColour), // 11
|
||||
#[options(help = "set a wide vertical line zooming from left")]
|
||||
Flash(SingleColour),
|
||||
Flash(SingleColour), // 12
|
||||
}
|
||||
|
||||
impl Default for SetAuraBuiltin {
|
||||
|
||||
@@ -4,6 +4,7 @@ use rog_platform::platform::ThrottlePolicy;
|
||||
use crate::anime_cli::AnimeCommand;
|
||||
use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin};
|
||||
use crate::fan_curve_cli::FanCurveCommand;
|
||||
use crate::slash_cli::SlashCommand;
|
||||
|
||||
#[derive(Default, Options)]
|
||||
pub struct CliStart {
|
||||
@@ -41,6 +42,8 @@ pub enum CliCommand {
|
||||
Graphics(GraphicsCommand),
|
||||
#[options(name = "anime", help = "Manage AniMe Matrix")]
|
||||
Anime(AnimeCommand),
|
||||
#[options(name = "slash", help = "Manage Slash Ledbar")]
|
||||
Slash(SlashCommand),
|
||||
#[options(help = "Change bios settings")]
|
||||
Bios(BiosCommand),
|
||||
}
|
||||
|
||||
@@ -5,31 +5,39 @@ use std::process::Command;
|
||||
use std::thread::sleep;
|
||||
|
||||
use anime_cli::{AnimeActions, AnimeCommand};
|
||||
use asusd::ctrl_aura::trait_impls::AURA_ZBUS_NAME;
|
||||
use asusd::ctrl_fancurves::FAN_CURVE_ZBUS_NAME;
|
||||
use aura_cli::{LedPowerCommand1, LedPowerCommand2};
|
||||
use dmi_id::DMIID;
|
||||
use fan_curve_cli::FanCurveCommand;
|
||||
use gumdrop::{Opt, Options};
|
||||
use rog_anime::usb::get_anime_type;
|
||||
use rog_anime::usb::get_maybe_anime_type;
|
||||
use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2};
|
||||
use rog_aura::power::KbAuraPowerState;
|
||||
use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraPowerDev};
|
||||
use rog_aura::{self, AuraEffect};
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
use rog_platform::error::PlatformError;
|
||||
use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower};
|
||||
use rog_aura::{self, AuraDeviceType, AuraEffect, PowerZones};
|
||||
use rog_dbus::list_iface_blocking;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use rog_dbus::zbus_aura::AuraProxyBlocking;
|
||||
use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking;
|
||||
use rog_dbus::zbus_platform::PlatformProxyBlocking;
|
||||
use rog_dbus::zbus_slash::SlashProxyBlocking;
|
||||
use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy};
|
||||
use rog_profiles::error::ProfileError;
|
||||
use rog_slash::SlashMode;
|
||||
use ron::ser::PrettyConfig;
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
use crate::aura_cli::{AuraPowerStates, LedBrightness};
|
||||
use crate::cli_opts::*;
|
||||
use crate::slash_cli::SlashCommand;
|
||||
|
||||
mod anime_cli;
|
||||
mod aura_cli;
|
||||
mod cli_opts;
|
||||
mod fan_curve_cli;
|
||||
mod slash_cli;
|
||||
|
||||
fn main() {
|
||||
let self_version = env!("CARGO_PKG_VERSION");
|
||||
println!("Starting version {self_version}");
|
||||
let args: Vec<String> = args().skip(1).collect();
|
||||
|
||||
let missing_argument_k = gumdrop::Error::missing_argument(Opt::Short('k'));
|
||||
@@ -45,13 +53,20 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
if let Ok((dbus, _)) = RogDbusClientBlocking::new().map_err(|e| {
|
||||
let conn = Connection::system().unwrap();
|
||||
if let Ok(platform_proxy) = PlatformProxyBlocking::new(&conn).map_err(|e| {
|
||||
check_service("asusd");
|
||||
println!("\nError: {e}\n");
|
||||
print_info();
|
||||
}) {
|
||||
let supported_properties = dbus.proxies().platform().supported_properties().unwrap();
|
||||
let supported_interfaces = dbus.proxies().platform().supported_interfaces().unwrap();
|
||||
let asusd_version = platform_proxy.version().unwrap();
|
||||
if asusd_version != self_version {
|
||||
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
|
||||
return;
|
||||
}
|
||||
|
||||
let supported_properties = platform_proxy.supported_properties().unwrap();
|
||||
let supported_interfaces = list_iface_blocking().unwrap();
|
||||
|
||||
if parsed.version {
|
||||
println!("asusctl v{}", env!("CARGO_PKG_VERSION"));
|
||||
@@ -59,7 +74,7 @@ fn main() {
|
||||
print_info();
|
||||
}
|
||||
|
||||
if let Err(err) = do_parsed(&parsed, &supported_interfaces, &supported_properties, &dbus) {
|
||||
if let Err(err) = do_parsed(&parsed, &supported_interfaces, &supported_properties, conn) {
|
||||
print_error_help(&*err, &supported_interfaces, &supported_properties);
|
||||
}
|
||||
}
|
||||
@@ -75,7 +90,10 @@ fn print_error_help(
|
||||
print_info();
|
||||
println!();
|
||||
println!("Supported interfaces:\n\n{:#?}\n", supported_interfaces);
|
||||
println!("Supported properties:\n\n{:#?}\n", supported_properties);
|
||||
println!(
|
||||
"Supported properties on Platform:\n\n{:#?}\n",
|
||||
supported_properties
|
||||
);
|
||||
}
|
||||
|
||||
fn print_info() {
|
||||
@@ -104,23 +122,64 @@ fn check_service(name: &str) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn find_aura_iface() -> Result<Vec<AuraProxyBlocking<'static>>, Box<dyn std::error::Error>> {
|
||||
let conn = zbus::blocking::Connection::system().unwrap();
|
||||
let f =
|
||||
zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").unwrap();
|
||||
let interfaces = f.get_managed_objects().unwrap();
|
||||
let mut aura_paths = Vec::new();
|
||||
for v in interfaces.iter() {
|
||||
// let o: Vec<zbus::names::OwnedInterfaceName> = v.1.keys().map(|e|
|
||||
// e.to_owned()).collect(); println!("{}, {:?}", v.0, o);
|
||||
for k in v.1.keys() {
|
||||
if k.as_str() == "org.asuslinux.Aura" {
|
||||
println!("Found aura device at {}, {}", v.0, k);
|
||||
aura_paths.push(v.0.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
if aura_paths.len() > 1 {
|
||||
println!("Multiple aura devices found: {aura_paths:?}");
|
||||
println!("TODO: enable selection");
|
||||
}
|
||||
if !aura_paths.is_empty() {
|
||||
let mut ctrl = Vec::new();
|
||||
for path in aura_paths {
|
||||
ctrl.push(
|
||||
AuraProxyBlocking::builder(&conn)
|
||||
.path(path.clone())?
|
||||
.destination("org.asuslinux.Daemon")?
|
||||
.build()?,
|
||||
);
|
||||
}
|
||||
return Ok(ctrl);
|
||||
}
|
||||
|
||||
Err("No Aura interface".into())
|
||||
}
|
||||
|
||||
fn do_parsed(
|
||||
parsed: &CliStart,
|
||||
supported_interfaces: &[String],
|
||||
supported_properties: &[Properties],
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
conn: Connection,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
match &parsed.command {
|
||||
Some(CliCommand::LedMode(mode)) => handle_led_mode(dbus, supported_interfaces, mode)?,
|
||||
Some(CliCommand::LedPow1(pow)) => handle_led_power1(dbus, supported_interfaces, pow)?,
|
||||
Some(CliCommand::LedPow2(pow)) => handle_led_power2(dbus, supported_interfaces, pow)?,
|
||||
Some(CliCommand::Profile(cmd)) => handle_throttle_profile(dbus, supported_properties, cmd)?,
|
||||
Some(CliCommand::LedMode(mode)) => handle_led_mode(&find_aura_iface()?, mode)?,
|
||||
Some(CliCommand::LedPow1(pow)) => handle_led_power1(&find_aura_iface()?, pow)?,
|
||||
Some(CliCommand::LedPow2(pow)) => handle_led_power2(&find_aura_iface()?, pow)?,
|
||||
Some(CliCommand::Profile(cmd)) => {
|
||||
handle_throttle_profile(&conn, supported_properties, cmd)?
|
||||
}
|
||||
Some(CliCommand::FanCurve(cmd)) => {
|
||||
handle_fan_curve(dbus, supported_interfaces, cmd)?;
|
||||
handle_fan_curve(&conn, cmd)?;
|
||||
}
|
||||
Some(CliCommand::Graphics(_)) => do_gfx(),
|
||||
Some(CliCommand::Anime(cmd)) => handle_anime(dbus, cmd)?,
|
||||
Some(CliCommand::Bios(cmd)) => handle_platform_properties(dbus, supported_properties, cmd)?,
|
||||
Some(CliCommand::Anime(cmd)) => handle_anime(&conn, cmd)?,
|
||||
Some(CliCommand::Slash(cmd)) => handle_slash(&conn, cmd)?,
|
||||
Some(CliCommand::Bios(cmd)) => {
|
||||
handle_platform_properties(&conn, supported_properties, cmd)?
|
||||
}
|
||||
None => {
|
||||
if (!parsed.show_supported
|
||||
&& parsed.kbd_bright.is_none()
|
||||
@@ -132,16 +191,50 @@ fn do_parsed(
|
||||
println!("{}", CliStart::usage());
|
||||
println!();
|
||||
if let Some(cmdlist) = CliStart::command_list() {
|
||||
let dev_type = dbus.proxies().aura().device_type()?;
|
||||
let dev_type = if let Ok(proxy) = find_aura_iface() {
|
||||
// TODO: commands on all?
|
||||
proxy
|
||||
.first()
|
||||
.unwrap()
|
||||
.device_type()
|
||||
.unwrap_or(AuraDeviceType::Unknown)
|
||||
} else {
|
||||
AuraDeviceType::Unknown
|
||||
};
|
||||
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
|
||||
for command in commands.iter().filter(|command| {
|
||||
if !dev_type.is_old_style()
|
||||
&& !dev_type.is_tuf_style()
|
||||
if command.trim().starts_with("fan-curve")
|
||||
&& !supported_interfaces
|
||||
.contains(&"org.asuslinux.FanCurves".to_string())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if command.trim().starts_with("anime")
|
||||
&& !supported_interfaces.contains(&"org.asuslinux.Anime".to_string())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if command.trim().starts_with("slash")
|
||||
&& !supported_interfaces.contains(&"org.asuslinux.Slash".to_string())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if command.trim().starts_with("bios")
|
||||
&& !supported_interfaces.contains(&"org.asuslinux.Platform".to_string())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if !dev_type.is_old_laptop()
|
||||
&& !dev_type.is_tuf_laptop()
|
||||
&& command.trim().starts_with("led-pow-1")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if !dev_type.is_new_style() && command.trim().starts_with("led-pow-2") {
|
||||
if !dev_type.is_new_laptop() && command.trim().starts_with("led-pow-2") {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
@@ -158,26 +251,41 @@ fn do_parsed(
|
||||
}
|
||||
|
||||
if let Some(brightness) = &parsed.kbd_bright {
|
||||
match brightness.level() {
|
||||
None => {
|
||||
let level = dbus.proxies().aura().brightness()?;
|
||||
println!("Current keyboard led brightness: {level:?}");
|
||||
if let Ok(aura) = find_aura_iface() {
|
||||
for aura in aura.iter() {
|
||||
match brightness.level() {
|
||||
None => {
|
||||
let level = aura.brightness()?;
|
||||
println!("Current keyboard led brightness: {level:?}");
|
||||
}
|
||||
Some(level) => aura.set_brightness(rog_aura::LedBrightness::from(level))?,
|
||||
}
|
||||
}
|
||||
Some(level) => dbus
|
||||
.proxies()
|
||||
.aura()
|
||||
.set_brightness(rog_aura::LedBrightness::from(level))?,
|
||||
} else {
|
||||
println!("No aura interface found");
|
||||
}
|
||||
}
|
||||
|
||||
if parsed.next_kbd_bright {
|
||||
let brightness = dbus.proxies().aura().brightness()?;
|
||||
dbus.proxies().aura().set_brightness(brightness.next())?;
|
||||
if let Ok(aura) = find_aura_iface() {
|
||||
for aura in aura.iter() {
|
||||
let brightness = aura.brightness()?;
|
||||
aura.set_brightness(brightness.next())?;
|
||||
}
|
||||
} else {
|
||||
println!("No aura interface found");
|
||||
}
|
||||
}
|
||||
|
||||
if parsed.prev_kbd_bright {
|
||||
let brightness = dbus.proxies().aura().brightness()?;
|
||||
dbus.proxies().aura().set_brightness(brightness.prev())?;
|
||||
if let Ok(aura) = find_aura_iface() {
|
||||
for aura in aura.iter() {
|
||||
let brightness = aura.brightness()?;
|
||||
aura.set_brightness(brightness.prev())?;
|
||||
}
|
||||
} else {
|
||||
println!("No aura interface found");
|
||||
}
|
||||
}
|
||||
|
||||
if parsed.show_supported {
|
||||
@@ -186,22 +294,24 @@ fn do_parsed(
|
||||
"Supported Platform Properties:\n{:#?}",
|
||||
supported_properties
|
||||
);
|
||||
if supported_interfaces.contains(&"Aura".to_owned()) {
|
||||
let bright = dbus.proxies().aura().supported_brightness()?;
|
||||
let modes = dbus.proxies().aura().supported_basic_modes()?;
|
||||
let zones = dbus.proxies().aura().supported_basic_zones()?;
|
||||
let power = dbus.proxies().aura().supported_power_zones()?;
|
||||
if let Ok(aura) = find_aura_iface() {
|
||||
// TODO: multiple RGB check
|
||||
let bright = aura.first().unwrap().supported_brightness()?;
|
||||
let modes = aura.first().unwrap().supported_basic_modes()?;
|
||||
let zones = aura.first().unwrap().supported_basic_zones()?;
|
||||
let power = aura.first().unwrap().supported_power_zones()?;
|
||||
println!("Supported Keyboard Brightness:\n{:#?}", bright);
|
||||
println!("Supported Aura Modes:\n{:#?}", modes);
|
||||
println!("Supported Aura Zones:\n{:#?}", zones);
|
||||
println!("Supported Aura Power Zones:\n{:#?}", power);
|
||||
} else {
|
||||
println!("No aura interface found");
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(chg_limit) = parsed.chg_limit {
|
||||
dbus.proxies()
|
||||
.platform()
|
||||
.set_charge_control_end_threshold(chg_limit)?;
|
||||
let proxy = PlatformProxyBlocking::new(&conn)?;
|
||||
proxy.set_charge_control_end_threshold(chg_limit)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -215,10 +325,7 @@ fn do_gfx() {
|
||||
println!("This command will be removed in future");
|
||||
}
|
||||
|
||||
fn handle_anime(
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
cmd: &AnimeCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
fn handle_anime(conn: &Connection, cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if (cmd.command.is_none()
|
||||
&& cmd.enable_display.is_none()
|
||||
&& cmd.enable_powersave_anim.is_none()
|
||||
@@ -235,30 +342,31 @@ fn handle_anime(
|
||||
println!("\n{}", lst);
|
||||
}
|
||||
}
|
||||
let proxy = AnimeProxyBlocking::new(conn)?;
|
||||
if let Some(enable) = cmd.enable_display {
|
||||
dbus.proxies().anime().set_enable_display(enable)?;
|
||||
proxy.set_enable_display(enable)?;
|
||||
}
|
||||
if let Some(enable) = cmd.enable_powersave_anim {
|
||||
dbus.proxies().anime().set_builtins_enabled(enable)?;
|
||||
proxy.set_builtins_enabled(enable)?;
|
||||
}
|
||||
if let Some(bright) = cmd.brightness {
|
||||
dbus.proxies().anime().set_brightness(bright)?;
|
||||
proxy.set_brightness(bright)?;
|
||||
}
|
||||
if let Some(enable) = cmd.off_when_lid_closed {
|
||||
dbus.proxies().anime().set_off_when_lid_closed(enable)?;
|
||||
proxy.set_off_when_lid_closed(enable)?;
|
||||
}
|
||||
if let Some(enable) = cmd.off_when_suspended {
|
||||
dbus.proxies().anime().set_off_when_suspended(enable)?;
|
||||
proxy.set_off_when_suspended(enable)?;
|
||||
}
|
||||
if let Some(enable) = cmd.off_when_unplugged {
|
||||
dbus.proxies().anime().set_off_when_unplugged(enable)?;
|
||||
proxy.set_off_when_unplugged(enable)?;
|
||||
}
|
||||
if cmd.off_with_his_head.is_some() {
|
||||
println!("Did Alice _really_ make it back from Wonderland?");
|
||||
}
|
||||
|
||||
let mut anime_type = get_anime_type()?;
|
||||
if let AnimeType::Unknown = anime_type {
|
||||
let mut anime_type = get_maybe_anime_type()?;
|
||||
if let AnimeType::Unsupported = anime_type {
|
||||
if let Some(model) = cmd.override_type {
|
||||
anime_type = model;
|
||||
}
|
||||
@@ -267,7 +375,7 @@ fn handle_anime(
|
||||
if cmd.clear {
|
||||
let data = vec![255u8; anime_type.data_length()];
|
||||
let tmp = AnimeDataBuffer::from_vec(anime_type, data)?;
|
||||
dbus.proxies().anime().write(tmp)?;
|
||||
proxy.write(tmp)?;
|
||||
}
|
||||
|
||||
if let Some(action) = cmd.command.as_ref() {
|
||||
@@ -291,9 +399,7 @@ fn handle_anime(
|
||||
anime_type,
|
||||
)?;
|
||||
|
||||
dbus.proxies()
|
||||
.anime()
|
||||
.write(<AnimeDataBuffer>::try_from(&matrix)?)?;
|
||||
proxy.write(<AnimeDataBuffer>::try_from(&matrix)?)?;
|
||||
}
|
||||
AnimeActions::PixelImage(image) => {
|
||||
if image.help_requested() || image.path.is_empty() {
|
||||
@@ -312,9 +418,7 @@ fn handle_anime(
|
||||
anime_type,
|
||||
)?;
|
||||
|
||||
dbus.proxies()
|
||||
.anime()
|
||||
.write(matrix.into_data_buffer(anime_type)?)?;
|
||||
proxy.write(matrix.into_data_buffer(anime_type)?)?;
|
||||
}
|
||||
AnimeActions::Gif(gif) => {
|
||||
if gif.help_requested() || gif.path.is_empty() {
|
||||
@@ -339,7 +443,7 @@ fn handle_anime(
|
||||
let mut loops = gif.loops as i32;
|
||||
loop {
|
||||
for frame in matrix.frames() {
|
||||
dbus.proxies().anime().write(frame.frame().clone())?;
|
||||
proxy.write(frame.frame().clone())?;
|
||||
sleep(frame.delay());
|
||||
}
|
||||
if loops >= 0 {
|
||||
@@ -370,7 +474,7 @@ fn handle_anime(
|
||||
let mut loops = gif.loops as i32;
|
||||
loop {
|
||||
for frame in matrix.frames() {
|
||||
dbus.proxies().anime().write(frame.frame().clone())?;
|
||||
proxy.write(frame.frame().clone())?;
|
||||
sleep(frame.delay());
|
||||
}
|
||||
if loops >= 0 {
|
||||
@@ -391,14 +495,12 @@ fn handle_anime(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
dbus.proxies()
|
||||
.anime()
|
||||
.set_builtin_animations(rog_anime::Animations {
|
||||
boot: builtins.boot,
|
||||
awake: builtins.awake,
|
||||
sleep: builtins.sleep,
|
||||
shutdown: builtins.shutdown,
|
||||
})?;
|
||||
proxy.set_builtin_animations(rog_anime::Animations {
|
||||
boot: builtins.boot,
|
||||
awake: builtins.awake,
|
||||
sleep: builtins.sleep,
|
||||
shutdown: builtins.shutdown,
|
||||
})?;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -414,16 +516,50 @@ fn verify_brightness(brightness: f32) {
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_led_mode(
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
supported: &[String],
|
||||
mode: &LedModeCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if !supported.contains(&AURA_ZBUS_NAME.to_string()) {
|
||||
println!("This laptop does not support power options");
|
||||
return Err(PlatformError::NotSupported.into());
|
||||
fn handle_slash(conn: &Connection, cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if (cmd.brightness.is_none()
|
||||
&& cmd.interval.is_none()
|
||||
&& cmd.slash_mode.is_none()
|
||||
&& !cmd.list
|
||||
&& !cmd.enable
|
||||
&& !cmd.disable)
|
||||
|| cmd.help
|
||||
{
|
||||
println!("Missing arg or command\n\n{}", cmd.self_usage());
|
||||
if let Some(lst) = cmd.self_command_list() {
|
||||
println!("\n{}", lst);
|
||||
}
|
||||
}
|
||||
let proxy = SlashProxyBlocking::new(conn)?;
|
||||
if cmd.enable {
|
||||
proxy.set_enabled(true)?;
|
||||
}
|
||||
if cmd.disable {
|
||||
proxy.set_enabled(false)?;
|
||||
}
|
||||
if let Some(brightness) = cmd.brightness {
|
||||
proxy.set_brightness(brightness)?;
|
||||
}
|
||||
if let Some(interval) = cmd.interval {
|
||||
proxy.set_interval(interval)?;
|
||||
}
|
||||
if let Some(slash_mode) = cmd.slash_mode {
|
||||
proxy.set_slash_mode(slash_mode)?;
|
||||
}
|
||||
if cmd.list {
|
||||
let res = SlashMode::list();
|
||||
for p in &res {
|
||||
println!("{:?}", p);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_led_mode(
|
||||
aura: &[AuraProxyBlocking],
|
||||
mode: &LedModeCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if mode.command.is_none() && !mode.prev_mode && !mode.next_mode {
|
||||
if !mode.help {
|
||||
println!("Missing arg or command\n");
|
||||
@@ -433,7 +569,8 @@ fn handle_led_mode(
|
||||
|
||||
if let Some(cmdlist) = LedModeCommand::command_list() {
|
||||
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
|
||||
let modes = dbus.proxies().aura().supported_basic_modes()?;
|
||||
// TODO: multiple rgb check
|
||||
let modes = aura.first().unwrap().supported_basic_modes()?;
|
||||
for command in commands.iter().filter(|command| {
|
||||
for mode in &modes {
|
||||
if command
|
||||
@@ -462,71 +599,67 @@ fn handle_led_mode(
|
||||
return Ok(());
|
||||
}
|
||||
if mode.next_mode {
|
||||
let mode = dbus.proxies().aura().led_mode()?;
|
||||
let modes = dbus.proxies().aura().supported_basic_modes()?;
|
||||
let mut pos = modes.iter().position(|m| *m == mode).unwrap() + 1;
|
||||
if pos >= modes.len() {
|
||||
pos = 0;
|
||||
for aura in aura {
|
||||
let mode = aura.led_mode()?;
|
||||
let modes = aura.supported_basic_modes()?;
|
||||
let mut pos = modes.iter().position(|m| *m == mode).unwrap() + 1;
|
||||
if pos >= modes.len() {
|
||||
pos = 0;
|
||||
}
|
||||
aura.set_led_mode(modes[pos])?;
|
||||
}
|
||||
dbus.proxies().aura().set_led_mode(modes[pos])?;
|
||||
} else if mode.prev_mode {
|
||||
let mode = dbus.proxies().aura().led_mode()?;
|
||||
let modes = dbus.proxies().aura().supported_basic_modes()?;
|
||||
let mut pos = modes.iter().position(|m| *m == mode).unwrap();
|
||||
if pos == 0 {
|
||||
pos = modes.len() - 1;
|
||||
} else {
|
||||
pos -= 1;
|
||||
for aura in aura {
|
||||
let mode = aura.led_mode()?;
|
||||
let modes = aura.supported_basic_modes()?;
|
||||
let mut pos = modes.iter().position(|m| *m == mode).unwrap();
|
||||
if pos == 0 {
|
||||
pos = modes.len() - 1;
|
||||
} else {
|
||||
pos -= 1;
|
||||
}
|
||||
aura.set_led_mode(modes[pos])?;
|
||||
}
|
||||
dbus.proxies().aura().set_led_mode(modes[pos])?;
|
||||
} else if let Some(mode) = mode.command.as_ref() {
|
||||
if mode.help_requested() {
|
||||
println!("{}", mode.self_usage());
|
||||
return Ok(());
|
||||
}
|
||||
dbus.proxies()
|
||||
.aura()
|
||||
.set_led_mode_data(<AuraEffect>::from(mode))?;
|
||||
for aura in aura {
|
||||
aura.set_led_mode_data(<AuraEffect>::from(mode))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_led_power1(
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
supported: &[String],
|
||||
aura: &[AuraProxyBlocking],
|
||||
power: &LedPowerCommand1,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if !supported.contains(&AURA_ZBUS_NAME.to_string()) {
|
||||
println!("This laptop does not support power options");
|
||||
return Err(PlatformError::NotSupported.into());
|
||||
}
|
||||
let dev_type = dbus.proxies().aura().device_type()?;
|
||||
if !dev_type.is_old_style() && !dev_type.is_tuf_style() {
|
||||
println!("This option applies only to keyboards 2021+");
|
||||
}
|
||||
|
||||
if power.awake.is_none()
|
||||
&& power.sleep.is_none()
|
||||
&& power.boot.is_none()
|
||||
&& power.keyboard.is_none()
|
||||
&& power.lightbar.is_none()
|
||||
{
|
||||
if !power.help {
|
||||
println!("Missing arg or command\n");
|
||||
for aura in aura {
|
||||
let dev_type = aura.device_type()?;
|
||||
if !dev_type.is_old_laptop() && !dev_type.is_tuf_laptop() {
|
||||
println!("This option applies only to keyboards 2021+");
|
||||
}
|
||||
println!("{}\n", power.self_usage());
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if dev_type.is_old_style() {
|
||||
handle_led_power_1_do_1866(dbus, power)?;
|
||||
return Ok(());
|
||||
}
|
||||
if power.awake.is_none()
|
||||
&& power.sleep.is_none()
|
||||
&& power.boot.is_none()
|
||||
&& !power.keyboard
|
||||
&& !power.lightbar
|
||||
{
|
||||
if !power.help {
|
||||
println!("Missing arg or command\n");
|
||||
}
|
||||
println!("{}\n", power.self_usage());
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if dev_type.is_tuf_style() {
|
||||
handle_led_power_1_do_tuf(dbus, power)?;
|
||||
return Ok(());
|
||||
if dev_type.is_old_laptop() || dev_type.is_tuf_laptop() {
|
||||
handle_led_power_1_do_1866(aura, power)?;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
println!("These options are for keyboards of product ID 0x1866 or TUF only");
|
||||
@@ -534,144 +667,101 @@ fn handle_led_power1(
|
||||
}
|
||||
|
||||
fn handle_led_power_1_do_1866(
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
aura: &AuraProxyBlocking,
|
||||
power: &LedPowerCommand1,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut enabled: Vec<AuraDevRog1> = Vec::new();
|
||||
let mut disabled: Vec<AuraDevRog1> = Vec::new();
|
||||
|
||||
let mut check = |e: Option<bool>, a: AuraDevRog1| {
|
||||
if let Some(arg) = e {
|
||||
if arg {
|
||||
enabled.push(a);
|
||||
} else {
|
||||
disabled.push(a);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
check(power.awake, AuraDevRog1::Awake);
|
||||
check(power.boot, AuraDevRog1::Boot);
|
||||
check(power.sleep, AuraDevRog1::Sleep);
|
||||
check(power.keyboard, AuraDevRog1::Keyboard);
|
||||
check(power.lightbar, AuraDevRog1::Lightbar);
|
||||
|
||||
let data = AuraPowerDev {
|
||||
old_rog: enabled,
|
||||
..Default::default()
|
||||
};
|
||||
dbus.proxies().aura().set_led_power((data, true))?;
|
||||
|
||||
let data = AuraPowerDev {
|
||||
old_rog: disabled,
|
||||
..Default::default()
|
||||
};
|
||||
dbus.proxies().aura().set_led_power((data, false))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_led_power_1_do_tuf(
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
power: &LedPowerCommand1,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut enabled: Vec<AuraDevTuf> = Vec::new();
|
||||
let mut disabled: Vec<AuraDevTuf> = Vec::new();
|
||||
|
||||
let mut check = |e: Option<bool>, a: AuraDevTuf| {
|
||||
if let Some(arg) = e {
|
||||
if arg {
|
||||
enabled.push(a);
|
||||
} else {
|
||||
disabled.push(a);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
check(power.awake, AuraDevTuf::Awake);
|
||||
check(power.boot, AuraDevTuf::Boot);
|
||||
check(power.sleep, AuraDevTuf::Sleep);
|
||||
check(power.keyboard, AuraDevTuf::Keyboard);
|
||||
|
||||
let data = AuraPowerDev {
|
||||
tuf: enabled,
|
||||
..Default::default()
|
||||
};
|
||||
dbus.proxies().aura().set_led_power((data, true))?;
|
||||
|
||||
let data = AuraPowerDev {
|
||||
tuf: disabled,
|
||||
..Default::default()
|
||||
};
|
||||
dbus.proxies().aura().set_led_power((data, false))?;
|
||||
let mut states = Vec::new();
|
||||
if power.keyboard {
|
||||
states.push(AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: power.boot.unwrap_or_default(),
|
||||
awake: power.awake.unwrap_or_default(),
|
||||
sleep: power.sleep.unwrap_or_default(),
|
||||
shutdown: false,
|
||||
});
|
||||
}
|
||||
if power.lightbar {
|
||||
states.push(AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: power.boot.unwrap_or_default(),
|
||||
awake: power.awake.unwrap_or_default(),
|
||||
sleep: power.sleep.unwrap_or_default(),
|
||||
shutdown: false,
|
||||
});
|
||||
}
|
||||
|
||||
let states = LaptopAuraPower { states };
|
||||
aura.set_led_power(states)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_led_power2(
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
supported: &[String],
|
||||
aura: &[AuraProxyBlocking],
|
||||
power: &LedPowerCommand2,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if !supported.contains(&AURA_ZBUS_NAME.to_string()) {
|
||||
println!("This laptop does not support power options");
|
||||
return Err(PlatformError::NotSupported.into());
|
||||
}
|
||||
let dev_type = dbus.proxies().aura().device_type()?;
|
||||
if !dev_type.is_new_style() {
|
||||
println!("This option applies only to keyboards 2021+");
|
||||
}
|
||||
|
||||
if power.command().is_none() {
|
||||
if !power.help {
|
||||
println!("Missing arg or command\n");
|
||||
for aura in aura {
|
||||
let dev_type = aura.device_type()?;
|
||||
if !dev_type.is_new_laptop() {
|
||||
println!("This option applies only to keyboards 2021+");
|
||||
continue;
|
||||
}
|
||||
println!("{}\n", power.self_usage());
|
||||
println!("Commands available");
|
||||
|
||||
if let Some(cmdlist) = LedPowerCommand2::command_list() {
|
||||
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
|
||||
for command in &commands {
|
||||
println!("{}", command);
|
||||
if power.command().is_none() {
|
||||
if !power.help {
|
||||
println!("Missing arg or command\n");
|
||||
}
|
||||
}
|
||||
println!("{}\n", power.self_usage());
|
||||
println!("Commands available");
|
||||
|
||||
println!("\nHelp can also be requested on commands, e.g: boot --help");
|
||||
return Ok(());
|
||||
}
|
||||
if let Some(cmdlist) = LedPowerCommand2::command_list() {
|
||||
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
|
||||
for command in &commands {
|
||||
println!("{}", command);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(pow) = power.command.as_ref() {
|
||||
if pow.help_requested() {
|
||||
println!("{}", pow.self_usage());
|
||||
println!("\nHelp can also be requested on commands, e.g: boot --help");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let set = |power: &mut KbAuraPowerState, set_to: &AuraPowerStates| {
|
||||
power.boot = set_to.boot;
|
||||
power.awake = set_to.awake;
|
||||
power.sleep = set_to.sleep;
|
||||
power.shutdown = set_to.shutdown;
|
||||
};
|
||||
|
||||
let mut enabled = dbus.proxies().aura().led_power()?;
|
||||
if let Some(cmd) = &power.command {
|
||||
match cmd {
|
||||
aura_cli::SetAuraZoneEnabled::Keyboard(k) => set(&mut enabled.rog.keyboard, k),
|
||||
aura_cli::SetAuraZoneEnabled::Logo(l) => set(&mut enabled.rog.logo, l),
|
||||
aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(&mut enabled.rog.lightbar, l),
|
||||
aura_cli::SetAuraZoneEnabled::Lid(l) => set(&mut enabled.rog.lid, l),
|
||||
aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(&mut enabled.rog.rear_glow, r),
|
||||
if let Some(pow) = power.command.as_ref() {
|
||||
if pow.help_requested() {
|
||||
println!("{}", pow.self_usage());
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
dbus.proxies().aura().set_led_power((enabled, true))?;
|
||||
let mut states = aura.led_power()?;
|
||||
let mut set = |zone: PowerZones, set_to: &AuraPowerStates| {
|
||||
for state in states.states.iter_mut() {
|
||||
if state.zone == zone {
|
||||
state.boot = set_to.boot;
|
||||
state.awake = set_to.awake;
|
||||
state.sleep = set_to.sleep;
|
||||
state.shutdown = set_to.shutdown;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(cmd) = &power.command {
|
||||
match cmd {
|
||||
aura_cli::SetAuraZoneEnabled::Keyboard(k) => set(PowerZones::Keyboard, k),
|
||||
aura_cli::SetAuraZoneEnabled::Logo(l) => set(PowerZones::Logo, l),
|
||||
aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(PowerZones::Lightbar, l),
|
||||
aura_cli::SetAuraZoneEnabled::Lid(l) => set(PowerZones::Lid, l),
|
||||
aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(PowerZones::RearGlow, r),
|
||||
}
|
||||
}
|
||||
|
||||
aura.set_led_power(states)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_throttle_profile(
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
conn: &Connection,
|
||||
supported: &[Properties],
|
||||
cmd: &ProfileCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -691,16 +781,14 @@ fn handle_throttle_profile(
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
let current = dbus.proxies().platform().throttle_thermal_policy()?;
|
||||
|
||||
let proxy = PlatformProxyBlocking::new(conn)?;
|
||||
let current = proxy.throttle_thermal_policy()?;
|
||||
|
||||
if cmd.next {
|
||||
dbus.proxies()
|
||||
.platform()
|
||||
.set_throttle_thermal_policy(current.next())?;
|
||||
proxy.set_throttle_thermal_policy(current.next())?;
|
||||
} else if let Some(profile) = cmd.profile_set {
|
||||
dbus.proxies()
|
||||
.platform()
|
||||
.set_throttle_thermal_policy(profile)?;
|
||||
proxy.set_throttle_thermal_policy(profile)?;
|
||||
}
|
||||
|
||||
if cmd.list {
|
||||
@@ -718,14 +806,14 @@ fn handle_throttle_profile(
|
||||
}
|
||||
|
||||
fn handle_fan_curve(
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
supported: &[String],
|
||||
conn: &Connection,
|
||||
cmd: &FanCurveCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if !supported.contains(&FAN_CURVE_ZBUS_NAME.to_string()) {
|
||||
println!("Fan-curves not supported by either this kernel or by the laptop.");
|
||||
let Ok(fan_proxy) = FanCurvesProxyBlocking::new(conn).map_err(|e| {
|
||||
println!("Fan-curves not supported by either this kernel or by the laptop: {e:?}");
|
||||
}) else {
|
||||
return Err(ProfileError::NotSupported.into());
|
||||
}
|
||||
};
|
||||
|
||||
if !cmd.get_enabled && !cmd.default && cmd.mod_profile.is_none() {
|
||||
if !cmd.help {
|
||||
@@ -749,36 +837,34 @@ fn handle_fan_curve(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let plat_proxy = PlatformProxyBlocking::new(conn)?;
|
||||
if cmd.get_enabled {
|
||||
let profile = dbus.proxies().platform().throttle_thermal_policy()?;
|
||||
let curves = dbus.proxies().fan_curves().fan_curve_data(profile)?;
|
||||
let profile = plat_proxy.throttle_thermal_policy()?;
|
||||
let curves = fan_proxy.fan_curve_data(profile)?;
|
||||
for curve in curves.iter() {
|
||||
println!("{}", String::from(curve));
|
||||
}
|
||||
}
|
||||
|
||||
if cmd.default {
|
||||
dbus.proxies().fan_curves().set_active_curve_to_defaults()?;
|
||||
let active = plat_proxy.throttle_thermal_policy()?;
|
||||
fan_proxy.set_curves_to_defaults(active)?;
|
||||
}
|
||||
|
||||
if let Some(profile) = cmd.mod_profile {
|
||||
if cmd.enable_fan_curves.is_none() && cmd.data.is_none() {
|
||||
let data = dbus.proxies().fan_curves().fan_curve_data(profile)?;
|
||||
let data = toml::to_string(&data)?;
|
||||
println!("\nFan curves for {:?}\n\n{}", profile, data);
|
||||
let data = fan_proxy.fan_curve_data(profile)?;
|
||||
let ron = ron::ser::to_string_pretty(&data, PrettyConfig::new().depth_limit(4))?;
|
||||
println!("\nFan curves for {:?}\n\n{}", profile, ron);
|
||||
}
|
||||
|
||||
if let Some(enabled) = cmd.enable_fan_curves {
|
||||
dbus.proxies()
|
||||
.fan_curves()
|
||||
.set_fan_curves_enabled(profile, enabled)?;
|
||||
fan_proxy.set_fan_curves_enabled(profile, enabled)?;
|
||||
}
|
||||
|
||||
if let Some(enabled) = cmd.enable_fan_curve {
|
||||
if let Some(fan) = cmd.fan {
|
||||
dbus.proxies()
|
||||
.fan_curves()
|
||||
.set_profile_fan_curve_enabled(profile, fan, enabled)?;
|
||||
fan_proxy.set_profile_fan_curve_enabled(profile, fan, enabled)?;
|
||||
} else {
|
||||
println!(
|
||||
"--enable-fan-curves, --enable-fan-curve, --fan, and --data options require \
|
||||
@@ -790,7 +876,7 @@ fn handle_fan_curve(
|
||||
if let Some(mut curve) = cmd.data.clone() {
|
||||
let fan = cmd.fan.unwrap_or_default();
|
||||
curve.set_fan(fan);
|
||||
dbus.proxies().fan_curves().set_fan_curve(profile, curve)?;
|
||||
fan_proxy.set_fan_curve(profile, curve)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -798,7 +884,7 @@ fn handle_fan_curve(
|
||||
}
|
||||
|
||||
fn handle_platform_properties(
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
conn: &Connection,
|
||||
supported: &[Properties],
|
||||
cmd: &BiosCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -824,34 +910,34 @@ fn handle_platform_properties(
|
||||
}
|
||||
}
|
||||
|
||||
let proxy = PlatformProxyBlocking::new(conn)?;
|
||||
|
||||
if let Some(opt) = cmd.post_sound_set {
|
||||
dbus.proxies().platform().set_post_animation_sound(opt)?;
|
||||
proxy.set_boot_sound(opt)?;
|
||||
}
|
||||
if cmd.post_sound_get {
|
||||
let res = dbus.proxies().platform().post_animation_sound()?;
|
||||
let res = proxy.boot_sound()?;
|
||||
println!("Bios POST sound on: {}", res);
|
||||
}
|
||||
|
||||
if let Some(opt) = cmd.gpu_mux_mode_set {
|
||||
println!("Rebuilding initrd to include drivers");
|
||||
dbus.proxies()
|
||||
.platform()
|
||||
.set_gpu_mux_mode(GpuMode::from_mux(opt))?;
|
||||
proxy.set_gpu_mux_mode(GpuMode::from_mux(opt))?;
|
||||
println!(
|
||||
"The mode change is not active until you reboot, on boot the bios will make the \
|
||||
required change"
|
||||
);
|
||||
}
|
||||
if cmd.gpu_mux_mode_get {
|
||||
let res = dbus.proxies().platform().gpu_mux_mode()?;
|
||||
let res = proxy.gpu_mux_mode()?;
|
||||
println!("Bios GPU MUX: {:?}", res);
|
||||
}
|
||||
|
||||
if let Some(opt) = cmd.panel_overdrive_set {
|
||||
dbus.proxies().platform().set_panel_od(opt)?;
|
||||
proxy.set_panel_od(opt)?;
|
||||
}
|
||||
if cmd.panel_overdrive_get {
|
||||
let res = dbus.proxies().platform().panel_od()?;
|
||||
let res = proxy.panel_od()?;
|
||||
println!("Panel overdrive on: {}", res);
|
||||
}
|
||||
}
|
||||
|
||||
20
asusctl/src/slash_cli.rs
Normal file
20
asusctl/src/slash_cli.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use gumdrop::Options;
|
||||
use rog_slash::SlashMode;
|
||||
|
||||
#[derive(Options)]
|
||||
pub struct SlashCommand {
|
||||
#[options(help = "print help message")]
|
||||
pub help: bool,
|
||||
#[options(help = "Enable the Slash Ledbar")]
|
||||
pub enable: bool,
|
||||
#[options(help = "Ddisable the Slash Ledbar")]
|
||||
pub disable: bool,
|
||||
#[options(meta = "", help = "Set brightness value <0-255>")]
|
||||
pub brightness: Option<u8>,
|
||||
#[options(meta = "", help = "Set interval value <0-255>")]
|
||||
pub interval: Option<u8>,
|
||||
#[options(help = "Set SlashMode (so 'list' for all options)")]
|
||||
pub slash_mode: Option<SlashMode>,
|
||||
#[options(help = "list available animations")]
|
||||
pub list: bool,
|
||||
}
|
||||
@@ -1,23 +1,29 @@
|
||||
[package]
|
||||
name = "asusd-user"
|
||||
license = "MPL-2.0"
|
||||
license.workspace = true
|
||||
version.workspace = true
|
||||
authors = ["Luke D Jones <luke@ljones.dev>"]
|
||||
edition = "2021"
|
||||
description = "Usermode daemon for user settings, anime, per-key lighting"
|
||||
readme.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "asusd-user"
|
||||
path = "src/daemon.rs"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
local_data = []
|
||||
|
||||
[dependencies]
|
||||
dirs.workspace = true
|
||||
smol.workspace = true
|
||||
|
||||
# serialisation
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
serde_derive.workspace = true
|
||||
ron.workspace = true
|
||||
|
||||
rog_anime = { path = "../rog-anime" }
|
||||
rog_aura = { path = "../rog-aura" }
|
||||
@@ -26,10 +32,10 @@ rog_platform = { path = "../rog-platform" }
|
||||
config-traits = { path = "../config-traits" }
|
||||
|
||||
zbus.workspace = true
|
||||
|
||||
# cli and logging
|
||||
log.workspace = true
|
||||
env_logger.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
cargo-husky.workspace = true
|
||||
cargo-husky.workspace = true
|
||||
|
||||
[package.metadata.cargo-machete]
|
||||
ignored = ["serde"]
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::time::Duration;
|
||||
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use rog_anime::{ActionLoader, AnimTime, AnimeType, Fade, Sequences as AnimeSequences, Vec2};
|
||||
use rog_aura::advanced::LedCode;
|
||||
use rog_aura::effects::{AdvancedEffects as AuraSequences, Breathe, DoomFlicker, Effect, Static};
|
||||
use rog_aura::keyboard::LedCode;
|
||||
use rog_aura::{Colour, Speed};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@ use std::time::{Duration, Instant};
|
||||
use config_traits::StdConfig;
|
||||
use rog_anime::error::AnimeError;
|
||||
use rog_anime::{ActionData, ActionLoader, AnimTime, Fade, Sequences, Vec2};
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use ron::ser::PrettyConfig;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use zbus::dbus_interface;
|
||||
use zbus::interface;
|
||||
use zbus::zvariant::{ObjectPath, Type};
|
||||
|
||||
use crate::config::ConfigAnime;
|
||||
@@ -61,14 +62,14 @@ pub enum TimeType {
|
||||
/// thread and a zbus server behind `Arc<Mutex<T>>`
|
||||
pub struct CtrlAnimeInner<'a> {
|
||||
sequences: Sequences,
|
||||
client: RogDbusClientBlocking<'a>,
|
||||
client: AnimeProxyBlocking<'a>,
|
||||
do_early_return: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl<'a> CtrlAnimeInner<'static> {
|
||||
pub fn new(
|
||||
sequences: Sequences,
|
||||
client: RogDbusClientBlocking<'static>,
|
||||
client: AnimeProxyBlocking<'static>,
|
||||
do_early_return: Arc<AtomicBool>,
|
||||
) -> Result<Self, Error> {
|
||||
Ok(Self {
|
||||
@@ -93,19 +94,13 @@ impl<'a> CtrlAnimeInner<'static> {
|
||||
return Ok(true); // Do safe exit
|
||||
}
|
||||
self.client
|
||||
.proxies()
|
||||
.anime()
|
||||
.write(output)
|
||||
.map_err(|e| AnimeError::Dbus(format!("{}", e)))
|
||||
.map(|_| false)
|
||||
});
|
||||
}
|
||||
ActionData::Image(image) => {
|
||||
self.client
|
||||
.proxies()
|
||||
.anime()
|
||||
.write(image.as_ref().clone())
|
||||
.ok();
|
||||
self.client.write(image.as_ref().clone()).ok();
|
||||
}
|
||||
ActionData::Pause(duration) => {
|
||||
let start = Instant::now();
|
||||
@@ -132,7 +127,7 @@ impl<'a> CtrlAnimeInner<'static> {
|
||||
|
||||
pub struct CtrlAnime<'a> {
|
||||
config: Arc<Mutex<ConfigAnime>>,
|
||||
client: RogDbusClientBlocking<'a>,
|
||||
client: AnimeProxyBlocking<'a>,
|
||||
inner: Arc<Mutex<CtrlAnimeInner<'a>>>,
|
||||
/// Must be the same Atomic as in CtrlAnimeInner
|
||||
inner_early_return: Arc<AtomicBool>,
|
||||
@@ -142,7 +137,7 @@ impl CtrlAnime<'static> {
|
||||
pub fn new(
|
||||
config: Arc<Mutex<ConfigAnime>>,
|
||||
inner: Arc<Mutex<CtrlAnimeInner<'static>>>,
|
||||
client: RogDbusClientBlocking<'static>,
|
||||
client: AnimeProxyBlocking<'static>,
|
||||
inner_early_return: Arc<AtomicBool>,
|
||||
) -> Result<Self, Error> {
|
||||
Ok(CtrlAnime {
|
||||
@@ -175,7 +170,7 @@ impl CtrlAnime<'static> {
|
||||
// - Do actions
|
||||
// - Write config if required
|
||||
// - Unset inner_early_return
|
||||
#[dbus_interface(name = "org.asuslinux.Daemon")]
|
||||
#[interface(name = "org.asuslinux.Daemon")]
|
||||
impl CtrlAnime<'static> {
|
||||
pub fn insert_asus_gif(
|
||||
&mut self,
|
||||
@@ -205,11 +200,12 @@ impl CtrlAnime<'static> {
|
||||
config.anime.push(action);
|
||||
config.write();
|
||||
|
||||
let json = serde_json::to_string_pretty(&*config).expect("Parse config to JSON failed");
|
||||
let ron = ron::ser::to_string_pretty(&*config, PrettyConfig::new().depth_limit(4))
|
||||
.expect("Parse config to RON failed");
|
||||
|
||||
// Release the inner run loop again
|
||||
self.inner_early_return.store(false, Ordering::SeqCst);
|
||||
return Ok(json);
|
||||
return Ok(ron);
|
||||
}
|
||||
Err(zbus::fdo::Error::Failed("UserConfig lock fail".into()))
|
||||
}
|
||||
@@ -250,12 +246,11 @@ impl CtrlAnime<'static> {
|
||||
config.anime.push(action);
|
||||
config.write();
|
||||
|
||||
let json =
|
||||
serde_json::to_string_pretty(&*config.anime).expect("Parse config to JSON failed");
|
||||
|
||||
let ron = ron::ser::to_string_pretty(&*config, PrettyConfig::new().depth_limit(4))
|
||||
.expect("Parse config to RON failed");
|
||||
// Release the inner run loop again
|
||||
self.inner_early_return.store(false, Ordering::SeqCst);
|
||||
return Ok(json);
|
||||
return Ok(ron);
|
||||
}
|
||||
Err(zbus::fdo::Error::Failed("UserConfig lock fail".into()))
|
||||
}
|
||||
@@ -295,12 +290,11 @@ impl CtrlAnime<'static> {
|
||||
config.anime.push(action);
|
||||
config.write();
|
||||
|
||||
let json =
|
||||
serde_json::to_string_pretty(&*config.anime).expect("Parse config to JSON failed");
|
||||
|
||||
let ron = ron::ser::to_string_pretty(&*config, PrettyConfig::new().depth_limit(4))
|
||||
.expect("Parse config to RON failed");
|
||||
// Release the inner run loop again
|
||||
self.inner_early_return.store(false, Ordering::SeqCst);
|
||||
return Ok(json);
|
||||
return Ok(ron);
|
||||
}
|
||||
Err(zbus::fdo::Error::Failed("UserConfig lock fail".into()))
|
||||
}
|
||||
@@ -320,12 +314,11 @@ impl CtrlAnime<'static> {
|
||||
config.anime.push(action);
|
||||
config.write();
|
||||
|
||||
let json =
|
||||
serde_json::to_string_pretty(&*config.anime).expect("Parse config to JSON failed");
|
||||
|
||||
let ron = ron::ser::to_string_pretty(&*config, PrettyConfig::new().depth_limit(4))
|
||||
.expect("Parse config to RON failed");
|
||||
// Release the inner run loop again
|
||||
self.inner_early_return.store(false, Ordering::SeqCst);
|
||||
return Ok(json);
|
||||
return Ok(ron);
|
||||
}
|
||||
Err(zbus::fdo::Error::Failed("UserConfig lock fail".into()))
|
||||
}
|
||||
@@ -343,12 +336,11 @@ impl CtrlAnime<'static> {
|
||||
}
|
||||
config.write();
|
||||
|
||||
let json =
|
||||
serde_json::to_string_pretty(&*config.anime).expect("Parse config to JSON failed");
|
||||
|
||||
let ron = ron::ser::to_string_pretty(&*config, PrettyConfig::new().depth_limit(4))
|
||||
.expect("Parse config to RON failed");
|
||||
// Release the inner run loop again
|
||||
self.inner_early_return.store(false, Ordering::SeqCst);
|
||||
return Ok(json);
|
||||
return Ok(ron);
|
||||
}
|
||||
Err(zbus::fdo::Error::Failed("UserConfig lock fail".into()))
|
||||
}
|
||||
@@ -356,13 +348,13 @@ impl CtrlAnime<'static> {
|
||||
pub fn set_state(&mut self, on: bool) -> zbus::fdo::Result<()> {
|
||||
// Operations here need to be in specific order
|
||||
if on {
|
||||
self.client.proxies().anime().set_enable_display(on).ok();
|
||||
self.client.set_enable_display(on).ok();
|
||||
// Let the inner loop run
|
||||
self.inner_early_return.store(false, Ordering::SeqCst);
|
||||
} else {
|
||||
// Must make the inner run loop return early
|
||||
self.inner_early_return.store(true, Ordering::SeqCst);
|
||||
self.client.proxies().anime().set_enable_display(on).ok();
|
||||
self.client.set_enable_display(on).ok();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@ use std::sync::{Arc, Mutex};
|
||||
use asusd_user::config::*;
|
||||
use asusd_user::ctrl_anime::{CtrlAnime, CtrlAnimeInner};
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use rog_anime::usb::get_anime_type;
|
||||
use rog_aura::aura_detection::LaptopLedData;
|
||||
use rog_aura::layouts::KeyLayout;
|
||||
use rog_dbus::{RogDbusClientBlocking, DBUS_NAME};
|
||||
use rog_anime::usb::get_maybe_anime_type;
|
||||
use rog_aura::aura_detection::LedSupportData;
|
||||
use rog_aura::keyboard::KeyLayout;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use rog_dbus::zbus_aura::AuraProxyBlocking;
|
||||
use rog_dbus::{list_iface_blocking, DBUS_NAME};
|
||||
use smol::Executor;
|
||||
use zbus::Connection;
|
||||
|
||||
@@ -32,25 +34,22 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!(" rog-dbus v{}", rog_dbus::VERSION);
|
||||
println!("rog-platform v{}", rog_platform::VERSION);
|
||||
|
||||
let (client, _) = RogDbusClientBlocking::new()?;
|
||||
let supported = client
|
||||
.proxies()
|
||||
.platform()
|
||||
.supported_interfaces()
|
||||
.unwrap_or_default()
|
||||
.contains(&"Anime".to_string());
|
||||
let conn = zbus::blocking::Connection::system().unwrap();
|
||||
|
||||
let supported = list_iface_blocking()?;
|
||||
let config = ConfigBase::new().load();
|
||||
let executor = Executor::new();
|
||||
|
||||
let early_return = Arc::new(AtomicBool::new(false));
|
||||
// Set up the anime data and run loop/thread
|
||||
if supported {
|
||||
if supported.contains(&"org.asuslinux.Anime".to_string()) {
|
||||
if let Some(cfg) = config.active_anime {
|
||||
let anime_type = get_anime_type()?;
|
||||
let anime_type = get_maybe_anime_type()?;
|
||||
let anime_config = ConfigAnime::new().set_name(cfg).load();
|
||||
let anime = anime_config.create(anime_type)?;
|
||||
let anime_config = Arc::new(Mutex::new(anime_config));
|
||||
|
||||
let anime_proxy_blocking = AnimeProxyBlocking::new(&conn).unwrap();
|
||||
executor
|
||||
.spawn(async move {
|
||||
// Create server
|
||||
@@ -59,12 +58,21 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Inner behind mutex required for thread safety
|
||||
let inner = Arc::new(Mutex::new(
|
||||
CtrlAnimeInner::new(anime, client, early_return.clone()).unwrap(),
|
||||
CtrlAnimeInner::new(
|
||||
anime,
|
||||
anime_proxy_blocking.clone(),
|
||||
early_return.clone(),
|
||||
)
|
||||
.unwrap(),
|
||||
));
|
||||
// Need new client object for dbus control part
|
||||
let (client, _) = RogDbusClientBlocking::new().unwrap();
|
||||
let anime_control =
|
||||
CtrlAnime::new(anime_config, inner.clone(), client, early_return).unwrap();
|
||||
let anime_control = CtrlAnime::new(
|
||||
anime_config,
|
||||
inner.clone(),
|
||||
anime_proxy_blocking,
|
||||
early_return,
|
||||
)
|
||||
.unwrap();
|
||||
anime_control.add_to_server(&mut connection).await;
|
||||
loop {
|
||||
if let Ok(inner) = inner.clone().try_lock() {
|
||||
@@ -81,7 +89,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut aura_config = ConfigAura::new().set_name(cfg).load();
|
||||
// let baord_name = std::fs::read_to_string(BOARD_NAME)?;
|
||||
|
||||
let led_support = LaptopLedData::get_data();
|
||||
let led_support = LedSupportData::get_data("");
|
||||
|
||||
let layout = KeyLayout::find_layout(led_support, PathBuf::from(DATA_DIR))
|
||||
.map_err(|e| {
|
||||
@@ -89,22 +97,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
})
|
||||
.unwrap_or_else(|_| KeyLayout::default_layout());
|
||||
|
||||
let aura_proxy_blocking = AuraProxyBlocking::new(&conn).unwrap();
|
||||
executor
|
||||
.spawn(async move {
|
||||
// Create server
|
||||
let (client, _) = RogDbusClientBlocking::new().unwrap();
|
||||
// let connection = Connection::session().await.unwrap();
|
||||
// connection.request_name(DBUS_NAME).await.unwrap();
|
||||
|
||||
loop {
|
||||
aura_config.aura.next_state(&layout);
|
||||
let packets = aura_config.aura.create_packets();
|
||||
|
||||
client
|
||||
.proxies()
|
||||
.aura()
|
||||
.direct_addressing_raw(packets)
|
||||
.unwrap();
|
||||
aura_proxy_blocking.direct_addressing_raw(packets).unwrap();
|
||||
std::thread::sleep(std::time::Duration::from_millis(33));
|
||||
}
|
||||
})
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use zbus::dbus_proxy;
|
||||
use zbus::proxy;
|
||||
|
||||
#[dbus_proxy(
|
||||
#[proxy(
|
||||
interface = "org.asuslinux.Daemon",
|
||||
default_path = "/org/asuslinux/Anime"
|
||||
)]
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
[package]
|
||||
name = "asusd"
|
||||
license = "MPL-2.0"
|
||||
license.workspace = true
|
||||
version.workspace = true
|
||||
readme = "README.md"
|
||||
authors = ["Luke <luke@ljones.dev>"]
|
||||
repository = "https://gitlab.com/asus-linux/asus-nb-ctrl"
|
||||
homepage = "https://gitlab.com/asus-linux/asus-nb-ctrl"
|
||||
description = "A daemon app for ASUS GX502 and similar laptops to control missing features"
|
||||
edition = "2021"
|
||||
readme.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
description.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "asusd"
|
||||
@@ -16,6 +16,7 @@ path = "src/daemon.rs"
|
||||
[dependencies]
|
||||
config-traits = { path = "../config-traits" }
|
||||
rog_anime = { path = "../rog-anime", features = ["dbus"] }
|
||||
rog_slash = { path = "../rog-slash", features = ["dbus"] }
|
||||
rog_aura = { path = "../rog-aura", features = ["dbus"] }
|
||||
rog_platform = { path = "../rog-platform" }
|
||||
rog_profiles = { path = "../rog-profiles" }
|
||||
@@ -24,7 +25,9 @@ futures-lite = "*"
|
||||
udev.workspace = true
|
||||
inotify.workspace = true
|
||||
|
||||
mio.workspace = true
|
||||
tokio.workspace = true
|
||||
# console-subscriber = "0.2.0"
|
||||
|
||||
# cli and logging
|
||||
log.workspace = true
|
||||
@@ -39,7 +42,8 @@ serde_derive.workspace = true
|
||||
|
||||
concat-idents.workspace = true
|
||||
|
||||
systemd-zbus = "*"
|
||||
|
||||
[dev-dependencies]
|
||||
cargo-husky.workspace = true
|
||||
cargo-husky.workspace = true
|
||||
|
||||
[package.metadata.cargo-machete]
|
||||
ignored = ["serde"]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use config_traits::{StdConfig, StdConfigLoad3};
|
||||
use config_traits::{StdConfig, StdConfigLoad1};
|
||||
use rog_platform::cpu::CPUEPP;
|
||||
use rog_platform::platform::ThrottlePolicy;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
@@ -10,6 +10,7 @@ pub struct Config {
|
||||
/// Save charge limit for restoring on boot/resume
|
||||
pub charge_control_end_threshold: u8,
|
||||
pub panel_od: bool,
|
||||
pub boot_sound: bool,
|
||||
pub mini_led_mode: bool,
|
||||
pub disable_nvidia_powerd_on_battery: bool,
|
||||
/// An optional command/script to run when power is changed to AC
|
||||
@@ -21,8 +22,12 @@ pub struct Config {
|
||||
pub throttle_policy_linked_epp: bool,
|
||||
/// Which throttle/profile to use on battery power
|
||||
pub throttle_policy_on_battery: ThrottlePolicy,
|
||||
/// Should the throttle policy be set on bat/ac change?
|
||||
pub change_throttle_policy_on_battery: bool,
|
||||
/// Which throttle/profile to use on AC power
|
||||
pub throttle_policy_on_ac: ThrottlePolicy,
|
||||
/// Should the throttle policy be set on bat/ac change?
|
||||
pub change_throttle_policy_on_ac: bool,
|
||||
/// The energy_performance_preference for this throttle/platform profile
|
||||
pub throttle_quiet_epp: CPUEPP,
|
||||
/// The energy_performance_preference for this throttle/platform profile
|
||||
@@ -30,18 +35,25 @@ pub struct Config {
|
||||
/// The energy_performance_preference for this throttle/platform profile
|
||||
pub throttle_performance_epp: CPUEPP,
|
||||
/// Defaults to `None` if not supported
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub ppt_pl1_spl: Option<u8>,
|
||||
/// Defaults to `None` if not supported
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub ppt_pl2_sppt: Option<u8>,
|
||||
/// Defaults to `None` if not supported
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub ppt_fppt: Option<u8>,
|
||||
/// Defaults to `None` if not supported
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub ppt_apu_sppt: Option<u8>,
|
||||
/// Defaults to `None` if not supported
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub ppt_platform_sppt: Option<u8>,
|
||||
/// Defaults to `None` if not supported
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub nv_dynamic_boost: Option<u8>,
|
||||
/// Defaults to `None` if not supported
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub nv_temp_target: Option<u8>,
|
||||
/// Temporary state for AC/Batt
|
||||
#[serde(skip)]
|
||||
@@ -53,13 +65,16 @@ impl Default for Config {
|
||||
Self {
|
||||
charge_control_end_threshold: 100,
|
||||
panel_od: false,
|
||||
boot_sound: false,
|
||||
mini_led_mode: false,
|
||||
disable_nvidia_powerd_on_battery: true,
|
||||
ac_command: Default::default(),
|
||||
bat_command: Default::default(),
|
||||
throttle_policy_linked_epp: true,
|
||||
throttle_policy_on_battery: ThrottlePolicy::Quiet,
|
||||
change_throttle_policy_on_battery: true,
|
||||
throttle_policy_on_ac: ThrottlePolicy::Performance,
|
||||
change_throttle_policy_on_ac: true,
|
||||
throttle_quiet_epp: CPUEPP::Power,
|
||||
throttle_balanced_epp: CPUEPP::BalancePower,
|
||||
throttle_performance_epp: CPUEPP::Performance,
|
||||
@@ -88,16 +103,16 @@ impl StdConfig for Config {
|
||||
}
|
||||
}
|
||||
|
||||
fn config_dir() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(crate::CONFIG_PATH_BASE)
|
||||
}
|
||||
|
||||
fn file_name(&self) -> String {
|
||||
CONFIG_FILE.to_owned()
|
||||
}
|
||||
|
||||
fn config_dir() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(crate::CONFIG_PATH_BASE)
|
||||
}
|
||||
}
|
||||
|
||||
impl StdConfigLoad3<Config472, Config506, Config507> for Config {}
|
||||
impl StdConfigLoad1<Config507> for Config {}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Config507 {
|
||||
@@ -126,13 +141,16 @@ impl From<Config507> for Config {
|
||||
Self {
|
||||
charge_control_end_threshold: c.charge_control_end_threshold,
|
||||
panel_od: c.panel_od,
|
||||
boot_sound: false,
|
||||
disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
|
||||
ac_command: c.ac_command,
|
||||
bat_command: c.bat_command,
|
||||
mini_led_mode: c.mini_led_mode,
|
||||
throttle_policy_linked_epp: true,
|
||||
throttle_policy_on_battery: c.platform_policy_on_battery,
|
||||
change_throttle_policy_on_battery: true,
|
||||
throttle_policy_on_ac: c.platform_policy_on_ac,
|
||||
change_throttle_policy_on_ac: true,
|
||||
throttle_quiet_epp: CPUEPP::Power,
|
||||
throttle_balanced_epp: CPUEPP::BalancePower,
|
||||
throttle_performance_epp: CPUEPP::Performance,
|
||||
@@ -147,78 +165,3 @@ impl From<Config507> for Config {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Config506 {
|
||||
/// Save charge limit for restoring on boot
|
||||
pub charge_control_end_threshold: u8,
|
||||
pub panel_od: bool,
|
||||
pub mini_led_mode: bool,
|
||||
pub disable_nvidia_powerd_on_battery: bool,
|
||||
pub ac_command: String,
|
||||
pub bat_command: String,
|
||||
/// Restored on boot as well as when power is plugged
|
||||
#[serde(skip)]
|
||||
pub platform_policy_to_restore: ThrottlePolicy,
|
||||
pub platform_policy_on_battery: ThrottlePolicy,
|
||||
pub platform_policy_on_ac: ThrottlePolicy,
|
||||
//
|
||||
pub ppt_pl1_spl: Option<u8>,
|
||||
pub ppt_pl2_sppt: Option<u8>,
|
||||
pub ppt_fppt: Option<u8>,
|
||||
pub ppt_apu_sppt: Option<u8>,
|
||||
pub ppt_platform_sppt: Option<u8>,
|
||||
pub nv_dynamic_boost: Option<u8>,
|
||||
pub nv_temp_target: Option<u8>,
|
||||
}
|
||||
|
||||
impl From<Config506> for Config {
|
||||
fn from(c: Config506) -> Self {
|
||||
Self {
|
||||
charge_control_end_threshold: c.charge_control_end_threshold,
|
||||
panel_od: c.panel_od,
|
||||
disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
|
||||
ac_command: c.ac_command,
|
||||
bat_command: c.bat_command,
|
||||
mini_led_mode: c.mini_led_mode,
|
||||
throttle_policy_linked_epp: true,
|
||||
throttle_policy_on_battery: c.platform_policy_on_battery,
|
||||
throttle_policy_on_ac: c.platform_policy_on_ac,
|
||||
throttle_quiet_epp: CPUEPP::Power,
|
||||
throttle_balanced_epp: CPUEPP::BalancePower,
|
||||
throttle_performance_epp: CPUEPP::Performance,
|
||||
ppt_pl1_spl: c.ppt_pl1_spl,
|
||||
ppt_pl2_sppt: c.ppt_pl2_sppt,
|
||||
ppt_fppt: c.ppt_fppt,
|
||||
ppt_apu_sppt: c.ppt_apu_sppt,
|
||||
ppt_platform_sppt: c.ppt_platform_sppt,
|
||||
nv_dynamic_boost: c.nv_dynamic_boost,
|
||||
nv_temp_target: c.nv_temp_target,
|
||||
last_power_plugged: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Config472 {
|
||||
/// Save charge limit for restoring on boot
|
||||
pub bat_charge_limit: u8,
|
||||
pub panel_od: bool,
|
||||
pub mini_led_mode: bool,
|
||||
pub disable_nvidia_powerd_on_battery: bool,
|
||||
pub ac_command: String,
|
||||
pub bat_command: String,
|
||||
}
|
||||
|
||||
impl From<Config472> for Config {
|
||||
fn from(c: Config472) -> Self {
|
||||
Self {
|
||||
charge_control_end_threshold: c.bat_charge_limit,
|
||||
panel_od: c.panel_od,
|
||||
disable_nvidia_powerd_on_battery: true,
|
||||
ac_command: c.ac_command,
|
||||
bat_command: c.bat_command,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use config_traits::{StdConfig, StdConfigLoad2};
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use rog_anime::error::AnimeError;
|
||||
use rog_anime::usb::Brightness;
|
||||
use rog_anime::{
|
||||
@@ -10,60 +10,6 @@ use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
const CONFIG_FILE: &str = "anime.ron";
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct AnimeConfigV460 {
|
||||
pub system: Vec<ActionLoader>,
|
||||
pub boot: Vec<ActionLoader>,
|
||||
pub wake: Vec<ActionLoader>,
|
||||
pub sleep: Vec<ActionLoader>,
|
||||
pub shutdown: Vec<ActionLoader>,
|
||||
pub brightness: f32,
|
||||
}
|
||||
|
||||
impl From<AnimeConfigV460> for AnimeConfig {
|
||||
fn from(c: AnimeConfigV460) -> AnimeConfig {
|
||||
AnimeConfig {
|
||||
system: c.system,
|
||||
boot: c.boot,
|
||||
wake: c.wake,
|
||||
shutdown: c.shutdown,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct AnimeConfigV472 {
|
||||
pub model_override: Option<AnimeType>,
|
||||
pub system: Vec<ActionLoader>,
|
||||
pub boot: Vec<ActionLoader>,
|
||||
pub wake: Vec<ActionLoader>,
|
||||
pub sleep: Vec<ActionLoader>,
|
||||
pub shutdown: Vec<ActionLoader>,
|
||||
pub brightness: f32,
|
||||
pub display_enabled: bool,
|
||||
pub display_brightness: Brightness,
|
||||
pub builtin_anims_enabled: bool,
|
||||
pub builtin_anims: Animations,
|
||||
}
|
||||
|
||||
impl From<AnimeConfigV472> for AnimeConfig {
|
||||
fn from(c: AnimeConfigV472) -> AnimeConfig {
|
||||
AnimeConfig {
|
||||
system: c.system,
|
||||
boot: c.boot,
|
||||
wake: c.wake,
|
||||
shutdown: c.shutdown,
|
||||
model_override: c.model_override,
|
||||
display_enabled: c.display_enabled,
|
||||
display_brightness: c.display_brightness,
|
||||
builtin_anims_enabled: c.builtin_anims_enabled,
|
||||
builtin_anims: c.builtin_anims,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Default)]
|
||||
pub struct AnimeConfigCached {
|
||||
pub system: Vec<ActionData>,
|
||||
@@ -106,9 +52,8 @@ impl AnimeConfigCached {
|
||||
}
|
||||
|
||||
/// Config for base system actions for the anime display
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||
pub struct AnimeConfig {
|
||||
pub model_override: Option<AnimeType>,
|
||||
pub system: Vec<ActionLoader>,
|
||||
pub boot: Vec<ActionLoader>,
|
||||
pub wake: Vec<ActionLoader>,
|
||||
@@ -127,7 +72,6 @@ pub struct AnimeConfig {
|
||||
impl Default for AnimeConfig {
|
||||
fn default() -> Self {
|
||||
AnimeConfig {
|
||||
model_override: None,
|
||||
system: Vec::new(),
|
||||
boot: Vec::new(),
|
||||
wake: Vec::new(),
|
||||
@@ -150,16 +94,16 @@ impl StdConfig for AnimeConfig {
|
||||
Self::create_default()
|
||||
}
|
||||
|
||||
fn config_dir() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(crate::CONFIG_PATH_BASE)
|
||||
}
|
||||
|
||||
fn file_name(&self) -> String {
|
||||
CONFIG_FILE.to_owned()
|
||||
}
|
||||
|
||||
fn config_dir() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(crate::CONFIG_PATH_BASE)
|
||||
}
|
||||
}
|
||||
|
||||
impl StdConfigLoad2<AnimeConfigV460, AnimeConfigV472> for AnimeConfig {}
|
||||
impl StdConfigLoad for AnimeConfig {}
|
||||
|
||||
impl From<&AnimeConfig> for DeviceState {
|
||||
fn from(config: &AnimeConfig) -> Self {
|
||||
|
||||
@@ -8,10 +8,11 @@ use std::sync::Arc;
|
||||
use std::thread::sleep;
|
||||
|
||||
use ::zbus::export::futures_util::lock::Mutex;
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use log::{error, info, warn};
|
||||
use rog_anime::error::AnimeError;
|
||||
use rog_anime::usb::{
|
||||
get_anime_type, pkt_flush, pkt_set_brightness, pkt_set_enable_display,
|
||||
get_maybe_anime_type, pkt_flush, pkt_set_brightness, pkt_set_enable_display,
|
||||
pkt_set_enable_powersave_anim, pkts_for_init, Brightness,
|
||||
};
|
||||
use rog_anime::{ActionData, AnimeDataBuffer, AnimePacketType, AnimeType};
|
||||
@@ -62,42 +63,49 @@ pub struct CtrlAnime {
|
||||
|
||||
impl CtrlAnime {
|
||||
#[inline]
|
||||
pub fn new(config: AnimeConfig) -> Result<CtrlAnime, RogError> {
|
||||
pub fn new() -> Result<CtrlAnime, RogError> {
|
||||
let anime_type = get_maybe_anime_type()?;
|
||||
if matches!(anime_type, AnimeType::Unsupported) {
|
||||
info!("No Anime Matrix capable laptop found");
|
||||
return Err(RogError::Anime(AnimeError::NoDevice));
|
||||
}
|
||||
|
||||
let usb = USBRaw::new(0x193b).ok();
|
||||
let hid = HidRaw::new("193b").ok();
|
||||
let node = if usb.is_some() {
|
||||
info!("Anime using the USB interface");
|
||||
unsafe { Node::Usb(usb.unwrap_unchecked()) }
|
||||
} else if hid.is_some() {
|
||||
info!("Anime using the HID interface");
|
||||
unsafe { Node::Hid(hid.unwrap_unchecked()) }
|
||||
} else {
|
||||
return Err(RogError::Anime(AnimeError::NoDevice));
|
||||
};
|
||||
|
||||
// TODO: something better to set wakeups disabled
|
||||
if matches!(node, Node::Usb(_)) {
|
||||
if let Ok(mut enumerator) = udev::Enumerator::new() {
|
||||
enumerator.match_subsystem("usb").ok();
|
||||
enumerator.match_attribute("idProduct", "193b").ok();
|
||||
// if matches!(node, Node::Usb(_)) {
|
||||
// if let Ok(mut enumerator) = udev::Enumerator::new() {
|
||||
// enumerator.match_subsystem("usb").ok();
|
||||
// enumerator.match_attribute("idProduct", "193b").ok();
|
||||
|
||||
if let Ok(mut enumer) = enumerator.scan_devices() {
|
||||
if let Some(mut dev) = enumer.next() {
|
||||
dev.set_attribute_value("power/wakeup", "disabled").ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if let Ok(mut enumer) = enumerator.scan_devices() {
|
||||
// if let Some(mut dev) = enumer.next() {
|
||||
// dev.set_attribute_value("power/wakeup", "disabled").ok();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
let mut anime_type = get_anime_type()?;
|
||||
if let AnimeType::Unknown = anime_type {
|
||||
if let Some(model) = config.model_override {
|
||||
warn!("Overriding the Animatrix type as {model:?}");
|
||||
anime_type = model;
|
||||
}
|
||||
}
|
||||
let mut config = AnimeConfig::new().load();
|
||||
|
||||
info!("Device has an AniMe Matrix display: {anime_type:?}");
|
||||
let mut cache = AnimeConfigCached::default();
|
||||
cache.init_from_config(&config, anime_type)?;
|
||||
if let Err(e) = cache.init_from_config(&config, anime_type) {
|
||||
error!("Trying to cache the Anime Config failed, will reset to default config: {e:?}");
|
||||
config.rename_file_old();
|
||||
config = AnimeConfig::new();
|
||||
config.write();
|
||||
}
|
||||
|
||||
let ctrl = CtrlAnime {
|
||||
node,
|
||||
|
||||
@@ -10,13 +10,14 @@ use rog_anime::usb::{
|
||||
};
|
||||
use rog_anime::{Animations, AnimeDataBuffer, DeviceState};
|
||||
use zbus::export::futures_util::lock::Mutex;
|
||||
use zbus::{dbus_interface, CacheProperties, Connection, SignalContext};
|
||||
use zbus::{interface, CacheProperties, Connection, SignalContext};
|
||||
|
||||
use super::config::AnimeConfig;
|
||||
use super::CtrlAnime;
|
||||
use crate::error::RogError;
|
||||
|
||||
pub const ANIME_ZBUS_NAME: &str = "Anime";
|
||||
pub const ANIME_ZBUS_PATH: &str = "/org/asuslinux/Anime";
|
||||
pub const ANIME_ZBUS_PATH: &str = "/org/asuslinux";
|
||||
|
||||
async fn get_logind_manager<'a>() -> ManagerProxy<'a> {
|
||||
let connection = Connection::system()
|
||||
@@ -43,50 +44,61 @@ impl crate::ZbusRun for CtrlAnimeZbus {
|
||||
// None of these calls can be guarnateed to succeed unless we loop until okay
|
||||
// If the try_lock *does* succeed then any other thread trying to lock will not
|
||||
// grab it until we finish.
|
||||
#[dbus_interface(name = "org.asuslinux.Daemon")]
|
||||
#[interface(name = "org.asuslinux.Anime")]
|
||||
impl CtrlAnimeZbus {
|
||||
/// Writes a data stream of length. Will force system thread to exit until
|
||||
/// it is restarted
|
||||
async fn write(&self, input: AnimeDataBuffer) -> zbus::fdo::Result<()> {
|
||||
let lock = self.0.lock().await;
|
||||
lock.thread_exit.store(true, Ordering::SeqCst);
|
||||
lock.write_data_buffer(input).map_err(|err| {
|
||||
warn!("ctrl_anime::run_animation:callback {}", err);
|
||||
err
|
||||
})?;
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.thread_exit
|
||||
.store(true, Ordering::SeqCst);
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.write_data_buffer(input)
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_anime::run_animation:callback {}", err);
|
||||
err
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set base brightness level
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn brightness(&self) -> Brightness {
|
||||
let lock = self.0.lock().await;
|
||||
lock.config.display_brightness
|
||||
self.0.lock().await.config.display_brightness
|
||||
}
|
||||
|
||||
/// Set base brightness level
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_brightness(&self, brightness: Brightness) {
|
||||
let mut lock = self.0.lock().await;
|
||||
lock.node
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_brightness(brightness))
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_anime::set_brightness {}", err);
|
||||
})
|
||||
.ok();
|
||||
lock.node
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_display(brightness != Brightness::Off))
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_anime::set_brightness {}", err);
|
||||
})
|
||||
.ok();
|
||||
|
||||
lock.config.display_enabled = brightness != Brightness::Off;
|
||||
lock.config.display_brightness = brightness;
|
||||
lock.config.write();
|
||||
self.0.lock().await.config.display_enabled = brightness != Brightness::Off;
|
||||
self.0.lock().await.config.display_brightness = brightness;
|
||||
self.0.lock().await.config.write();
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn builtins_enabled(&self) -> bool {
|
||||
let lock = self.0.lock().await;
|
||||
lock.config.builtin_anims_enabled
|
||||
@@ -94,22 +106,29 @@ impl CtrlAnimeZbus {
|
||||
|
||||
/// Enable the builtin animations or not. This is quivalent to "Powersave
|
||||
/// animations" in Armory crate
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_builtins_enabled(&self, enabled: bool) {
|
||||
let mut lock = self.0.lock().await;
|
||||
lock.node
|
||||
.set_builtins_enabled(enabled, lock.config.display_brightness)
|
||||
let brightness = self.0.lock().await.config.display_brightness;
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.set_builtins_enabled(enabled, brightness)
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_anime::set_builtins_enabled {}", err);
|
||||
})
|
||||
.ok();
|
||||
|
||||
if !enabled {
|
||||
let data = vec![255u8; lock.anime_type.data_length()];
|
||||
if let Ok(tmp) = AnimeDataBuffer::from_vec(lock.anime_type, data).map_err(|err| {
|
||||
let anime_type = self.0.lock().await.anime_type;
|
||||
let data = vec![255u8; anime_type.data_length()];
|
||||
if let Ok(tmp) = AnimeDataBuffer::from_vec(anime_type, data).map_err(|err| {
|
||||
warn!("ctrl_anime::set_builtins_enabled {}", err);
|
||||
}) {
|
||||
lock.node
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(tmp.data())
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_anime::set_builtins_enabled {}", err);
|
||||
@@ -118,24 +137,29 @@ impl CtrlAnimeZbus {
|
||||
}
|
||||
}
|
||||
|
||||
lock.config.builtin_anims_enabled = enabled;
|
||||
lock.config.write();
|
||||
self.0.lock().await.config.builtin_anims_enabled = enabled;
|
||||
self.0.lock().await.config.write();
|
||||
if enabled {
|
||||
lock.thread_exit.store(true, Ordering::Release);
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.thread_exit
|
||||
.store(true, Ordering::Release);
|
||||
}
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn builtin_animations(&self) -> Animations {
|
||||
let lock = self.0.lock().await;
|
||||
lock.config.builtin_anims
|
||||
self.0.lock().await.config.builtin_anims
|
||||
}
|
||||
|
||||
/// Set which builtin animation is used for each stage
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_builtin_animations(&self, settings: Animations) {
|
||||
let mut lock = self.0.lock().await;
|
||||
lock.node
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_builtin_animations(
|
||||
settings.boot,
|
||||
settings.awake,
|
||||
@@ -146,114 +170,125 @@ impl CtrlAnimeZbus {
|
||||
warn!("ctrl_anime::run_animation:callback {}", err);
|
||||
})
|
||||
.ok();
|
||||
lock.node
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_powersave_anim(true))
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_anime::run_animation:callback {}", err);
|
||||
})
|
||||
.ok();
|
||||
lock.config.display_enabled = true;
|
||||
lock.config.builtin_anims = settings;
|
||||
lock.config.write();
|
||||
self.0.lock().await.config.display_enabled = true;
|
||||
self.0.lock().await.config.builtin_anims = settings;
|
||||
self.0.lock().await.config.write();
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn enable_display(&self) -> bool {
|
||||
let lock = self.0.lock().await;
|
||||
lock.config.display_enabled
|
||||
self.0.lock().await.config.display_enabled
|
||||
}
|
||||
|
||||
/// Set whether the AniMe is enabled at all
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_enable_display(&self, enabled: bool) {
|
||||
let mut lock = self.0.lock().await;
|
||||
lock.node
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_display(enabled))
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_anime::run_animation:callback {}", err);
|
||||
})
|
||||
.ok();
|
||||
lock.config.display_enabled = enabled;
|
||||
lock.config.write();
|
||||
self.0.lock().await.config.display_enabled = enabled;
|
||||
self.0.lock().await.config.write();
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn off_when_unplugged(&self) -> bool {
|
||||
let lock = self.0.lock().await;
|
||||
lock.config.off_when_unplugged
|
||||
self.0.lock().await.config.off_when_unplugged
|
||||
}
|
||||
|
||||
/// Set if to turn the AniMe Matrix off when external power is unplugged
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_off_when_unplugged(&self, enabled: bool) {
|
||||
let mut lock = self.0.lock().await;
|
||||
let manager = get_logind_manager().await;
|
||||
let pow = manager.on_external_power().await.unwrap_or_default();
|
||||
|
||||
lock.node
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_display(!pow && !enabled))
|
||||
.map_err(|err| {
|
||||
warn!("create_sys_event_tasks::off_when_lid_closed {}", err);
|
||||
})
|
||||
.ok();
|
||||
|
||||
lock.config.off_when_unplugged = enabled;
|
||||
lock.config.write();
|
||||
self.0.lock().await.config.off_when_unplugged = enabled;
|
||||
self.0.lock().await.config.write();
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn off_when_suspended(&self) -> bool {
|
||||
let lock = self.0.lock().await;
|
||||
lock.config.off_when_suspended
|
||||
self.0.lock().await.config.off_when_suspended
|
||||
}
|
||||
|
||||
/// Set if to turn the AniMe Matrix off when the laptop is suspended
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_off_when_suspended(&self, enabled: bool) {
|
||||
let mut lock = self.0.lock().await;
|
||||
lock.config.off_when_suspended = enabled;
|
||||
lock.config.write();
|
||||
self.0.lock().await.config.off_when_suspended = enabled;
|
||||
self.0.lock().await.config.write();
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn off_when_lid_closed(&self) -> bool {
|
||||
let lock = self.0.lock().await;
|
||||
lock.config.off_when_lid_closed
|
||||
self.0.lock().await.config.off_when_lid_closed
|
||||
}
|
||||
|
||||
/// Set if to turn the AniMe Matrix off when the lid is closed
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_off_when_lid_closed(&self, enabled: bool) {
|
||||
let mut lock = self.0.lock().await;
|
||||
let manager = get_logind_manager().await;
|
||||
let lid = manager.lid_closed().await.unwrap_or_default();
|
||||
|
||||
lock.node
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_display(lid && !enabled))
|
||||
.map_err(|err| {
|
||||
warn!("create_sys_event_tasks::off_when_lid_closed {}", err);
|
||||
})
|
||||
.ok();
|
||||
|
||||
lock.config.off_when_lid_closed = enabled;
|
||||
lock.config.write();
|
||||
self.0.lock().await.config.off_when_lid_closed = enabled;
|
||||
self.0.lock().await.config.write();
|
||||
}
|
||||
|
||||
/// The main loop is the base system set action if the user isn't running
|
||||
/// the user daemon
|
||||
async fn run_main_loop(&self, start: bool) {
|
||||
if start {
|
||||
let lock = self.0.lock().await;
|
||||
lock.thread_exit.store(true, Ordering::SeqCst);
|
||||
CtrlAnime::run_thread(self.0.clone(), lock.cache.system.clone(), false).await;
|
||||
self.0
|
||||
.lock()
|
||||
.await
|
||||
.thread_exit
|
||||
.store(true, Ordering::SeqCst);
|
||||
CtrlAnime::run_thread(
|
||||
self.0.clone(),
|
||||
self.0.lock().await.cache.system.clone(),
|
||||
false,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the device state as stored by asusd
|
||||
// #[dbus_interface(property)]
|
||||
// #[zbus(property)]
|
||||
async fn device_state(&self) -> DeviceState {
|
||||
let lock = self.0.lock().await;
|
||||
DeviceState::from(&lock.config)
|
||||
DeviceState::from(&self.0.lock().await.config)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,36 +307,53 @@ impl crate::CtrlTask for CtrlAnimeZbus {
|
||||
// on_sleep
|
||||
let inner = inner1.clone();
|
||||
async move {
|
||||
let lock = inner.lock().await;
|
||||
if lock.config.display_enabled {
|
||||
lock.thread_exit.store(true, Ordering::Release); // ensure clean slate
|
||||
let config = inner.lock().await.config.clone();
|
||||
if config.display_enabled {
|
||||
inner
|
||||
.lock()
|
||||
.await
|
||||
.thread_exit
|
||||
.store(true, Ordering::Release); // ensure clean slate
|
||||
|
||||
lock.node
|
||||
inner
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_display(
|
||||
!(sleeping && lock.config.off_when_suspended),
|
||||
!(sleeping && config.off_when_suspended),
|
||||
))
|
||||
.map_err(|err| {
|
||||
warn!("create_sys_event_tasks::off_when_suspended {}", err);
|
||||
})
|
||||
.ok();
|
||||
|
||||
if lock.config.builtin_anims_enabled {
|
||||
lock.node
|
||||
if config.builtin_anims_enabled {
|
||||
inner
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_powersave_anim(
|
||||
!(sleeping && lock.config.off_when_suspended),
|
||||
!(sleeping && config.off_when_suspended),
|
||||
))
|
||||
.map_err(|err| {
|
||||
warn!("create_sys_event_tasks::off_when_suspended {}", err);
|
||||
})
|
||||
.ok();
|
||||
} else if !sleeping && !lock.config.builtin_anims_enabled {
|
||||
} else if !sleeping && !config.builtin_anims_enabled {
|
||||
// Run custom wake animation
|
||||
lock.node
|
||||
inner
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_powersave_anim(false))
|
||||
.ok(); // ensure builtins are disabled
|
||||
|
||||
CtrlAnime::run_thread(inner.clone(), lock.cache.wake.clone(), true)
|
||||
.await;
|
||||
CtrlAnime::run_thread(
|
||||
inner.clone(),
|
||||
inner.lock().await.cache.wake.clone(),
|
||||
true,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,14 +362,26 @@ impl crate::CtrlTask for CtrlAnimeZbus {
|
||||
// on_shutdown
|
||||
let inner = inner2.clone();
|
||||
async move {
|
||||
let lock = inner.lock().await;
|
||||
if lock.config.display_enabled && !lock.config.builtin_anims_enabled {
|
||||
let AnimeConfig {
|
||||
display_enabled,
|
||||
builtin_anims_enabled,
|
||||
..
|
||||
} = inner.lock().await.config;
|
||||
if display_enabled && !builtin_anims_enabled {
|
||||
if shutting_down {
|
||||
CtrlAnime::run_thread(inner.clone(), lock.cache.shutdown.clone(), true)
|
||||
.await;
|
||||
CtrlAnime::run_thread(
|
||||
inner.clone(),
|
||||
inner.lock().await.cache.shutdown.clone(),
|
||||
true,
|
||||
)
|
||||
.await;
|
||||
} else {
|
||||
CtrlAnime::run_thread(inner.clone(), lock.cache.boot.clone(), true)
|
||||
.await;
|
||||
CtrlAnime::run_thread(
|
||||
inner.clone(),
|
||||
inner.lock().await.cache.boot.clone(),
|
||||
true,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,17 +390,27 @@ impl crate::CtrlTask for CtrlAnimeZbus {
|
||||
let inner = inner3.clone();
|
||||
// on lid change
|
||||
async move {
|
||||
let lock = inner.lock().await;
|
||||
if lock.config.off_when_lid_closed {
|
||||
if lock.config.builtin_anims_enabled {
|
||||
lock.node
|
||||
let AnimeConfig {
|
||||
off_when_lid_closed,
|
||||
builtin_anims_enabled,
|
||||
..
|
||||
} = inner.lock().await.config;
|
||||
if off_when_lid_closed {
|
||||
if builtin_anims_enabled {
|
||||
inner
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_powersave_anim(!lid_closed))
|
||||
.map_err(|err| {
|
||||
warn!("create_sys_event_tasks::off_when_suspended {}", err);
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
lock.node
|
||||
inner
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_display(!lid_closed))
|
||||
.map_err(|err| {
|
||||
warn!("create_sys_event_tasks::off_when_lid_closed {}", err);
|
||||
@@ -349,25 +423,39 @@ impl crate::CtrlTask for CtrlAnimeZbus {
|
||||
let inner = inner4.clone();
|
||||
// on power change
|
||||
async move {
|
||||
let lock = inner.lock().await;
|
||||
if lock.config.off_when_unplugged {
|
||||
if lock.config.builtin_anims_enabled {
|
||||
lock.node
|
||||
let AnimeConfig {
|
||||
off_when_unplugged,
|
||||
builtin_anims_enabled,
|
||||
brightness_on_battery,
|
||||
..
|
||||
} = inner.lock().await.config;
|
||||
if off_when_unplugged {
|
||||
if builtin_anims_enabled {
|
||||
inner
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_powersave_anim(power_plugged))
|
||||
.map_err(|err| {
|
||||
warn!("create_sys_event_tasks::off_when_suspended {}", err);
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
lock.node
|
||||
inner
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_enable_display(power_plugged))
|
||||
.map_err(|err| {
|
||||
warn!("create_sys_event_tasks::off_when_unplugged {}", err);
|
||||
})
|
||||
.ok();
|
||||
} else {
|
||||
lock.node
|
||||
.write_bytes(&pkt_set_brightness(lock.config.brightness_on_battery))
|
||||
inner
|
||||
.lock()
|
||||
.await
|
||||
.node
|
||||
.write_bytes(&pkt_set_brightness(brightness_on_battery))
|
||||
.map_err(|err| {
|
||||
warn!("create_sys_event_tasks::off_when_unplugged {}", err);
|
||||
})
|
||||
|
||||
@@ -1,167 +1,62 @@
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use log::{debug, warn};
|
||||
use rog_aura::aura_detection::{LaptopLedData, ASUS_KEYBOARD_DEVICES};
|
||||
use rog_aura::power::AuraPower;
|
||||
use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev};
|
||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT};
|
||||
use rog_platform::hid_raw::HidRaw;
|
||||
use log::{debug, info, warn};
|
||||
use rog_aura::aura_detection::LedSupportData;
|
||||
use rog_aura::keyboard::LaptopAuraPower;
|
||||
use rog_aura::{
|
||||
AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT,
|
||||
};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
const CONFIG_FILE: &str = "aura.ron";
|
||||
use crate::error::RogError;
|
||||
|
||||
/// Enable/disable LED control in various states such as
|
||||
/// when the device is awake, suspended, shutting down or
|
||||
/// booting.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum AuraPowerConfig {
|
||||
AuraDevTuf(HashSet<AuraDevTuf>),
|
||||
AuraDevRog1(HashSet<AuraDevRog1>),
|
||||
AuraDevRog2(AuraPower),
|
||||
}
|
||||
|
||||
impl AuraPowerConfig {
|
||||
/// Invalid for TUF laptops
|
||||
pub fn to_bytes(control: &Self) -> [u8; 4] {
|
||||
match control {
|
||||
AuraPowerConfig::AuraDevTuf(_) => [0, 0, 0, 0],
|
||||
AuraPowerConfig::AuraDevRog1(c) => {
|
||||
let c: Vec<AuraDevRog1> = c.iter().copied().collect();
|
||||
AuraDevRog1::to_bytes(&c)
|
||||
}
|
||||
AuraPowerConfig::AuraDevRog2(c) => c.to_bytes(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_tuf_bool_array(control: &Self) -> Option<[bool; 5]> {
|
||||
if let Self::AuraDevTuf(c) = control {
|
||||
return Some([
|
||||
true,
|
||||
c.contains(&AuraDevTuf::Boot),
|
||||
c.contains(&AuraDevTuf::Awake),
|
||||
c.contains(&AuraDevTuf::Sleep),
|
||||
c.contains(&AuraDevTuf::Keyboard),
|
||||
]);
|
||||
}
|
||||
|
||||
if let Self::AuraDevRog1(c) = control {
|
||||
return Some([
|
||||
true,
|
||||
c.contains(&AuraDevRog1::Boot),
|
||||
c.contains(&AuraDevRog1::Awake),
|
||||
c.contains(&AuraDevRog1::Sleep),
|
||||
c.contains(&AuraDevRog1::Keyboard),
|
||||
]);
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn set_tuf(&mut self, power: AuraDevTuf, on: bool) {
|
||||
if let Self::AuraDevTuf(p) = self {
|
||||
if on {
|
||||
p.insert(power);
|
||||
} else {
|
||||
p.remove(&power);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_0x1866(&mut self, power: AuraDevRog1, on: bool) {
|
||||
if let Self::AuraDevRog1(p) = self {
|
||||
if on {
|
||||
p.insert(power);
|
||||
} else {
|
||||
p.remove(&power);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_0x19b6(&mut self, power: AuraPower) {
|
||||
if let Self::AuraDevRog2(p) = self {
|
||||
*p = power;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&AuraPowerConfig> for AuraPowerDev {
|
||||
fn from(config: &AuraPowerConfig) -> Self {
|
||||
match config {
|
||||
AuraPowerConfig::AuraDevTuf(d) => AuraPowerDev {
|
||||
tuf: d.iter().copied().collect(),
|
||||
..Default::default()
|
||||
},
|
||||
AuraPowerConfig::AuraDevRog1(d) => AuraPowerDev {
|
||||
old_rog: d.iter().copied().collect(),
|
||||
..Default::default()
|
||||
},
|
||||
AuraPowerConfig::AuraDevRog2(d) => AuraPowerDev {
|
||||
rog: d.clone(),
|
||||
..Default::default()
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||
#[derive(Deserialize, Serialize, Default, Debug, Clone)]
|
||||
// #[serde(default)]
|
||||
pub struct AuraConfig {
|
||||
pub config_name: String,
|
||||
pub brightness: LedBrightness,
|
||||
pub current_mode: AuraModeNum,
|
||||
pub builtins: BTreeMap<AuraModeNum, AuraEffect>,
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub multizone: Option<BTreeMap<AuraModeNum, Vec<AuraEffect>>>,
|
||||
pub multizone_on: bool,
|
||||
pub enabled: AuraPowerConfig,
|
||||
pub enabled: LaptopAuraPower,
|
||||
}
|
||||
|
||||
impl StdConfig for AuraConfig {
|
||||
/// Detect the keyboard type and load from default DB if data available
|
||||
fn new() -> Self {
|
||||
warn!("AuraConfig: creating new config");
|
||||
let mut prod_id = AuraDevice::Unknown;
|
||||
for prod in ASUS_KEYBOARD_DEVICES {
|
||||
if HidRaw::new(prod.into()).is_ok() {
|
||||
prod_id = prod;
|
||||
break;
|
||||
}
|
||||
panic!("This should not be used");
|
||||
}
|
||||
|
||||
fn file_name(&self) -> String {
|
||||
if self.config_name.is_empty() {
|
||||
panic!("Config file name should not be empty");
|
||||
}
|
||||
Self::from_default_support(prod_id, &LaptopLedData::get_data())
|
||||
self.config_name.to_owned()
|
||||
}
|
||||
|
||||
fn config_dir() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(crate::CONFIG_PATH_BASE)
|
||||
}
|
||||
|
||||
fn file_name(&self) -> String {
|
||||
CONFIG_FILE.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl StdConfigLoad for AuraConfig {}
|
||||
|
||||
impl AuraConfig {
|
||||
pub fn from_default_support(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self {
|
||||
/// Detect the keyboard type and load from default DB if data available
|
||||
pub fn new(prod_id: &str) -> Self {
|
||||
info!("Setting up AuraConfig for {prod_id:?}");
|
||||
// create a default config here
|
||||
let enabled = if prod_id.is_new_style() {
|
||||
AuraPowerConfig::AuraDevRog2(AuraPower::new_all_on())
|
||||
} else if prod_id.is_tuf_style() {
|
||||
AuraPowerConfig::AuraDevTuf(HashSet::from([
|
||||
AuraDevTuf::Awake,
|
||||
AuraDevTuf::Boot,
|
||||
AuraDevTuf::Sleep,
|
||||
AuraDevTuf::Keyboard,
|
||||
]))
|
||||
} else {
|
||||
AuraPowerConfig::AuraDevRog1(HashSet::from([
|
||||
AuraDevRog1::Awake,
|
||||
AuraDevRog1::Boot,
|
||||
AuraDevRog1::Sleep,
|
||||
AuraDevRog1::Keyboard,
|
||||
AuraDevRog1::Lightbar,
|
||||
]))
|
||||
};
|
||||
let device_type = AuraDeviceType::from(prod_id);
|
||||
if device_type == AuraDeviceType::Unknown {
|
||||
warn!("idProduct:{prod_id:?} is unknown");
|
||||
}
|
||||
let support_data = LedSupportData::get_data(prod_id);
|
||||
let enabled = LaptopAuraPower::new(device_type, &support_data);
|
||||
let mut config = AuraConfig {
|
||||
config_name: format!("aura_{prod_id}.ron"),
|
||||
brightness: LedBrightness::Med,
|
||||
current_mode: AuraModeNum::Static,
|
||||
builtins: BTreeMap::new(),
|
||||
@@ -171,7 +66,7 @@ impl AuraConfig {
|
||||
};
|
||||
|
||||
for n in &support_data.basic_modes {
|
||||
debug!("AuraConfig: creating default for {n}");
|
||||
debug!("creating default for {n}");
|
||||
config
|
||||
.builtins
|
||||
.insert(*n, AuraEffect::default_with_mode(*n));
|
||||
@@ -237,20 +132,52 @@ impl AuraConfig {
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Create a default for the `current_mode` if multizone and no config
|
||||
/// exists.
|
||||
pub(super) fn create_multizone_default(
|
||||
&mut self,
|
||||
supported_data: &LedSupportData,
|
||||
) -> Result<(), RogError> {
|
||||
let mut default = vec![];
|
||||
for (i, tmp) in supported_data.basic_zones.iter().enumerate() {
|
||||
default.push(AuraEffect {
|
||||
mode: self.current_mode,
|
||||
zone: *tmp,
|
||||
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
|
||||
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Left,
|
||||
});
|
||||
}
|
||||
if default.is_empty() {
|
||||
return Err(RogError::AuraEffectNotSupported);
|
||||
}
|
||||
|
||||
if let Some(multizones) = self.multizone.as_mut() {
|
||||
multizones.insert(self.current_mode, default);
|
||||
} else {
|
||||
let mut tmp = BTreeMap::new();
|
||||
tmp.insert(self.current_mode, default);
|
||||
self.multizone = Some(tmp);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use rog_aura::aura_detection::LaptopLedData;
|
||||
use rog_aura::usb::AuraDevice;
|
||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour};
|
||||
use rog_aura::keyboard::AuraPowerState;
|
||||
use rog_aura::{
|
||||
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed,
|
||||
};
|
||||
|
||||
use super::AuraConfig;
|
||||
|
||||
#[test]
|
||||
fn set_multizone_4key_config() {
|
||||
let mut config =
|
||||
AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default());
|
||||
std::env::set_var("BOARD_NAME", "");
|
||||
let mut config = AuraConfig::new("19b6");
|
||||
|
||||
let effect = AuraEffect {
|
||||
colour1: Colour {
|
||||
@@ -340,8 +267,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn set_multizone_multimode_config() {
|
||||
let mut config =
|
||||
AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default());
|
||||
std::env::set_var("BOARD_NAME", "");
|
||||
let mut config = AuraConfig::new("19b6");
|
||||
|
||||
let effect = AuraEffect {
|
||||
zone: AuraZone::Key1,
|
||||
@@ -385,4 +312,66 @@ mod tests {
|
||||
let sta = res.get(&AuraModeNum::Pulse).unwrap();
|
||||
assert_eq!(sta.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verify_0x1866_g531i() {
|
||||
std::env::set_var("BOARD_NAME", "G513I");
|
||||
let mut config = AuraConfig::new("1866");
|
||||
|
||||
assert_eq!(config.brightness, LedBrightness::Med);
|
||||
assert_eq!(config.builtins.len(), 5);
|
||||
assert_eq!(
|
||||
config.builtins.first_entry().unwrap().get(),
|
||||
&AuraEffect {
|
||||
mode: AuraModeNum::Static,
|
||||
zone: AuraZone::None,
|
||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right
|
||||
}
|
||||
);
|
||||
assert_eq!(config.enabled.states.len(), 1);
|
||||
assert_eq!(
|
||||
config.enabled.states[0],
|
||||
AuraPowerState {
|
||||
zone: PowerZones::KeyboardAndLightbar,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verify_0x19b6_g634j() {
|
||||
std::env::set_var("BOARD_NAME", "G634J");
|
||||
let mut config = AuraConfig::new("19b6");
|
||||
|
||||
assert_eq!(config.brightness, LedBrightness::Med);
|
||||
assert_eq!(config.builtins.len(), 12);
|
||||
assert_eq!(
|
||||
config.builtins.first_entry().unwrap().get(),
|
||||
&AuraEffect {
|
||||
mode: AuraModeNum::Static,
|
||||
zone: AuraZone::None,
|
||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right
|
||||
}
|
||||
);
|
||||
assert_eq!(config.enabled.states.len(), 4);
|
||||
assert_eq!(
|
||||
config.enabled.states[0],
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,82 +1,282 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use dmi_id::DMIID;
|
||||
use log::{info, warn};
|
||||
use rog_aura::advanced::{LedUsbPackets, UsbPackets};
|
||||
use rog_aura::aura_detection::{LaptopLedData, ASUS_KEYBOARD_DEVICES};
|
||||
use rog_aura::usb::{AuraDevice, LED_APPLY, LED_SET};
|
||||
use rog_aura::{AuraEffect, Direction, LedBrightness, Speed, GRADIENT, LED_MSG_LEN};
|
||||
use inotify::Inotify;
|
||||
use log::{debug, info, warn};
|
||||
use rog_aura::aura_detection::LedSupportData;
|
||||
use rog_aura::keyboard::{LedUsbPackets, UsbPackets};
|
||||
use rog_aura::usb::{LED_APPLY, LED_SET};
|
||||
use rog_aura::{AuraDeviceType, AuraEffect, LedBrightness, LED_MSG_LEN};
|
||||
use rog_platform::hid_raw::HidRaw;
|
||||
use rog_platform::keyboard_led::KeyboardLed;
|
||||
use rog_platform::keyboard_led::KeyboardBacklight;
|
||||
use udev::Device;
|
||||
use zbus::zvariant::OwnedObjectPath;
|
||||
use zbus::Connection;
|
||||
|
||||
use super::config::{AuraConfig, AuraPowerConfig};
|
||||
use super::config::AuraConfig;
|
||||
use crate::ctrl_aura::manager::{dbus_path_for_dev, dbus_path_for_tuf, start_tasks};
|
||||
use crate::ctrl_aura::trait_impls::CtrlAuraZbus;
|
||||
use crate::error::RogError;
|
||||
use crate::CtrlTask;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum LEDNode {
|
||||
KbdLed(KeyboardLed),
|
||||
Rog(HidRaw),
|
||||
None,
|
||||
/// Brightness and/or TUF RGB controls
|
||||
KbdLed(KeyboardBacklight),
|
||||
/// Raw HID handle
|
||||
Rog(Option<KeyboardBacklight>, HidRaw),
|
||||
}
|
||||
|
||||
impl LEDNode {
|
||||
// TODO: move various methods upwards to this
|
||||
pub fn set_brightness(&self, value: u8) -> Result<(), RogError> {
|
||||
match self {
|
||||
LEDNode::KbdLed(k) => k.set_brightness(value)?,
|
||||
LEDNode::Rog(k, r) => {
|
||||
if let Some(k) = k {
|
||||
k.set_brightness(value)?;
|
||||
let x = k.get_brightness()?;
|
||||
if x != value {
|
||||
debug!(
|
||||
"Kernel brightness control didn't read back correct value, setting \
|
||||
with raw hid"
|
||||
);
|
||||
r.write_bytes(&[0x5a, 0xba, 0xc5, 0xc4, value])?;
|
||||
}
|
||||
} else {
|
||||
debug!("No brightness control found, trying raw write");
|
||||
r.write_bytes(&[0x5a, 0xba, 0xc5, 0xc4, value])?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_brightness(&self) -> Result<u8, RogError> {
|
||||
Ok(match self {
|
||||
LEDNode::KbdLed(k) => k.get_brightness()?,
|
||||
LEDNode::Rog(k, _) => {
|
||||
if let Some(k) = k {
|
||||
k.get_brightness()?
|
||||
} else {
|
||||
debug!("No brightness control found");
|
||||
return Err(RogError::MissingFunction(
|
||||
"No keyboard brightness control found".to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn monitor_brightness(&self) -> Result<Inotify, RogError> {
|
||||
Ok(match self {
|
||||
LEDNode::KbdLed(k) => k.monitor_brightness()?,
|
||||
LEDNode::Rog(k, _) => {
|
||||
if let Some(k) = k {
|
||||
k.monitor_brightness()?
|
||||
} else {
|
||||
debug!("No brightness control found");
|
||||
return Err(RogError::MissingFunction(
|
||||
"No keyboard brightness control found".to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn has_brightness_control(&self) -> bool {
|
||||
match self {
|
||||
LEDNode::KbdLed(k) => k.has_brightness(),
|
||||
LEDNode::Rog(k, _) => {
|
||||
if let Some(k) = k {
|
||||
k.has_brightness()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Individual controller for one Aura device
|
||||
pub struct CtrlKbdLed {
|
||||
// TODO: config stores the keyboard type as an AuraPower, use or update this
|
||||
pub led_prod: AuraDevice,
|
||||
pub led_type: AuraDeviceType,
|
||||
pub led_node: LEDNode,
|
||||
pub sysfs_node: KeyboardLed,
|
||||
pub supported_data: LaptopLedData,
|
||||
pub supported_data: LedSupportData, // TODO: is storing this really required?
|
||||
pub per_key_mode_active: bool,
|
||||
pub config: AuraConfig,
|
||||
pub dbus_path: OwnedObjectPath,
|
||||
}
|
||||
|
||||
impl CtrlKbdLed {
|
||||
pub fn new(supported_basic_modes: LaptopLedData) -> Result<Self, RogError> {
|
||||
let mut led_prod = AuraDevice::Unknown;
|
||||
let mut usb_node = None;
|
||||
for prod in ASUS_KEYBOARD_DEVICES {
|
||||
match HidRaw::new(prod.into()) {
|
||||
Ok(node) => {
|
||||
led_prod = prod;
|
||||
usb_node = Some(node);
|
||||
info!(
|
||||
"Looked for keyboard controller 0x{}: Found",
|
||||
<&str>::from(prod)
|
||||
);
|
||||
break;
|
||||
pub fn add_to_dbus_and_start(
|
||||
self,
|
||||
interfaces: &mut HashSet<OwnedObjectPath>,
|
||||
conn: Connection,
|
||||
) -> Result<(), RogError> {
|
||||
let dbus_path = self.dbus_path.clone();
|
||||
let dbus_path_cpy = self.dbus_path.clone();
|
||||
info!(
|
||||
"AuraManager starting device at: {:?}, {:?}",
|
||||
dbus_path, self.led_type
|
||||
);
|
||||
let conn_copy = conn.clone();
|
||||
let sig_ctx1 = CtrlAuraZbus::signal_context(&conn_copy)?;
|
||||
let sig_ctx2 = CtrlAuraZbus::signal_context(&conn_copy)?;
|
||||
let zbus = CtrlAuraZbus::new(self, sig_ctx1);
|
||||
tokio::spawn(
|
||||
async move { start_tasks(zbus, conn_copy.clone(), sig_ctx2, dbus_path).await },
|
||||
);
|
||||
interfaces.insert(dbus_path_cpy);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Build and init a `CtrlKbdLed` from a udev device. Maybe.
|
||||
/// This will initialise the config also.
|
||||
pub fn maybe_device(
|
||||
device: Device,
|
||||
interfaces: &mut HashSet<OwnedObjectPath>,
|
||||
) -> Result<Option<Self>, RogError> {
|
||||
// usb_device gives us a product and vendor ID
|
||||
if let Some(usb_device) = device.parent_with_subsystem_devtype("usb", "usb_device")? {
|
||||
let dbus_path = dbus_path_for_dev(&usb_device).unwrap_or_default();
|
||||
if interfaces.contains(&dbus_path) {
|
||||
debug!("Already a ctrl at {dbus_path:?}, ignoring this end-point");
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
// The asus_wmi driver latches MCU that controls the USB endpoints
|
||||
if let Some(parent) = device.parent() {
|
||||
if let Some(driver) = parent.driver() {
|
||||
// There is a tree of devices added so filter by driver
|
||||
if driver != "asus" {
|
||||
return Ok(None);
|
||||
}
|
||||
} else {
|
||||
return Ok(None);
|
||||
}
|
||||
Err(err) => info!(
|
||||
"Looked for keyboard controller 0x{}: {err}",
|
||||
<&str>::from(prod)
|
||||
),
|
||||
}
|
||||
// Device is something like 002, while its parent is the MCU
|
||||
// Think of it like the device is an endpoint of the USB device attached
|
||||
let mut prod_id = String::new();
|
||||
if let Some(usb_id) = usb_device.attribute_value("idProduct") {
|
||||
prod_id = usb_id.to_string_lossy().to_string();
|
||||
let aura_device = AuraDeviceType::from(prod_id.as_str());
|
||||
if aura_device == AuraDeviceType::Unknown {
|
||||
log::debug!("Unknown or invalid device: {usb_id:?}, skipping");
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
|
||||
let dev_node = if let Some(dev_node) = usb_device.devnode() {
|
||||
dev_node
|
||||
} else {
|
||||
debug!("Device has no devnode, skipping");
|
||||
return Ok(None);
|
||||
};
|
||||
info!("AuraControl found device at: {:?}", dev_node);
|
||||
let dev = HidRaw::from_device(device)?;
|
||||
let mut controller = Self::from_hidraw(dev, dbus_path.clone())?;
|
||||
controller.config = Self::load_and_update_config(&prod_id);
|
||||
interfaces.insert(dbus_path);
|
||||
return Ok(Some(controller));
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
pub fn find_all() -> Result<Vec<Self>, RogError> {
|
||||
info!("Searching for all Aura devices");
|
||||
let mut devices = Vec::new();
|
||||
let mut interfaces = HashSet::new(); // track and ensure we use only one hidraw per prod_id
|
||||
|
||||
let mut enumerator = udev::Enumerator::new().map_err(|err| {
|
||||
warn!("{}", err);
|
||||
err
|
||||
})?;
|
||||
|
||||
enumerator.match_subsystem("hidraw").map_err(|err| {
|
||||
warn!("{}", err);
|
||||
err
|
||||
})?;
|
||||
|
||||
for end_point in enumerator.scan_devices()? {
|
||||
// maybe?
|
||||
if let Some(device) = Self::maybe_device(end_point, &mut interfaces)? {
|
||||
devices.push(device);
|
||||
}
|
||||
}
|
||||
|
||||
let rgb_led = KeyboardLed::new()?;
|
||||
// Check for a TUF laptop LED. Assume there is only ever one.
|
||||
if let Ok(kbd_backlight) = KeyboardBacklight::new() {
|
||||
if kbd_backlight.has_kbd_rgb_mode() {
|
||||
// Extra sure double-check that this isn't a laptop with crap
|
||||
// ACPI with borked return on the TUF rgb methods
|
||||
let dmi = DMIID::new().unwrap_or_default();
|
||||
info!("Found a TUF with product family: {}", dmi.product_family);
|
||||
info!("and board name: {}", dmi.board_name);
|
||||
|
||||
if usb_node.is_none() && !rgb_led.has_kbd_rgb_mode() {
|
||||
let dmi = DMIID::new().unwrap_or_default();
|
||||
if dmi.dmi_family.contains("TUF") {
|
||||
warn!(
|
||||
"kbd_rgb_mode was not found in the /sys/. You require a minimum 6.1 kernel \
|
||||
and a supported TUF laptop"
|
||||
);
|
||||
if dmi.product_family.contains("TUF") {
|
||||
info!("AuraControl found a TUF laptop keyboard");
|
||||
let ctrl = CtrlKbdLed {
|
||||
led_type: AuraDeviceType::LaptopTuf,
|
||||
led_node: LEDNode::KbdLed(kbd_backlight),
|
||||
supported_data: LedSupportData::get_data("tuf"),
|
||||
per_key_mode_active: false,
|
||||
config: Self::load_and_update_config("tuf"),
|
||||
dbus_path: dbus_path_for_tuf(),
|
||||
};
|
||||
devices.push(ctrl);
|
||||
}
|
||||
}
|
||||
return Err(RogError::NoAuraKeyboard);
|
||||
}
|
||||
|
||||
let led_node = if let Some(rog) = usb_node {
|
||||
info!("Found ROG USB keyboard");
|
||||
LEDNode::Rog(rog)
|
||||
} else if rgb_led.has_kbd_rgb_mode() {
|
||||
info!("Found TUF keyboard");
|
||||
LEDNode::KbdLed(rgb_led.clone())
|
||||
} else {
|
||||
LEDNode::None
|
||||
};
|
||||
let dmi = DMIID::new().unwrap_or_default();
|
||||
warn!("No asus::kbd_backlight found for {} ??", dmi.product_family);
|
||||
}
|
||||
|
||||
// New loads data fromt he DB also
|
||||
let mut config_init = AuraConfig::new();
|
||||
info!("Found {} Aura devices", devices.len());
|
||||
|
||||
Ok(devices)
|
||||
}
|
||||
|
||||
/// The generated data from this function has a default config. This config
|
||||
/// should be overwritten. The reason for the default config is because
|
||||
/// of async issues between this and udev/hidraw
|
||||
fn from_hidraw(device: HidRaw, dbus_path: OwnedObjectPath) -> Result<Self, RogError> {
|
||||
let rgb_led = KeyboardBacklight::new()
|
||||
.map_err(|e| {
|
||||
log::error!(
|
||||
"{} is missing a keyboard backlight brightness control: {e:?}",
|
||||
device.prod_id()
|
||||
);
|
||||
})
|
||||
.ok();
|
||||
let prod_id = AuraDeviceType::from(device.prod_id());
|
||||
if prod_id == AuraDeviceType::Unknown {
|
||||
log::error!("{} is AuraDevice::Unknown", device.prod_id());
|
||||
return Err(RogError::NoAuraNode);
|
||||
}
|
||||
|
||||
// New loads data from the DB also
|
||||
// let config = Self::init_config(prod_id, data);
|
||||
|
||||
let data = LedSupportData::get_data(device.prod_id());
|
||||
let ctrl = CtrlKbdLed {
|
||||
led_type: prod_id,
|
||||
led_node: LEDNode::Rog(rgb_led, device),
|
||||
supported_data: data.clone(),
|
||||
per_key_mode_active: false,
|
||||
config: AuraConfig::default(),
|
||||
dbus_path,
|
||||
};
|
||||
Ok(ctrl)
|
||||
}
|
||||
|
||||
/// Reload the config from disk then verify and update it if required
|
||||
fn load_and_update_config(prod_id: &str) -> AuraConfig {
|
||||
// New loads data from the DB also
|
||||
let mut config_init = AuraConfig::new(prod_id);
|
||||
// config_init.set_filename(prod_id);
|
||||
let mut config_loaded = config_init.clone().load();
|
||||
// update the initialised data with what we loaded from disk
|
||||
for mode in &mut config_init.builtins {
|
||||
@@ -88,6 +288,12 @@ impl CtrlKbdLed {
|
||||
// Then replace just incase the initialised data contains new modes added
|
||||
config_loaded.builtins = config_init.builtins;
|
||||
|
||||
// Check the powerzones and replace, if the len is different then the support
|
||||
// file was updated
|
||||
if config_loaded.enabled.states.len() != config_init.enabled.states.len() {
|
||||
config_loaded.enabled.states = config_init.enabled.states;
|
||||
}
|
||||
|
||||
if let (Some(mut multizone_init), Some(multizone_loaded)) =
|
||||
(config_init.multizone, config_loaded.multizone.as_mut())
|
||||
{
|
||||
@@ -95,9 +301,10 @@ impl CtrlKbdLed {
|
||||
// update init values from loaded values if they exist
|
||||
if let Some(loaded) = multizone_loaded.get(mode.0) {
|
||||
let mut new_set = Vec::new();
|
||||
let data = LedSupportData::get_data(prod_id);
|
||||
// only reuse a zone mode if the mode is supported
|
||||
for mode in loaded {
|
||||
if supported_basic_modes.basic_modes.contains(&mode.mode) {
|
||||
if data.basic_modes.contains(&mode.mode) {
|
||||
new_set.push(mode.clone());
|
||||
}
|
||||
}
|
||||
@@ -107,27 +314,18 @@ impl CtrlKbdLed {
|
||||
*multizone_loaded = multizone_init;
|
||||
}
|
||||
|
||||
let ctrl = CtrlKbdLed {
|
||||
led_prod,
|
||||
led_node, // on TUF this is the same as rgb_led / kd_brightness
|
||||
sysfs_node: rgb_led, // If was none then we already returned above
|
||||
supported_data: supported_basic_modes,
|
||||
per_key_mode_active: false,
|
||||
config: config_loaded,
|
||||
};
|
||||
Ok(ctrl)
|
||||
config_loaded
|
||||
}
|
||||
|
||||
/// Set combination state for boot animation/sleep animation/all leds/keys
|
||||
/// leds/side leds LED active
|
||||
pub(super) fn set_power_states(&mut self) -> Result<(), RogError> {
|
||||
if let LEDNode::KbdLed(platform) = &mut self.led_node {
|
||||
if let Some(pwr) = AuraPowerConfig::to_tuf_bool_array(&self.config.enabled) {
|
||||
let buf = [1, pwr[1] as u8, pwr[2] as u8, pwr[3] as u8, pwr[4] as u8];
|
||||
platform.set_kbd_rgb_state(&buf)?;
|
||||
}
|
||||
} else if let LEDNode::Rog(hid_raw) = &self.led_node {
|
||||
let bytes = AuraPowerConfig::to_bytes(&self.config.enabled);
|
||||
// TODO: tuf bool array
|
||||
let buf = self.config.enabled.to_bytes(self.led_type);
|
||||
platform.set_kbd_rgb_state(&buf)?;
|
||||
} else if let LEDNode::Rog(_, hid_raw) = &self.led_node {
|
||||
let bytes = self.config.enabled.to_bytes(self.led_type);
|
||||
let message = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]];
|
||||
|
||||
hid_raw.write_bytes(&message)?;
|
||||
@@ -152,20 +350,20 @@ impl CtrlKbdLed {
|
||||
|
||||
if pkt_type != PER_KEY_TYPE {
|
||||
self.per_key_mode_active = false;
|
||||
if let LEDNode::Rog(hid_raw) = &self.led_node {
|
||||
if let LEDNode::Rog(_, hid_raw) = &self.led_node {
|
||||
hid_raw.write_bytes(&effect[0])?;
|
||||
hid_raw.write_bytes(&LED_SET)?;
|
||||
// hid_raw.write_bytes(&LED_APPLY)?;
|
||||
}
|
||||
} else {
|
||||
if !self.per_key_mode_active {
|
||||
if let LEDNode::Rog(hid_raw) = &self.led_node {
|
||||
if let LEDNode::Rog(_, hid_raw) = &self.led_node {
|
||||
let init = LedUsbPackets::get_init_msg();
|
||||
hid_raw.write_bytes(&init)?;
|
||||
}
|
||||
self.per_key_mode_active = true;
|
||||
}
|
||||
if let LEDNode::Rog(hid_raw) = &self.led_node {
|
||||
if let LEDNode::Rog(_, hid_raw) = &self.led_node {
|
||||
for row in effect.iter() {
|
||||
hid_raw.write_bytes(row)?;
|
||||
}
|
||||
@@ -181,7 +379,8 @@ impl CtrlKbdLed {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn write_mode(&mut self, mode: &AuraEffect) -> Result<(), RogError> {
|
||||
/// Write the AuraEffect to the device
|
||||
pub fn write_effect_and_apply(&mut self, mode: &AuraEffect) -> Result<(), RogError> {
|
||||
if let LEDNode::KbdLed(platform) = &self.led_node {
|
||||
let buf = [
|
||||
1,
|
||||
@@ -192,7 +391,7 @@ impl CtrlKbdLed {
|
||||
mode.speed as u8,
|
||||
];
|
||||
platform.set_kbd_rgb_mode(&buf)?;
|
||||
} else if let LEDNode::Rog(hid_raw) = &self.led_node {
|
||||
} else if let LEDNode::Rog(_, hid_raw) = &self.led_node {
|
||||
let bytes: [u8; LED_MSG_LEN] = mode.into();
|
||||
hid_raw.write_bytes(&bytes)?;
|
||||
hid_raw.write_bytes(&LED_SET)?;
|
||||
@@ -221,94 +420,78 @@ impl CtrlKbdLed {
|
||||
}
|
||||
if create {
|
||||
info!("No user-set config for zone founding, attempting a default");
|
||||
self.create_multizone_default()?;
|
||||
self.config.create_multizone_default(&self.supported_data)?;
|
||||
}
|
||||
|
||||
if let Some(multizones) = self.config.multizone.as_mut() {
|
||||
if let Some(set) = multizones.get(&mode) {
|
||||
for mode in set.clone() {
|
||||
self.write_mode(&mode)?;
|
||||
self.write_effect_and_apply(&mode)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let mode = self.config.current_mode;
|
||||
if let Some(effect) = self.config.builtins.get(&mode).cloned() {
|
||||
self.write_mode(&effect)?;
|
||||
self.write_effect_and_apply(&effect)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Create a default for the `current_mode` if multizone and no config
|
||||
/// exists.
|
||||
fn create_multizone_default(&mut self) -> Result<(), RogError> {
|
||||
let mut default = vec![];
|
||||
for (i, tmp) in self.supported_data.basic_zones.iter().enumerate() {
|
||||
default.push(AuraEffect {
|
||||
mode: self.config.current_mode,
|
||||
zone: *tmp,
|
||||
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
|
||||
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Left,
|
||||
});
|
||||
}
|
||||
if default.is_empty() {
|
||||
return Err(RogError::AuraEffectNotSupported);
|
||||
}
|
||||
|
||||
if let Some(multizones) = self.config.multizone.as_mut() {
|
||||
multizones.insert(self.config.current_mode, default);
|
||||
} else {
|
||||
let mut tmp = BTreeMap::new();
|
||||
tmp.insert(self.config.current_mode, default);
|
||||
self.config.multizone = Some(tmp);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use rog_aura::aura_detection::{LaptopLedData, PowerZones};
|
||||
use rog_aura::usb::AuraDevice;
|
||||
use rog_aura::{AuraModeNum, AuraZone};
|
||||
use rog_platform::keyboard_led::KeyboardLed;
|
||||
use rog_aura::aura_detection::LedSupportData;
|
||||
use rog_aura::{AuraDeviceType, AuraModeNum, AuraZone, PowerZones};
|
||||
use rog_platform::hid_raw::HidRaw;
|
||||
use rog_platform::keyboard_led::KeyboardBacklight;
|
||||
use zbus::zvariant::OwnedObjectPath;
|
||||
|
||||
use super::CtrlKbdLed;
|
||||
use crate::ctrl_aura::config::AuraConfig;
|
||||
use crate::ctrl_aura::controller::LEDNode;
|
||||
|
||||
#[test]
|
||||
#[ignore = "Unable to run in CI as the HIDRAW device is required"]
|
||||
fn create_multizone_if_no_config() {
|
||||
// Checking to ensure set_mode errors when unsupported modes are tried
|
||||
let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default());
|
||||
let supported_basic_modes = LaptopLedData {
|
||||
board_name: String::new(),
|
||||
let config = AuraConfig::new("19b6");
|
||||
let supported_basic_modes = LedSupportData {
|
||||
device_name: String::new(),
|
||||
product_id: String::new(),
|
||||
layout_name: "ga401".to_owned(),
|
||||
basic_modes: vec![AuraModeNum::Static],
|
||||
basic_zones: vec![],
|
||||
advanced_type: rog_aura::AdvancedAuraType::None,
|
||||
advanced_type: rog_aura::keyboard::AdvancedAuraType::None,
|
||||
power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow],
|
||||
};
|
||||
let mut controller = CtrlKbdLed {
|
||||
led_prod: AuraDevice::X19b6,
|
||||
led_node: LEDNode::None,
|
||||
sysfs_node: KeyboardLed::default(),
|
||||
led_type: AuraDeviceType::LaptopPost2021,
|
||||
led_node: LEDNode::Rog(
|
||||
Some(KeyboardBacklight::default()),
|
||||
HidRaw::new("19b6").unwrap(),
|
||||
),
|
||||
supported_data: supported_basic_modes,
|
||||
per_key_mode_active: false,
|
||||
config,
|
||||
dbus_path: OwnedObjectPath::default(),
|
||||
};
|
||||
|
||||
assert!(controller.config.multizone.is_none());
|
||||
assert!(controller.create_multizone_default().is_err());
|
||||
assert!(controller
|
||||
.config
|
||||
.create_multizone_default(&controller.supported_data)
|
||||
.is_err());
|
||||
assert!(controller.config.multizone.is_none());
|
||||
|
||||
controller.supported_data.basic_zones.push(AuraZone::Key1);
|
||||
controller.supported_data.basic_zones.push(AuraZone::Key2);
|
||||
assert!(controller.create_multizone_default().is_ok());
|
||||
assert!(controller
|
||||
.config
|
||||
.create_multizone_default(&controller.supported_data)
|
||||
.is_ok());
|
||||
assert!(controller.config.multizone.is_some());
|
||||
|
||||
let m = controller.config.multizone.unwrap();
|
||||
@@ -320,24 +503,30 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Unable to run in CI as the HIDRAW device is required"]
|
||||
// TODO: use sim device
|
||||
fn next_mode_create_multizone_if_no_config() {
|
||||
// Checking to ensure set_mode errors when unsupported modes are tried
|
||||
let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default());
|
||||
let supported_basic_modes = LaptopLedData {
|
||||
board_name: String::new(),
|
||||
let config = AuraConfig::new("19b6");
|
||||
let supported_basic_modes = LedSupportData {
|
||||
device_name: String::new(),
|
||||
product_id: String::new(),
|
||||
layout_name: "ga401".to_owned(),
|
||||
basic_modes: vec![AuraModeNum::Static],
|
||||
basic_zones: vec![AuraZone::Key1, AuraZone::Key2],
|
||||
advanced_type: rog_aura::AdvancedAuraType::None,
|
||||
advanced_type: rog_aura::keyboard::AdvancedAuraType::None,
|
||||
power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow],
|
||||
};
|
||||
let mut controller = CtrlKbdLed {
|
||||
led_prod: AuraDevice::X19b6,
|
||||
led_node: LEDNode::None,
|
||||
sysfs_node: KeyboardLed::default(),
|
||||
led_type: AuraDeviceType::LaptopPost2021,
|
||||
led_node: LEDNode::Rog(
|
||||
Some(KeyboardBacklight::default()),
|
||||
HidRaw::new("19b6").unwrap(),
|
||||
),
|
||||
supported_data: supported_basic_modes,
|
||||
per_key_mode_active: false,
|
||||
config,
|
||||
dbus_path: OwnedObjectPath::default(),
|
||||
};
|
||||
|
||||
assert!(controller.config.multizone.is_none());
|
||||
|
||||
139
asusd/src/ctrl_aura/manager.rs
Normal file
139
asusd/src/ctrl_aura/manager.rs
Normal file
@@ -0,0 +1,139 @@
|
||||
// Plan:
|
||||
// - Manager has udev monitor on USB looking for ROG devices
|
||||
// - If a device is found, add it to watch
|
||||
// - Add it to Zbus server
|
||||
// - If udev sees device removed then remove the zbus path
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use log::{error, info, warn};
|
||||
use mio::{Events, Interest, Poll, Token};
|
||||
use tokio::task::spawn_blocking;
|
||||
use udev::{Device, MonitorBuilder};
|
||||
use zbus::object_server::SignalContext;
|
||||
use zbus::zvariant::{ObjectPath, OwnedObjectPath};
|
||||
use zbus::Connection;
|
||||
|
||||
use crate::ctrl_aura::controller::CtrlKbdLed;
|
||||
use crate::ctrl_aura::trait_impls::{CtrlAuraZbus, AURA_ZBUS_PATH};
|
||||
use crate::error::RogError;
|
||||
use crate::{CtrlTask, Reloadable};
|
||||
|
||||
pub struct AuraManager {
|
||||
_connection: Connection,
|
||||
}
|
||||
|
||||
impl AuraManager {
|
||||
pub async fn new(connection: Connection) -> Result<Self, RogError> {
|
||||
let conn_copy = connection.clone();
|
||||
let mut interfaces = HashSet::new();
|
||||
|
||||
// Do the initial keyboard detection:
|
||||
let all = CtrlKbdLed::find_all()?;
|
||||
for ctrl in all {
|
||||
let path = ctrl.dbus_path.clone();
|
||||
interfaces.insert(path.clone()); // ensure we record the initial stuff
|
||||
let sig_ctx = CtrlAuraZbus::signal_context(&connection)?;
|
||||
let sig_ctx2 = sig_ctx.clone();
|
||||
let zbus = CtrlAuraZbus::new(ctrl, sig_ctx);
|
||||
start_tasks(zbus, connection.clone(), sig_ctx2, path).await?;
|
||||
}
|
||||
|
||||
let manager = Self {
|
||||
_connection: connection,
|
||||
};
|
||||
|
||||
// detect all plugged in aura devices (eventually)
|
||||
// only USB devices are detected for here
|
||||
spawn_blocking(move || {
|
||||
let mut monitor = MonitorBuilder::new()?.match_subsystem("hidraw")?.listen()?;
|
||||
let mut poll = Poll::new()?;
|
||||
let mut events = Events::with_capacity(1024);
|
||||
poll.registry()
|
||||
.register(&mut monitor, Token(0), Interest::READABLE)?;
|
||||
|
||||
loop {
|
||||
if poll.poll(&mut events, None).is_err() {
|
||||
continue;
|
||||
}
|
||||
for event in monitor.iter() {
|
||||
let action = event.action().unwrap_or_default();
|
||||
|
||||
if let Some(parent) =
|
||||
event.parent_with_subsystem_devtype("usb", "usb_device")?
|
||||
{
|
||||
if action == "remove" {
|
||||
if let Some(path) = dbus_path_for_dev(&parent) {
|
||||
if interfaces.remove(&path) {
|
||||
info!("AuraManager removing: {path:?}");
|
||||
let conn_copy = conn_copy.clone();
|
||||
tokio::spawn(async move {
|
||||
let res = conn_copy
|
||||
.object_server()
|
||||
.remove::<CtrlAuraZbus, _>(&path)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("Failed to remove {path:?}, {e:?}");
|
||||
e
|
||||
})?;
|
||||
info!("AuraManager removed: {path:?}, {res}");
|
||||
Ok::<(), RogError>(())
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if action == "add" {
|
||||
if let Ok(Some(ctrl)) =
|
||||
CtrlKbdLed::maybe_device(event.device(), &mut interfaces)
|
||||
{
|
||||
ctrl.add_to_dbus_and_start(&mut interfaces, conn_copy.clone())
|
||||
.map_err(|e| {
|
||||
error!("Couldn't start aura device on dbus: {e:?}")
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
// Required for return type on spawn
|
||||
#[allow(unreachable_code)]
|
||||
Ok::<(), RogError>(())
|
||||
});
|
||||
Ok(manager)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn dbus_path_for_dev(parent: &Device) -> Option<OwnedObjectPath> {
|
||||
if let Some(filename) = super::filename_partial(parent) {
|
||||
return Some(
|
||||
ObjectPath::from_str_unchecked(&format!("{AURA_ZBUS_PATH}/{filename}")).into(),
|
||||
);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub(crate) fn dbus_path_for_tuf() -> OwnedObjectPath {
|
||||
ObjectPath::from_str_unchecked(&format!("{AURA_ZBUS_PATH}/tuf")).into()
|
||||
}
|
||||
|
||||
pub async fn start_tasks(
|
||||
mut zbus: CtrlAuraZbus,
|
||||
connection: Connection,
|
||||
_signal_ctx: SignalContext<'static>,
|
||||
path: OwnedObjectPath,
|
||||
) -> Result<(), RogError> {
|
||||
// let task = zbus.clone();
|
||||
// let signal_ctx = signal_ctx.clone();
|
||||
zbus.reload()
|
||||
.await
|
||||
.unwrap_or_else(|err| warn!("Controller error: {}", err));
|
||||
connection
|
||||
.object_server()
|
||||
.at(path.clone(), zbus)
|
||||
.await
|
||||
.map_err(|e| error!("Couldn't add server at path: {path}, {e:?}"))
|
||||
.ok();
|
||||
// TODO: skip this until we keep handles to tasks so they can be killed
|
||||
// task.create_tasks(signal_ctx).await
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,4 +1,34 @@
|
||||
use log::warn;
|
||||
use udev::Device;
|
||||
use zbus::zvariant::{ObjectPath, OwnedObjectPath};
|
||||
|
||||
pub mod config;
|
||||
pub mod controller;
|
||||
pub mod manager;
|
||||
/// Implements `CtrlTask`, `Reloadable`, `ZbusRun`
|
||||
pub mod trait_impls;
|
||||
|
||||
/// Returns only the Device details concatenated in a form usable for
|
||||
/// adding/appending to a filename
|
||||
pub(super) fn filename_partial(parent: &Device) -> Option<OwnedObjectPath> {
|
||||
if let Some(id_product) = parent.attribute_value("idProduct") {
|
||||
let id_product = id_product.to_string_lossy();
|
||||
let mut path = if let Some(devnum) = parent.attribute_value("devnum") {
|
||||
let devnum = devnum.to_string_lossy();
|
||||
if let Some(devpath) = parent.attribute_value("devpath") {
|
||||
let devpath = devpath.to_string_lossy();
|
||||
format!("{id_product}_{devnum}_{devpath}")
|
||||
} else {
|
||||
format!("{id_product}_{devnum}")
|
||||
}
|
||||
} else {
|
||||
format!("{id_product}")
|
||||
};
|
||||
if path.contains('.') {
|
||||
warn!("dbus path for {id_product} contains `.`, removing");
|
||||
path.replace('.', "").clone_into(&mut path);
|
||||
}
|
||||
return Some(ObjectPath::from_str_unchecked(&path).into());
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
@@ -3,28 +3,30 @@ use std::sync::Arc;
|
||||
|
||||
use config_traits::StdConfig;
|
||||
use log::{debug, error, info, warn};
|
||||
use rog_aura::advanced::UsbPackets;
|
||||
use rog_aura::aura_detection::PowerZones;
|
||||
use rog_aura::usb::{AuraDevice, AuraPowerDev};
|
||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
|
||||
use rog_aura::keyboard::{LaptopAuraPower, UsbPackets};
|
||||
use rog_aura::{AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, LedBrightness, PowerZones};
|
||||
use zbus::export::futures_util::lock::{Mutex, MutexGuard};
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use zbus::fdo::Error as ZbErr;
|
||||
use zbus::{dbus_interface, Connection, SignalContext};
|
||||
use zbus::{interface, SignalContext};
|
||||
|
||||
use super::controller::CtrlKbdLed;
|
||||
use crate::error::RogError;
|
||||
use crate::CtrlTask;
|
||||
|
||||
pub const AURA_ZBUS_NAME: &str = "Aura";
|
||||
pub const AURA_ZBUS_PATH: &str = "/org/asuslinux/Aura";
|
||||
pub const AURA_ZBUS_PATH: &str = "/org/asuslinux";
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CtrlAuraZbus(pub Arc<Mutex<CtrlKbdLed>>);
|
||||
pub struct CtrlAuraZbus(Arc<Mutex<CtrlKbdLed>>, SignalContext<'static>);
|
||||
|
||||
impl CtrlAuraZbus {
|
||||
pub fn new(controller: CtrlKbdLed, signal: SignalContext<'static>) -> Self {
|
||||
Self(Arc::new(Mutex::new(controller)), signal)
|
||||
}
|
||||
|
||||
fn update_config(lock: &mut CtrlKbdLed) -> Result<(), RogError> {
|
||||
let bright = lock.sysfs_node.get_brightness()?;
|
||||
let bright = lock.led_node.get_brightness().unwrap_or_default();
|
||||
lock.config.read();
|
||||
lock.config.brightness = bright.into();
|
||||
lock.config.write();
|
||||
@@ -32,40 +34,34 @@ impl CtrlAuraZbus {
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::ZbusRun for CtrlAuraZbus {
|
||||
async fn add_to_server(self, server: &mut Connection) {
|
||||
Self::add_to_server_helper(self, AURA_ZBUS_PATH, server).await;
|
||||
}
|
||||
}
|
||||
|
||||
/// The main interface for changing, reading, or notfying signals
|
||||
/// The main interface for changing, reading, or notfying
|
||||
///
|
||||
/// LED commands are split between Brightness, Modes, Per-Key
|
||||
#[dbus_interface(name = "org.asuslinux.Daemon")]
|
||||
#[interface(name = "org.asuslinux.Aura")]
|
||||
impl CtrlAuraZbus {
|
||||
/// Return the device type for this Aura keyboard
|
||||
#[dbus_interface(property)]
|
||||
async fn device_type(&self) -> AuraDevice {
|
||||
#[zbus(property)]
|
||||
async fn device_type(&self) -> AuraDeviceType {
|
||||
let ctrl = self.0.lock().await;
|
||||
ctrl.led_prod
|
||||
ctrl.led_type
|
||||
}
|
||||
|
||||
/// Return the current LED brightness
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn brightness(&self) -> Result<LedBrightness, ZbErr> {
|
||||
let ctrl = self.0.lock().await;
|
||||
Ok(ctrl.sysfs_node.get_brightness().map(|n| n.into())?)
|
||||
Ok(ctrl.led_node.get_brightness().map(|n| n.into())?)
|
||||
}
|
||||
|
||||
/// Set the keyboard brightness level (0-3)
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_brightness(&mut self, brightness: LedBrightness) -> Result<(), ZbErr> {
|
||||
let ctrl = self.0.lock().await;
|
||||
Ok(ctrl.sysfs_node.set_brightness(brightness.into())?)
|
||||
Ok(ctrl.led_node.set_brightness(brightness.into())?)
|
||||
}
|
||||
|
||||
/// Total levels of brightness available
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn supported_brightness(&self) -> Vec<LedBrightness> {
|
||||
vec![
|
||||
LedBrightness::Off,
|
||||
@@ -76,26 +72,26 @@ impl CtrlAuraZbus {
|
||||
}
|
||||
|
||||
/// The total available modes
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn supported_basic_modes(&self) -> Result<Vec<AuraModeNum>, ZbErr> {
|
||||
let ctrl = self.0.lock().await;
|
||||
Ok(ctrl.config.builtins.keys().cloned().collect())
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn supported_basic_zones(&self) -> Result<Vec<AuraZone>, ZbErr> {
|
||||
let ctrl = self.0.lock().await;
|
||||
Ok(ctrl.supported_data.basic_zones.clone())
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn supported_power_zones(&self) -> Result<Vec<PowerZones>, ZbErr> {
|
||||
let ctrl = self.0.lock().await;
|
||||
Ok(ctrl.supported_data.power_zones.clone())
|
||||
}
|
||||
|
||||
/// The current mode data
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn led_mode(&self) -> Result<AuraModeNum, ZbErr> {
|
||||
let ctrl = self.0.lock().await;
|
||||
Ok(ctrl.config.current_mode)
|
||||
@@ -105,7 +101,7 @@ impl CtrlAuraZbus {
|
||||
///
|
||||
/// On success the aura config file is read to refresh cached values, then
|
||||
/// the effect is stored and config written to disk.
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_led_mode(&mut self, num: AuraModeNum) -> Result<(), ZbErr> {
|
||||
let mut ctrl = self.0.lock().await;
|
||||
ctrl.config.current_mode = num;
|
||||
@@ -113,14 +109,18 @@ impl CtrlAuraZbus {
|
||||
if ctrl.config.brightness == LedBrightness::Off {
|
||||
ctrl.config.brightness = LedBrightness::Med;
|
||||
}
|
||||
ctrl.sysfs_node
|
||||
.set_brightness(ctrl.config.brightness.into())?;
|
||||
if ctrl.led_node.has_brightness_control() {
|
||||
ctrl.led_node
|
||||
.set_brightness(ctrl.config.brightness.into())?;
|
||||
}
|
||||
ctrl.config.write();
|
||||
|
||||
self.led_mode_data_invalidate(&self.1).await.ok();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The current mode data
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> {
|
||||
let ctrl = self.0.lock().await;
|
||||
let mode = ctrl.config.current_mode;
|
||||
@@ -134,7 +134,7 @@ impl CtrlAuraZbus {
|
||||
///
|
||||
/// On success the aura config file is read to refresh cached values, then
|
||||
/// the effect is stored and config written to disk.
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_led_mode_data(&mut self, effect: AuraEffect) -> Result<(), ZbErr> {
|
||||
let mut ctrl = self.0.lock().await;
|
||||
if !ctrl.supported_data.basic_modes.contains(&effect.mode)
|
||||
@@ -146,14 +146,18 @@ impl CtrlAuraZbus {
|
||||
)));
|
||||
}
|
||||
|
||||
ctrl.write_mode(&effect)?;
|
||||
ctrl.write_effect_and_apply(&effect)?;
|
||||
if ctrl.config.brightness == LedBrightness::Off {
|
||||
ctrl.config.brightness = LedBrightness::Med;
|
||||
}
|
||||
ctrl.sysfs_node
|
||||
.set_brightness(ctrl.config.brightness.into())?;
|
||||
if ctrl.led_node.has_brightness_control() {
|
||||
ctrl.led_node
|
||||
.set_brightness(ctrl.config.brightness.into())?;
|
||||
}
|
||||
ctrl.config.set_builtin(effect);
|
||||
ctrl.config.write();
|
||||
|
||||
self.led_mode_invalidate(&self.1).await.ok();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -164,28 +168,27 @@ impl CtrlAuraZbus {
|
||||
}
|
||||
|
||||
// As property doesn't work for AuraPowerDev (complexity of serialization?)
|
||||
#[dbus_interface(property)]
|
||||
async fn led_power(&self) -> AuraPowerDev {
|
||||
#[zbus(property)]
|
||||
async fn led_power(&self) -> LaptopAuraPower {
|
||||
let ctrl = self.0.lock().await;
|
||||
AuraPowerDev::from(&ctrl.config.enabled)
|
||||
ctrl.config.enabled.clone()
|
||||
}
|
||||
|
||||
/// Set a variety of states, input is array of enum.
|
||||
/// `enabled` sets if the sent array should be disabled or enabled
|
||||
///
|
||||
/// For Modern ROG devices the "enabled" flag is ignored.
|
||||
#[dbus_interface(property)]
|
||||
async fn set_led_power(&mut self, options: (AuraPowerDev, bool)) -> Result<(), ZbErr> {
|
||||
let enabled = options.1;
|
||||
let options = options.0;
|
||||
#[zbus(property)]
|
||||
async fn set_led_power(&mut self, options: LaptopAuraPower) -> Result<(), ZbErr> {
|
||||
let mut ctrl = self.0.lock().await;
|
||||
for p in options.tuf {
|
||||
ctrl.config.enabled.set_tuf(p, enabled);
|
||||
for opt in options.states {
|
||||
let zone = opt.zone;
|
||||
for config in ctrl.config.enabled.states.iter_mut() {
|
||||
if config.zone == zone {
|
||||
*config = opt;
|
||||
}
|
||||
}
|
||||
}
|
||||
for p in options.old_rog {
|
||||
ctrl.config.enabled.set_0x1866(p, enabled);
|
||||
}
|
||||
ctrl.config.enabled.set_0x19b6(options.rog);
|
||||
ctrl.config.write();
|
||||
Ok(ctrl.set_power_states().map_err(|e| {
|
||||
warn!("{}", e);
|
||||
@@ -205,27 +208,35 @@ impl CtrlAuraZbus {
|
||||
|
||||
impl CtrlTask for CtrlAuraZbus {
|
||||
fn zbus_path() -> &'static str {
|
||||
AURA_ZBUS_PATH
|
||||
"/org/asuslinux"
|
||||
}
|
||||
|
||||
async fn create_tasks(&self, _: SignalContext<'static>) -> Result<(), RogError> {
|
||||
let load_save = |start: bool, mut lock: MutexGuard<'_, CtrlKbdLed>| {
|
||||
// If waking up
|
||||
if !start {
|
||||
info!("CtrlKbdLedTask reloading brightness and modes");
|
||||
lock.sysfs_node
|
||||
.set_brightness(lock.config.brightness.into())
|
||||
.map_err(|e| error!("CtrlKbdLedTask: {e}"))
|
||||
.ok();
|
||||
lock.write_current_config_mode()
|
||||
.map_err(|e| error!("CtrlKbdLedTask: {e}"))
|
||||
.ok();
|
||||
} else if start {
|
||||
Self::update_config(&mut lock)
|
||||
.map_err(|e| error!("CtrlKbdLedTask: {e}"))
|
||||
.ok();
|
||||
}
|
||||
};
|
||||
let load_save =
|
||||
|start: bool, mut lock: MutexGuard<'_, CtrlKbdLed>| -> Result<(), RogError> {
|
||||
// If waking up
|
||||
if !start {
|
||||
info!("CtrlKbdLedTask reloading brightness and modes");
|
||||
if lock.led_node.has_brightness_control() {
|
||||
lock.led_node
|
||||
.set_brightness(lock.config.brightness.into())
|
||||
.map_err(|e| {
|
||||
error!("CtrlKbdLedTask: {e}");
|
||||
e
|
||||
})?;
|
||||
}
|
||||
lock.write_current_config_mode().map_err(|e| {
|
||||
error!("CtrlKbdLedTask: {e}");
|
||||
e
|
||||
})?;
|
||||
} else if start {
|
||||
Self::update_config(&mut lock).map_err(|e| {
|
||||
error!("CtrlKbdLedTask: {e}");
|
||||
e
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
};
|
||||
|
||||
let inner1 = self.0.clone();
|
||||
let inner3 = self.0.clone();
|
||||
@@ -234,14 +245,16 @@ impl CtrlTask for CtrlAuraZbus {
|
||||
let inner1 = inner1.clone();
|
||||
async move {
|
||||
let lock = inner1.lock().await;
|
||||
load_save(sleeping, lock);
|
||||
load_save(sleeping, lock).unwrap(); // unwrap as we want to
|
||||
// bomb out of the task
|
||||
}
|
||||
},
|
||||
move |_shutting_down| {
|
||||
let inner3 = inner3.clone();
|
||||
async move {
|
||||
let lock = inner3.lock().await;
|
||||
load_save(false, lock);
|
||||
load_save(false, lock).unwrap(); // unwrap as we want to
|
||||
// bomb out of the task
|
||||
}
|
||||
},
|
||||
move |_lid_closed| {
|
||||
@@ -257,19 +270,24 @@ impl CtrlTask for CtrlAuraZbus {
|
||||
|
||||
let ctrl2 = self.0.clone();
|
||||
let ctrl = self.0.lock().await;
|
||||
let watch = ctrl.sysfs_node.monitor_brightness()?;
|
||||
tokio::spawn(async move {
|
||||
let mut buffer = [0; 32];
|
||||
watch
|
||||
.into_event_stream(&mut buffer)
|
||||
.unwrap()
|
||||
.for_each(|_| async {
|
||||
if let Some(lock) = ctrl2.try_lock() {
|
||||
load_save(true, lock);
|
||||
}
|
||||
})
|
||||
.await;
|
||||
});
|
||||
if ctrl.led_node.has_brightness_control() {
|
||||
let watch = ctrl.led_node.monitor_brightness()?;
|
||||
tokio::spawn(async move {
|
||||
let mut buffer = [0; 32];
|
||||
watch
|
||||
.into_event_stream(&mut buffer)
|
||||
.unwrap()
|
||||
.for_each(|_| async {
|
||||
if let Some(lock) = ctrl2.try_lock() {
|
||||
load_save(true, lock).unwrap(); // unwrap as we want
|
||||
// to
|
||||
// bomb out of the
|
||||
// task
|
||||
}
|
||||
})
|
||||
.await;
|
||||
});
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -278,9 +296,9 @@ impl CtrlTask for CtrlAuraZbus {
|
||||
impl crate::Reloadable for CtrlAuraZbus {
|
||||
async fn reload(&mut self) -> Result<(), RogError> {
|
||||
let mut ctrl = self.0.lock().await;
|
||||
debug!("CtrlKbdLedZbus: reloading keyboard mode");
|
||||
debug!("reloading keyboard mode");
|
||||
ctrl.write_current_config_mode()?;
|
||||
debug!("CtrlKbdLedZbus: reloading power states");
|
||||
debug!("reloading power states");
|
||||
ctrl.set_power_states().map_err(|err| warn!("{err}")).ok();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -10,20 +10,17 @@ use rog_profiles::fan_curve_set::CurveData;
|
||||
use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use tokio::sync::Mutex;
|
||||
use zbus::{dbus_interface, Connection, SignalContext};
|
||||
use zbus::{interface, Connection, SignalContext};
|
||||
|
||||
use crate::error::RogError;
|
||||
use crate::{CtrlTask, CONFIG_PATH_BASE};
|
||||
|
||||
const MOD_NAME: &str = "FanCurveZbus";
|
||||
pub const FAN_CURVE_ZBUS_NAME: &str = "FanCurves";
|
||||
pub const FAN_CURVE_ZBUS_PATH: &str = "/org/asuslinux/FanCurves";
|
||||
pub const FAN_CURVE_ZBUS_PATH: &str = "/org/asuslinux";
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Default)]
|
||||
pub struct FanCurveConfig {
|
||||
pub balanced: Vec<CurveData>,
|
||||
pub performance: Vec<CurveData>,
|
||||
pub quiet: Vec<CurveData>,
|
||||
pub profiles: FanCurveProfiles,
|
||||
#[serde(skip)]
|
||||
pub current: u8,
|
||||
}
|
||||
@@ -49,7 +46,6 @@ impl StdConfigLoad for FanCurveConfig {}
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CtrlFanCurveZbus {
|
||||
config: Arc<Mutex<FanCurveConfig>>,
|
||||
fan_curves: Arc<Mutex<FanCurveProfiles>>,
|
||||
platform: RogPlatform,
|
||||
}
|
||||
|
||||
@@ -58,16 +54,17 @@ impl CtrlFanCurveZbus {
|
||||
pub fn new() -> Result<Self, RogError> {
|
||||
let platform = RogPlatform::new()?;
|
||||
if platform.has_throttle_thermal_policy() {
|
||||
info!("{MOD_NAME}: Device has profile control available");
|
||||
info!("Device has profile control available");
|
||||
find_fan_curve_node()?;
|
||||
info!("{MOD_NAME}: Device has fan curves available");
|
||||
let mut config = FanCurveConfig::new();
|
||||
info!("Device has fan curves available");
|
||||
let mut config = FanCurveConfig::new().load();
|
||||
let mut fan_curves = FanCurveProfiles::default();
|
||||
|
||||
// Only do defaults if the config doesn't already exist
|
||||
if !config.file_path().exists() {
|
||||
info!("{MOD_NAME}: Fetching default fan curves");
|
||||
// Only do defaults if the config doesn't already exist\
|
||||
if config.profiles.balanced.is_empty() || !config.file_path().exists() {
|
||||
info!("Fetching default fan curves");
|
||||
|
||||
let current = platform.get_throttle_thermal_policy()?;
|
||||
for this in [
|
||||
ThrottlePolicy::Balanced,
|
||||
ThrottlePolicy::Performance,
|
||||
@@ -76,54 +73,34 @@ impl CtrlFanCurveZbus {
|
||||
// For each profile we need to switch to it before we
|
||||
// can read the existing values from hardware. The ACPI method used
|
||||
// for this is what limits us.
|
||||
let next = ThrottlePolicy::next(this);
|
||||
platform.set_throttle_thermal_policy(next.into())?;
|
||||
platform.set_throttle_thermal_policy(this.into())?;
|
||||
let mut dev = find_fan_curve_node()?;
|
||||
fan_curves.set_active_curve_to_defaults(this, &mut dev)?;
|
||||
|
||||
let active = platform
|
||||
.get_throttle_thermal_policy()
|
||||
.map_or(ThrottlePolicy::Balanced, |t| t.into());
|
||||
|
||||
info!("{MOD_NAME}: {active:?}:");
|
||||
for curve in fan_curves.get_fan_curves_for(active) {
|
||||
info!("{this:?}:");
|
||||
for curve in fan_curves.get_fan_curves_for(this) {
|
||||
info!("{}", String::from(curve));
|
||||
}
|
||||
}
|
||||
platform.set_throttle_thermal_policy(current)?;
|
||||
config.profiles = fan_curves;
|
||||
config.write();
|
||||
} else {
|
||||
info!("{MOD_NAME}: Fan curves previously stored, loading...");
|
||||
info!("Fan curves previously stored, loading...");
|
||||
config = config.load();
|
||||
fan_curves.balanced = config.balanced.clone();
|
||||
fan_curves.performance = config.performance.clone();
|
||||
fan_curves.quiet = config.quiet.clone();
|
||||
}
|
||||
|
||||
return Ok(Self {
|
||||
config: Arc::new(Mutex::new(config)),
|
||||
fan_curves: Arc::new(Mutex::new(fan_curves)),
|
||||
platform,
|
||||
});
|
||||
}
|
||||
|
||||
Err(ProfileError::NotSupported.into())
|
||||
}
|
||||
|
||||
pub async fn update_profiles_from_config(&self) {
|
||||
self.fan_curves.lock().await.balanced = self.config.lock().await.balanced.clone();
|
||||
self.fan_curves.lock().await.performance = self.config.lock().await.performance.clone();
|
||||
self.fan_curves.lock().await.quiet = self.config.lock().await.quiet.clone();
|
||||
}
|
||||
|
||||
/// Because this locks both config and fan_curves, it means nothing else can
|
||||
/// hold a lock across this function call. Stupid choice to do this and
|
||||
/// needs to be fixed.
|
||||
pub async fn update_config_from_profiles(&self) {
|
||||
self.config.lock().await.balanced = self.fan_curves.lock().await.balanced.clone();
|
||||
self.config.lock().await.performance = self.fan_curves.lock().await.performance.clone();
|
||||
self.config.lock().await.quiet = self.fan_curves.lock().await.quiet.clone();
|
||||
}
|
||||
}
|
||||
|
||||
#[dbus_interface(name = "org.asuslinux.Daemon")]
|
||||
#[interface(name = "org.asuslinux.FanCurves")]
|
||||
impl CtrlFanCurveZbus {
|
||||
/// Set all fan curves for a profile to enabled status. Will also activate a
|
||||
/// fan curve if in the same profile mode
|
||||
@@ -132,15 +109,16 @@ impl CtrlFanCurveZbus {
|
||||
profile: ThrottlePolicy,
|
||||
enabled: bool,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.fan_curves
|
||||
self.config
|
||||
.lock()
|
||||
.await
|
||||
.profiles
|
||||
.set_profile_curves_enabled(profile, enabled);
|
||||
self.fan_curves
|
||||
self.config
|
||||
.lock()
|
||||
.await
|
||||
.profiles
|
||||
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
|
||||
self.update_config_from_profiles().await;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
@@ -153,15 +131,16 @@ impl CtrlFanCurveZbus {
|
||||
fan: FanCurvePU,
|
||||
enabled: bool,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.fan_curves
|
||||
self.config
|
||||
.lock()
|
||||
.await
|
||||
.profiles
|
||||
.set_profile_fan_curve_enabled(profile, fan, enabled);
|
||||
self.fan_curves
|
||||
self.config
|
||||
.lock()
|
||||
.await
|
||||
.profiles
|
||||
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
|
||||
self.update_config_from_profiles().await;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
@@ -172,9 +151,10 @@ impl CtrlFanCurveZbus {
|
||||
profile: ThrottlePolicy,
|
||||
) -> zbus::fdo::Result<Vec<CurveData>> {
|
||||
let curve = self
|
||||
.fan_curves
|
||||
.config
|
||||
.lock()
|
||||
.await
|
||||
.profiles
|
||||
.get_fan_curves_for(profile)
|
||||
.to_vec();
|
||||
Ok(curve)
|
||||
@@ -187,31 +167,37 @@ impl CtrlFanCurveZbus {
|
||||
profile: ThrottlePolicy,
|
||||
curve: CurveData,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.fan_curves
|
||||
self.config
|
||||
.lock()
|
||||
.await
|
||||
.profiles
|
||||
.save_fan_curve(curve, profile)?;
|
||||
self.fan_curves
|
||||
.lock()
|
||||
.await
|
||||
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
|
||||
self.update_config_from_profiles().await;
|
||||
let active: ThrottlePolicy = self.platform.get_throttle_thermal_policy()?.into();
|
||||
if active == profile {
|
||||
self.config
|
||||
.lock()
|
||||
.await
|
||||
.profiles
|
||||
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
|
||||
}
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Reset the stored (self) and device curve to the defaults of the
|
||||
/// Reset the stored (self) and device curves to the defaults of the
|
||||
/// platform.
|
||||
///
|
||||
/// Each platform_profile has a different default and the defualt can be
|
||||
/// Each platform_profile has a different default and the default can be
|
||||
/// read only for the currently active profile.
|
||||
async fn set_active_curve_to_defaults(&mut self) -> zbus::fdo::Result<()> {
|
||||
async fn set_curves_to_defaults(&mut self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> {
|
||||
let active = self.platform.get_throttle_thermal_policy()?;
|
||||
self.fan_curves
|
||||
self.platform.set_throttle_thermal_policy(profile.into())?;
|
||||
self.config
|
||||
.lock()
|
||||
.await
|
||||
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
|
||||
self.update_config_from_profiles().await;
|
||||
.profiles
|
||||
.set_active_curve_to_defaults(profile, &mut find_fan_curve_node()?)?;
|
||||
self.platform.set_throttle_thermal_policy(active)?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
@@ -225,13 +211,13 @@ impl CtrlFanCurveZbus {
|
||||
let active = self.platform.get_throttle_thermal_policy()?;
|
||||
|
||||
self.platform.set_throttle_thermal_policy(profile.into())?;
|
||||
self.fan_curves
|
||||
self.config
|
||||
.lock()
|
||||
.await
|
||||
.profiles
|
||||
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
|
||||
self.platform.set_throttle_thermal_policy(active)?;
|
||||
|
||||
self.update_config_from_profiles().await;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
@@ -252,7 +238,7 @@ impl CtrlTask for CtrlFanCurveZbus {
|
||||
let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?;
|
||||
let platform = self.platform.clone();
|
||||
let config = self.config.clone();
|
||||
let fan_curves = self.fan_curves.clone();
|
||||
let fan_curves = self.config.clone();
|
||||
|
||||
tokio::spawn(async move {
|
||||
let mut buffer = [0; 32];
|
||||
@@ -260,19 +246,18 @@ impl CtrlTask for CtrlFanCurveZbus {
|
||||
while (stream.next().await).is_some() {
|
||||
debug!("watch_throttle_thermal_policy changed");
|
||||
if let Ok(profile) = platform.get_throttle_thermal_policy().map_err(|e| {
|
||||
error!("{MOD_NAME}: get_throttle_thermal_policy error: {e}");
|
||||
error!("get_throttle_thermal_policy error: {e}");
|
||||
}) {
|
||||
if profile != config.lock().await.current {
|
||||
fan_curves
|
||||
.lock()
|
||||
.await
|
||||
.profiles
|
||||
.write_profile_curve_to_platform(
|
||||
profile.into(),
|
||||
&mut find_fan_curve_node().unwrap(),
|
||||
)
|
||||
.map_err(|e| {
|
||||
warn!("{MOD_NAME}: write_profile_curve_to_platform, {}", e)
|
||||
})
|
||||
.map_err(|e| warn!("write_profile_curve_to_platform, {}", e))
|
||||
.ok();
|
||||
config.lock().await.current = profile;
|
||||
}
|
||||
@@ -289,17 +274,13 @@ impl crate::Reloadable for CtrlFanCurveZbus {
|
||||
/// Fetch the active profile and use that to set all related components up
|
||||
async fn reload(&mut self) -> Result<(), RogError> {
|
||||
let active = self.platform.get_throttle_thermal_policy()?.into();
|
||||
let mut config = self.config.lock().await;
|
||||
if let Ok(mut device) = find_fan_curve_node() {
|
||||
// There is a possibility that the curve was default zeroed, so this call
|
||||
// initialises the data from system read and we need to save it
|
||||
// after
|
||||
loop {
|
||||
if let Ok(mut curves) = self.fan_curves.try_lock() {
|
||||
curves.write_profile_curve_to_platform(active, &mut device)?;
|
||||
break;
|
||||
}
|
||||
}
|
||||
config
|
||||
.profiles
|
||||
.write_profile_curve_to_platform(active, &mut device)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,17 +9,13 @@ use rog_platform::platform::{GpuMode, Properties, RogPlatform, ThrottlePolicy};
|
||||
use rog_platform::power::AsusPower;
|
||||
use zbus::export::futures_util::lock::Mutex;
|
||||
use zbus::fdo::Error as FdoErr;
|
||||
use zbus::{dbus_interface, Connection, ObjectServer, SignalContext};
|
||||
use zbus::{interface, Connection, SignalContext};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::ctrl_anime::trait_impls::{CtrlAnimeZbus, ANIME_ZBUS_NAME, ANIME_ZBUS_PATH};
|
||||
use crate::ctrl_aura::trait_impls::{CtrlAuraZbus, AURA_ZBUS_NAME, AURA_ZBUS_PATH};
|
||||
use crate::ctrl_fancurves::{CtrlFanCurveZbus, FAN_CURVE_ZBUS_NAME, FAN_CURVE_ZBUS_PATH};
|
||||
use crate::error::RogError;
|
||||
use crate::{task_watch_item, task_watch_item_notify, CtrlTask, ReloadAndNotify};
|
||||
|
||||
const PLATFORM_ZBUS_NAME: &str = "Platform";
|
||||
const PLATFORM_ZBUS_PATH: &str = "/org/asuslinux/Platform";
|
||||
const PLATFORM_ZBUS_PATH: &str = "/org/asuslinux";
|
||||
|
||||
macro_rules! platform_get_value {
|
||||
($self:ident, $property:tt, $prop_name:literal) => {
|
||||
@@ -29,33 +25,18 @@ macro_rules! platform_get_value {
|
||||
$self.platform
|
||||
.get()
|
||||
.map_err(|err| {
|
||||
warn!("RogPlatform: {}: {}", $prop_name, err);
|
||||
warn!("{}: {}", $prop_name, err);
|
||||
FdoErr::Failed(format!("RogPlatform: {}: {}", $prop_name, err))
|
||||
})
|
||||
})
|
||||
} else {
|
||||
info!("RogPlatform: {} not supported", $prop_name);
|
||||
return Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)));
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! platform_get_value_if_some {
|
||||
($self:ident, $property:tt, $prop_name:literal, $default:expr) => {
|
||||
concat_idents::concat_idents!(has = has_, $property {
|
||||
if $self.platform.has() {
|
||||
let lock = $self.config.lock().await;
|
||||
Ok(lock.$property.unwrap_or($default))
|
||||
} else {
|
||||
info!("RogPlatform: {} not supported", $prop_name);
|
||||
return Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)));
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! platform_set_bool {
|
||||
macro_rules! platform_set_value {
|
||||
($self:ident, $property:tt, $prop_name:literal, $new_value:expr) => {
|
||||
concat_idents::concat_idents!(has = has_, $property {
|
||||
if $self.platform.has() {
|
||||
@@ -70,40 +51,32 @@ macro_rules! platform_set_bool {
|
||||
lock.write();
|
||||
Ok(())
|
||||
} else {
|
||||
info!("RogPlatform: {} not supported", $prop_name);
|
||||
debug!("RogPlatform: {} not supported", $prop_name);
|
||||
Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Intended only for setting platform object values where the value isn't
|
||||
/// retained across boots
|
||||
macro_rules! platform_set_with_min_max {
|
||||
($self:ident, $property:tt, $prop_name:literal, $new_value:expr, $min_value:expr, $max_value:expr) => {
|
||||
if !($min_value..=$max_value).contains(&$new_value) {
|
||||
Err(FdoErr::Failed(
|
||||
format!("RogPlatform: {} value not in range {}=..={}", $prop_name, $min_value, $max_value)
|
||||
))
|
||||
} else {
|
||||
concat_idents::concat_idents!(has = has_, $property {
|
||||
if $self.platform.has() {
|
||||
concat_idents::concat_idents!(set = set_, $property {
|
||||
$self.platform.set($new_value).map_err(|err| {
|
||||
error!("RogPlatform: {} {err}", $prop_name);
|
||||
FdoErr::NotSupported(format!("RogPlatform: {} {err}", $prop_name))
|
||||
})?;
|
||||
});
|
||||
let mut lock = $self.config.lock().await;
|
||||
lock.$property = Some($new_value);
|
||||
lock.write();
|
||||
} else {
|
||||
error!("RogPlatform: {} not supported", $prop_name);
|
||||
return Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)));
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
macro_rules! platform_ppt_set_value {
|
||||
($self:ident, $property:tt, $prop_name:literal, $new_value:expr) => {
|
||||
concat_idents::concat_idents!(has = has_, $property {
|
||||
if $self.platform.has() {
|
||||
concat_idents::concat_idents!(set = set_, $property {
|
||||
$self.platform.set($new_value).map_err(|err| {
|
||||
error!("RogPlatform: {} {err}", $prop_name);
|
||||
FdoErr::NotSupported(format!("RogPlatform: {} {err}", $prop_name))
|
||||
})?;
|
||||
});
|
||||
let mut lock = $self.config.lock().await;
|
||||
lock.$property = Some($new_value);
|
||||
lock.write();
|
||||
Ok(())
|
||||
} else {
|
||||
debug!("RogPlatform: ppt: setting {} not supported", $prop_name);
|
||||
Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +171,7 @@ impl CtrlPlatform {
|
||||
fn set_gfx_mode(&self, mode: GpuMode) -> Result<(), RogError> {
|
||||
self.platform.set_gpu_mux_mode(mode.to_mux_attr())?;
|
||||
// self.update_initramfs(enable)?;
|
||||
if mode == GpuMode::Discrete {
|
||||
if mode == GpuMode::Ultimate {
|
||||
info!("Set system-level graphics mode: Dedicated Nvidia");
|
||||
} else {
|
||||
info!("Set system-level graphics mode: Optimus");
|
||||
@@ -255,7 +228,16 @@ impl CtrlPlatform {
|
||||
cpu.set_epp(enegy_pref).ok();
|
||||
} else if let Ok(gov) = cpu.get_governor() {
|
||||
if gov != CPUGovernor::Powersave {
|
||||
warn!("powersave governor is not is use, you should use it.");
|
||||
warn!("powersave governor is not is use, trying to set.");
|
||||
cpu.set_governor(CPUGovernor::Powersave)
|
||||
.map_err(|e| error!("couldn't set powersave: {e:?}"))
|
||||
.ok();
|
||||
if epp.contains(&enegy_pref) {
|
||||
debug!("Setting {enegy_pref:?}");
|
||||
cpu.set_epp(enegy_pref)
|
||||
.map_err(|e| error!("couldn't set EPP: {e:?}"))
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,6 +253,21 @@ impl CtrlPlatform {
|
||||
}
|
||||
|
||||
async fn update_policy_ac_or_bat(&self, power_plugged: bool, change_epp: bool) {
|
||||
if power_plugged && !self.config.lock().await.change_throttle_policy_on_ac {
|
||||
debug!(
|
||||
"Power status changed but set_throttle_policy_on_ac set false. Not setting the \
|
||||
thing"
|
||||
);
|
||||
return;
|
||||
}
|
||||
if !power_plugged && !self.config.lock().await.change_throttle_policy_on_battery {
|
||||
debug!(
|
||||
"Power status changed but set_throttle_policy_on_battery set false. Not setting \
|
||||
the thing"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let throttle = if power_plugged {
|
||||
self.config.lock().await.throttle_policy_on_ac
|
||||
} else {
|
||||
@@ -285,8 +282,13 @@ impl CtrlPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
#[dbus_interface(name = "org.asuslinux.Daemon")]
|
||||
#[interface(name = "org.asuslinux.Platform")]
|
||||
impl CtrlPlatform {
|
||||
#[zbus(property)]
|
||||
async fn version(&self) -> String {
|
||||
crate::VERSION.to_string()
|
||||
}
|
||||
|
||||
/// Returns a list of property names that this system supports
|
||||
async fn supported_properties(&self) -> Vec<Properties> {
|
||||
let mut supported = Vec::new();
|
||||
@@ -319,7 +321,7 @@ impl CtrlPlatform {
|
||||
|
||||
platform_name!(dgpu_disable, Properties::DgpuDisable);
|
||||
platform_name!(gpu_mux_mode, Properties::GpuMuxMode);
|
||||
platform_name!(post_animation_sound, Properties::PostAnimationSound);
|
||||
platform_name!(boot_sound, Properties::PostAnimationSound);
|
||||
platform_name!(panel_od, Properties::PanelOd);
|
||||
platform_name!(mini_led_mode, Properties::MiniLedMode);
|
||||
platform_name!(egpu_enable, Properties::EgpuEnable);
|
||||
@@ -336,78 +338,45 @@ impl CtrlPlatform {
|
||||
supported
|
||||
}
|
||||
|
||||
async fn supported_interfaces(
|
||||
&self,
|
||||
#[zbus(object_server)] server: &ObjectServer,
|
||||
) -> Vec<String> {
|
||||
let mut interfaces = Vec::default();
|
||||
if server
|
||||
.interface::<_, CtrlAnimeZbus>(ANIME_ZBUS_PATH)
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
interfaces.push(ANIME_ZBUS_NAME.to_owned());
|
||||
}
|
||||
if server
|
||||
.interface::<_, CtrlAuraZbus>(AURA_ZBUS_PATH)
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
interfaces.push(AURA_ZBUS_NAME.to_owned());
|
||||
}
|
||||
if server
|
||||
.interface::<_, CtrlFanCurveZbus>(FAN_CURVE_ZBUS_PATH)
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
interfaces.push(FAN_CURVE_ZBUS_NAME.to_owned());
|
||||
}
|
||||
if server
|
||||
.interface::<_, CtrlPlatform>(PLATFORM_ZBUS_PATH)
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
interfaces.push(PLATFORM_ZBUS_NAME.to_owned());
|
||||
}
|
||||
interfaces
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
fn charge_control_end_threshold(&self) -> Result<u8, FdoErr> {
|
||||
let limit = self.power.get_charge_control_end_threshold()?;
|
||||
Ok(limit)
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_charge_control_end_threshold(&mut self, limit: u8) -> Result<(), FdoErr> {
|
||||
if !(20..=100).contains(&limit) {
|
||||
return Err(RogError::ChargeLimit(limit))?;
|
||||
}
|
||||
self.power.set_charge_control_end_threshold(limit)?;
|
||||
self.config.lock().await.charge_control_end_threshold = limit;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
fn gpu_mux_mode(&self) -> Result<u8, FdoErr> {
|
||||
self.platform.get_gpu_mux_mode().map_err(|err| {
|
||||
warn!("RogPlatform: set_gpu_mux_mode {err}");
|
||||
warn!("get_gpu_mux_mode {err}");
|
||||
FdoErr::NotSupported("RogPlatform: set_gpu_mux_mode not supported".to_owned())
|
||||
})
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_gpu_mux_mode(&mut self, mode: u8) -> Result<(), FdoErr> {
|
||||
if self.platform.has_gpu_mux_mode() {
|
||||
self.set_gfx_mode(mode.into()).map_err(|err| {
|
||||
warn!("RogPlatform: set_gpu_mux_mode {}", err);
|
||||
warn!("set_gpu_mux_mode {}", err);
|
||||
FdoErr::Failed(format!("RogPlatform: set_gpu_mux_mode: {err}"))
|
||||
})
|
||||
})?;
|
||||
self.config.lock().await.write();
|
||||
} else {
|
||||
Err(FdoErr::NotSupported(
|
||||
return Err(FdoErr::NotSupported(
|
||||
"RogPlatform: set_gpu_mux_mode not supported".to_owned(),
|
||||
))
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Toggle to next platform_profile. Names provided by `Profiles`.
|
||||
@@ -428,7 +397,7 @@ impl CtrlPlatform {
|
||||
self.platform
|
||||
.set_throttle_thermal_policy(policy.into())
|
||||
.map_err(|err| {
|
||||
warn!("RogPlatform: throttle_thermal_policy {}", err);
|
||||
warn!("throttle_thermal_policy {}", err);
|
||||
FdoErr::Failed(format!("RogPlatform: throttle_thermal_policy: {err}"))
|
||||
})?;
|
||||
Ok(self.throttle_thermal_policy_changed(&ctxt).await?)
|
||||
@@ -439,23 +408,24 @@ impl CtrlPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
fn throttle_thermal_policy(&self) -> Result<ThrottlePolicy, FdoErr> {
|
||||
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
|
||||
.map(|n| n.into())
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_throttle_thermal_policy(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> {
|
||||
// TODO: watch for external changes
|
||||
if self.platform.has_throttle_thermal_policy() {
|
||||
let change_epp = self.config.lock().await.throttle_policy_linked_epp;
|
||||
let epp = self.get_config_epp_for_throttle(policy).await;
|
||||
self.check_and_set_epp(epp, change_epp);
|
||||
self.config.lock().await.write();
|
||||
self.platform
|
||||
.set_throttle_thermal_policy(policy.into())
|
||||
.map_err(|err| {
|
||||
warn!("RogPlatform: throttle_thermal_policy {}", err);
|
||||
warn!("throttle_thermal_policy {}", err);
|
||||
FdoErr::Failed(format!("RogPlatform: throttle_thermal_policy: {err}"))
|
||||
})
|
||||
} else {
|
||||
@@ -465,140 +435,167 @@ impl CtrlPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn throttle_policy_linked_epp(&self) -> Result<bool, FdoErr> {
|
||||
Ok(self.config.lock().await.throttle_policy_linked_epp)
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_throttle_policy_linked_epp(&self, linked: bool) -> Result<(), zbus::Error> {
|
||||
self.config.lock().await.throttle_policy_linked_epp = linked;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn throttle_policy_on_battery(&self) -> Result<ThrottlePolicy, FdoErr> {
|
||||
Ok(self.config.lock().await.throttle_policy_on_battery)
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_throttle_policy_on_battery(
|
||||
&mut self,
|
||||
policy: ThrottlePolicy,
|
||||
) -> Result<(), FdoErr> {
|
||||
self.config.lock().await.throttle_policy_on_battery = policy;
|
||||
self.set_throttle_thermal_policy(policy).await?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn change_throttle_policy_on_battery(&self) -> Result<bool, FdoErr> {
|
||||
Ok(self.config.lock().await.change_throttle_policy_on_battery)
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn set_change_throttle_policy_on_battery(&mut self, change: bool) -> Result<(), FdoErr> {
|
||||
self.config.lock().await.change_throttle_policy_on_battery = change;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn throttle_policy_on_ac(&self) -> Result<ThrottlePolicy, FdoErr> {
|
||||
Ok(self.config.lock().await.throttle_policy_on_ac)
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_throttle_policy_on_ac(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> {
|
||||
self.config.lock().await.throttle_policy_on_ac = policy;
|
||||
self.set_throttle_thermal_policy(policy).await?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn change_throttle_policy_on_ac(&self) -> Result<bool, FdoErr> {
|
||||
Ok(self.config.lock().await.change_throttle_policy_on_ac)
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn set_change_throttle_policy_on_ac(&mut self, change: bool) -> Result<(), FdoErr> {
|
||||
self.config.lock().await.change_throttle_policy_on_ac = change;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The energy_performance_preference for the quiet throttle/platform
|
||||
/// profile
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn throttle_quiet_epp(&self) -> Result<CPUEPP, FdoErr> {
|
||||
Ok(self.config.lock().await.throttle_quiet_epp)
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_throttle_quiet_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
|
||||
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
|
||||
self.config.lock().await.throttle_quiet_epp = epp;
|
||||
self.check_and_set_epp(epp, change_pp);
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The energy_performance_preference for the balanced throttle/platform
|
||||
/// profile
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn throttle_balanced_epp(&self) -> Result<CPUEPP, FdoErr> {
|
||||
Ok(self.config.lock().await.throttle_balanced_epp)
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_throttle_balanced_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
|
||||
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
|
||||
self.config.lock().await.throttle_balanced_epp = epp;
|
||||
self.check_and_set_epp(epp, change_pp);
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The energy_performance_preference for the performance throttle/platform
|
||||
/// profile
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn throttle_performance_epp(&self) -> Result<CPUEPP, FdoErr> {
|
||||
Ok(self.config.lock().await.throttle_performance_epp)
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_throttle_performance_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
|
||||
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
|
||||
self.config.lock().await.throttle_performance_epp = epp;
|
||||
self.check_and_set_epp(epp, change_pp);
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// ***********************************************************************
|
||||
|
||||
#[dbus_interface(property)]
|
||||
fn post_animation_sound(&self) -> Result<bool, FdoErr> {
|
||||
platform_get_value!(self, post_animation_sound, "post_animation_sound")
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
async fn set_post_animation_sound(&mut self, on: bool) -> Result<(), FdoErr> {
|
||||
if self.platform.has_post_animation_sound() {
|
||||
self.platform.set_post_animation_sound(on).map_err(|err| {
|
||||
warn!("RogPlatform: set_post_animation_sound {}", err);
|
||||
FdoErr::Failed(format!("RogPlatform: set_post_animation_sound: {err}"))
|
||||
})
|
||||
} else {
|
||||
Err(FdoErr::NotSupported(
|
||||
"RogPlatform: set_post_animation_sound not supported".to_owned(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the `panel_od` value from platform. Updates the stored value in
|
||||
/// internal config also.
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
fn panel_od(&self) -> Result<bool, FdoErr> {
|
||||
platform_get_value!(self, panel_od, "panel_od")
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_panel_od(&mut self, overdrive: bool) -> Result<(), FdoErr> {
|
||||
platform_set_bool!(self, panel_od, "panel_od", overdrive)
|
||||
platform_set_value!(self, panel_od, "panel_od", overdrive)?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the `boot_sound` value from platform. Updates the stored value in
|
||||
/// internal config also.
|
||||
#[zbus(property)]
|
||||
fn boot_sound(&self) -> Result<bool, FdoErr> {
|
||||
platform_get_value!(self, boot_sound, "boot_sound")
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn set_boot_sound(&mut self, on: bool) -> Result<(), FdoErr> {
|
||||
platform_set_value!(self, boot_sound, "boot_sound", on)?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the `panel_od` value from platform. Updates the stored value in
|
||||
/// internal config also.
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
fn mini_led_mode(&self) -> Result<bool, FdoErr> {
|
||||
platform_get_value!(self, mini_led_mode, "mini_led_mode")
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_mini_led_mode(&mut self, on: bool) -> Result<(), FdoErr> {
|
||||
platform_set_bool!(self, mini_led_mode, "mini_led_mode", on)
|
||||
platform_set_value!(self, mini_led_mode, "mini_led_mode", on)?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
fn dgpu_disable(&self) -> Result<bool, FdoErr> {
|
||||
platform_get_value!(self, dgpu_disable, "dgpu_disable")
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
fn egpu_enable(&self) -> Result<bool, FdoErr> {
|
||||
platform_get_value!(self, egpu_enable, "egpu_enable")
|
||||
}
|
||||
@@ -607,87 +604,101 @@ impl CtrlPlatform {
|
||||
/// Set the Package Power Target total of CPU: PL1 on Intel, SPL on AMD.
|
||||
/// Shown on Intel+Nvidia or AMD+Nvidia based systems:
|
||||
/// * min=5, max=250
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn ppt_pl1_spl(&self) -> Result<u8, FdoErr> {
|
||||
platform_get_value_if_some!(self, ppt_pl1_spl, "ppt_pl1_spl", 5)
|
||||
platform_get_value!(self, ppt_pl1_spl, "ppt_pl1_spl")
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_ppt_pl1_spl(&mut self, value: u8) -> Result<(), FdoErr> {
|
||||
platform_set_with_min_max!(self, ppt_pl1_spl, "ppt_pl1_spl", value, 5, 250)
|
||||
platform_ppt_set_value!(self, ppt_pl1_spl, "ppt_pl1_spl", value)?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the Slow Package Power Tracking Limit of CPU: PL2 on Intel, SPPT,
|
||||
/// on AMD. Shown on Intel+Nvidia or AMD+Nvidia based systems:
|
||||
/// * min=5, max=250
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn ppt_pl2_sppt(&self) -> Result<u8, FdoErr> {
|
||||
platform_get_value_if_some!(self, ppt_pl2_sppt, "ppt_pl2_sppt", 5)
|
||||
platform_get_value!(self, ppt_pl2_sppt, "ppt_pl2_sppt")
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_ppt_pl2_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
|
||||
platform_set_with_min_max!(self, ppt_pl2_sppt, "ppt_pl2_sppt", value, 5, 250)
|
||||
platform_ppt_set_value!(self, ppt_pl2_sppt, "ppt_pl2_sppt", value)?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the Fast Package Power Tracking Limit of CPU. AMD+Nvidia only:
|
||||
/// * min=5, max=250
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn ppt_fppt(&self) -> Result<u8, FdoErr> {
|
||||
platform_get_value_if_some!(self, ppt_fppt, "ppt_fppt", 5)
|
||||
platform_get_value!(self, ppt_fppt, "ppt_fppt")
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_ppt_fppt(&mut self, value: u8) -> Result<(), FdoErr> {
|
||||
platform_set_with_min_max!(self, ppt_fppt, "ppt_fppt", value, 5, 250)
|
||||
platform_ppt_set_value!(self, ppt_fppt, "ppt_fppt", value)?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the APU SPPT limit. Shown on full AMD systems only:
|
||||
/// * min=5, max=130
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn ppt_apu_sppt(&self) -> Result<u8, FdoErr> {
|
||||
platform_get_value_if_some!(self, ppt_apu_sppt, "ppt_apu_sppt", 5)
|
||||
platform_get_value!(self, ppt_apu_sppt, "ppt_apu_sppt")
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_ppt_apu_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
|
||||
platform_set_with_min_max!(self, ppt_apu_sppt, "ppt_apu_sppt", value, 5, 130)
|
||||
platform_ppt_set_value!(self, ppt_apu_sppt, "ppt_apu_sppt", value)?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the platform SPPT limit. Shown on full AMD systems only:
|
||||
/// * min=5, max=130
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn ppt_platform_sppt(&self) -> Result<u8, FdoErr> {
|
||||
platform_get_value_if_some!(self, ppt_platform_sppt, "ppt_platform_sppt", 5)
|
||||
platform_get_value!(self, ppt_platform_sppt, "ppt_platform_sppt")
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_ppt_platform_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
|
||||
platform_set_with_min_max!(self, ppt_platform_sppt, "ppt_platform_sppt", value, 5, 130)
|
||||
platform_ppt_set_value!(self, ppt_platform_sppt, "ppt_platform_sppt", value)?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the dynamic boost limit of the Nvidia dGPU:
|
||||
/// * min=5, max=25
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn nv_dynamic_boost(&self) -> Result<u8, FdoErr> {
|
||||
platform_get_value_if_some!(self, nv_dynamic_boost, "nv_dynamic_boost", 5)
|
||||
platform_get_value!(self, nv_dynamic_boost, "nv_dynamic_boost")
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_nv_dynamic_boost(&mut self, value: u8) -> Result<(), FdoErr> {
|
||||
platform_set_with_min_max!(self, nv_dynamic_boost, "nv_dynamic_boost", value, 5, 25)
|
||||
platform_ppt_set_value!(self, nv_dynamic_boost, "nv_dynamic_boost", value)?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the target temperature limit of the Nvidia dGPU:
|
||||
/// * min=75, max=87
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn nv_temp_target(&self) -> Result<u8, FdoErr> {
|
||||
platform_get_value_if_some!(self, nv_temp_target, "nv_temp_target", 5)
|
||||
platform_get_value!(self, nv_temp_target, "nv_temp_target")
|
||||
}
|
||||
|
||||
#[dbus_interface(property)]
|
||||
#[zbus(property)]
|
||||
async fn set_nv_temp_target(&mut self, value: u8) -> Result<(), FdoErr> {
|
||||
platform_set_with_min_max!(self, nv_temp_target, "nv_temp_target", value, 5, 87)
|
||||
platform_ppt_set_value!(self, nv_temp_target, "nv_temp_target", value)?;
|
||||
self.config.lock().await.write();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,6 +711,7 @@ impl crate::ZbusRun for CtrlPlatform {
|
||||
impl ReloadAndNotify for CtrlPlatform {
|
||||
type Data = Config;
|
||||
|
||||
/// Called on config file changed externally
|
||||
async fn reload_and_notify(
|
||||
&mut self,
|
||||
signal_context: &SignalContext<'static>,
|
||||
@@ -710,37 +722,46 @@ impl ReloadAndNotify for CtrlPlatform {
|
||||
info!("asusd.ron updated externally, reloading and updating internal copy");
|
||||
|
||||
if self.power.has_charge_control_end_threshold() {
|
||||
self.power
|
||||
.set_charge_control_end_threshold(data.charge_control_end_threshold)?;
|
||||
let limit = data.charge_control_end_threshold;
|
||||
warn!("setting charge_control_end_threshold to {limit}");
|
||||
self.power.set_charge_control_end_threshold(limit)?;
|
||||
self.charge_control_end_threshold_changed(signal_context)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if self.platform.has_panel_od() && config.panel_od != data.panel_od {
|
||||
self.platform.set_panel_od(data.panel_od)?;
|
||||
self.panel_od_changed(signal_context).await?;
|
||||
}
|
||||
|
||||
if self.platform.has_mini_led_mode() && config.mini_led_mode != data.mini_led_mode {
|
||||
self.platform.set_mini_led_mode(data.mini_led_mode)?;
|
||||
self.mini_led_mode_changed(signal_context).await?;
|
||||
}
|
||||
|
||||
if self.platform.has_throttle_thermal_policy()
|
||||
&& config.throttle_policy_linked_epp != data.throttle_policy_linked_epp
|
||||
{
|
||||
// TODO: extra stuff
|
||||
}
|
||||
|
||||
macro_rules! reload_and_notify {
|
||||
($property:tt, $prop_name:literal) => {
|
||||
concat_idents::concat_idents!(has = has_, $property {
|
||||
if self.platform.has() && config.$property != data.$property {
|
||||
concat_idents::concat_idents!(set = set_, $property {
|
||||
self.platform
|
||||
.set(data.$property)?;});
|
||||
concat_idents::concat_idents!(changed = $property, _changed {
|
||||
self.changed(signal_context).await?;});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
reload_and_notify!(mini_led_mode, "mini_led_mode");
|
||||
reload_and_notify!(panel_od, "panel_od");
|
||||
reload_and_notify!(boot_sound, "boot_sound");
|
||||
// reload_and_notify!(throttle_thermal_policy, "throttle_thermal_policy");
|
||||
|
||||
macro_rules! ppt_reload_and_notify {
|
||||
($property:tt, $prop_name:literal) => {
|
||||
concat_idents::concat_idents!(has = has_, $property {
|
||||
if self.platform.has() && config.$property != data.$property {
|
||||
concat_idents::concat_idents!(set = set_, $property {
|
||||
self.platform
|
||||
.set_ppt_pl1_spl(data.$property.unwrap_or_default())?;});
|
||||
.set(data.$property.unwrap_or_default())?;});
|
||||
concat_idents::concat_idents!(changed = $property, _changed {
|
||||
self.ppt_pl1_spl_changed(signal_context).await?;});
|
||||
self.changed(signal_context).await?;});
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -762,22 +783,50 @@ impl ReloadAndNotify for CtrlPlatform {
|
||||
|
||||
impl crate::Reloadable for CtrlPlatform {
|
||||
async fn reload(&mut self) -> Result<(), RogError> {
|
||||
if self.platform.has_panel_od() {
|
||||
self.platform
|
||||
.set_panel_od(self.config.lock().await.panel_od)?;
|
||||
}
|
||||
|
||||
if self.platform.has_mini_led_mode() {
|
||||
self.platform
|
||||
.set_mini_led_mode(self.config.lock().await.mini_led_mode)?;
|
||||
}
|
||||
|
||||
info!("Begin Platform settings restore");
|
||||
if self.power.has_charge_control_end_threshold() {
|
||||
self.power.set_charge_control_end_threshold(
|
||||
self.config.lock().await.charge_control_end_threshold,
|
||||
)?;
|
||||
let limit = self.config.lock().await.charge_control_end_threshold;
|
||||
info!("reloading charge_control_end_threshold to {limit}");
|
||||
self.power.set_charge_control_end_threshold(limit)?;
|
||||
} else {
|
||||
warn!("No charge_control_end_threshold found")
|
||||
}
|
||||
|
||||
macro_rules! reload {
|
||||
($property:tt, $prop_name:literal) => {
|
||||
concat_idents::concat_idents!(has = has_, $property {
|
||||
if self.platform.has() {
|
||||
concat_idents::concat_idents!(set = set_, $property {
|
||||
self.platform
|
||||
.set(self.config.lock().await.$property)?;});
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
reload!(mini_led_mode, "mini_led_mode");
|
||||
reload!(panel_od, "panel_od");
|
||||
reload!(boot_sound, "boot_sound");
|
||||
|
||||
macro_rules! ppt_reload {
|
||||
($property:tt, $prop_name:literal) => {
|
||||
concat_idents::concat_idents!(has = has_, $property {
|
||||
if self.platform.has() {
|
||||
concat_idents::concat_idents!(set = set_, $property {
|
||||
self.platform
|
||||
.set(self.config.lock().await.$property.unwrap_or_default())?;});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
ppt_reload!(ppt_pl1_spl, "ppt_pl1_spl");
|
||||
ppt_reload!(ppt_pl2_sppt, "ppt_pl2_sppt");
|
||||
ppt_reload!(ppt_fppt, "ppt_fppt");
|
||||
ppt_reload!(ppt_apu_sppt, "ppt_apu_sppt");
|
||||
ppt_reload!(ppt_platform_sppt, "ppt_platform_sppt");
|
||||
ppt_reload!(nv_dynamic_boost, "nv_dynamic_boost");
|
||||
ppt_reload!(nv_temp_target, "nv_temp_target");
|
||||
|
||||
if let Ok(power_plugged) = self.power.get_online() {
|
||||
self.config.lock().await.last_power_plugged = power_plugged;
|
||||
if self.platform.has_throttle_thermal_policy() {
|
||||
@@ -793,13 +842,13 @@ impl crate::Reloadable for CtrlPlatform {
|
||||
}
|
||||
|
||||
impl CtrlPlatform {
|
||||
task_watch_item!(panel_od platform);
|
||||
task_watch_item!(panel_od "panel_od" platform);
|
||||
|
||||
task_watch_item!(mini_led_mode platform);
|
||||
task_watch_item!(mini_led_mode "mini_led_mode" platform);
|
||||
|
||||
task_watch_item!(charge_control_end_threshold power);
|
||||
task_watch_item!(charge_control_end_threshold "charge_control_end_threshold" power);
|
||||
|
||||
task_watch_item_notify!(post_animation_sound platform);
|
||||
task_watch_item_notify!(boot_sound platform);
|
||||
|
||||
task_watch_item_notify!(dgpu_disable platform);
|
||||
|
||||
@@ -847,12 +896,16 @@ impl CtrlTask for CtrlPlatform {
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
if sleeping && platform1.power.has_charge_control_end_threshold() {
|
||||
platform1.config.lock().await.charge_control_end_threshold = platform1
|
||||
.power
|
||||
.get_charge_control_end_threshold()
|
||||
.unwrap_or(100);
|
||||
} else if !sleeping && platform1.power.has_charge_control_end_threshold() {
|
||||
// This block is commented out due to some kind of issue reported. Maybe the
|
||||
// desktops used were storing a value whcih was then read here.
|
||||
// Don't store it on suspend, assume that the current config setting is desired
|
||||
// if sleeping && platform1.power.has_charge_control_end_threshold() {
|
||||
// platform1.config.lock().await.charge_control_end_threshold = platform1
|
||||
// .power
|
||||
// .get_charge_control_end_threshold()
|
||||
// .unwrap_or(100);
|
||||
// } else
|
||||
if !sleeping && platform1.power.has_charge_control_end_threshold() {
|
||||
platform1
|
||||
.power
|
||||
.set_charge_control_end_threshold(
|
||||
@@ -927,7 +980,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
// NOTE: Can't have this as a watch because on a write to it, it reverts back to
|
||||
// booted-with value as it does not actually change until reboot.
|
||||
self.watch_gpu_mux_mode(signal_ctxt.clone()).await?;
|
||||
self.watch_post_animation_sound(signal_ctxt.clone()).await?;
|
||||
self.watch_boot_sound(signal_ctxt.clone()).await?;
|
||||
|
||||
self.watch_ppt_pl1_spl(signal_ctxt.clone()).await?;
|
||||
self.watch_ppt_pl2_sppt(signal_ctxt.clone()).await?;
|
||||
|
||||
51
asusd/src/ctrl_slash/config.rs
Normal file
51
asusd/src/ctrl_slash/config.rs
Normal file
@@ -0,0 +1,51 @@
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use rog_slash::{DeviceState, SlashMode};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
const CONFIG_FILE: &str = "slash.ron";
|
||||
|
||||
/// Config for base system actions for the anime display
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct SlashConfig {
|
||||
pub slash_enabled: bool,
|
||||
pub slash_brightness: u8,
|
||||
pub slash_interval: u8,
|
||||
pub slash_mode: SlashMode,
|
||||
}
|
||||
|
||||
impl Default for SlashConfig {
|
||||
fn default() -> Self {
|
||||
SlashConfig {
|
||||
slash_enabled: true,
|
||||
slash_brightness: 255,
|
||||
slash_interval: 0,
|
||||
slash_mode: SlashMode::Bounce,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl StdConfig for SlashConfig {
|
||||
fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
fn file_name(&self) -> String {
|
||||
CONFIG_FILE.to_owned()
|
||||
}
|
||||
|
||||
fn config_dir() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(crate::CONFIG_PATH_BASE)
|
||||
}
|
||||
}
|
||||
|
||||
impl StdConfigLoad for SlashConfig {}
|
||||
|
||||
impl From<&SlashConfig> for DeviceState {
|
||||
fn from(config: &SlashConfig) -> Self {
|
||||
DeviceState {
|
||||
slash_enabled: config.slash_enabled,
|
||||
slash_brightness: config.slash_brightness,
|
||||
slash_interval: config.slash_interval,
|
||||
slash_mode: config.slash_mode,
|
||||
}
|
||||
}
|
||||
}
|
||||
100
asusd/src/ctrl_slash/mod.rs
Normal file
100
asusd/src/ctrl_slash/mod.rs
Normal file
@@ -0,0 +1,100 @@
|
||||
pub mod config;
|
||||
pub mod trait_impls;
|
||||
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use log::info;
|
||||
use rog_platform::hid_raw::HidRaw;
|
||||
use rog_platform::usb_raw::USBRaw;
|
||||
use rog_slash::error::SlashError;
|
||||
use rog_slash::usb::{get_maybe_slash_type, pkt_set_mode, pkt_set_options, pkts_for_init};
|
||||
use rog_slash::{SlashMode, SlashType};
|
||||
|
||||
use crate::ctrl_slash::config::SlashConfig;
|
||||
use crate::error::RogError;
|
||||
|
||||
enum Node {
|
||||
Usb(USBRaw),
|
||||
Hid(HidRaw),
|
||||
}
|
||||
|
||||
impl Node {
|
||||
pub fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> {
|
||||
// TODO: map and pass on errors
|
||||
match self {
|
||||
Node::Usb(u) => {
|
||||
u.write_bytes(message).ok();
|
||||
}
|
||||
Node::Hid(h) => {
|
||||
h.write_bytes(message).ok();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CtrlSlash {
|
||||
node: Node,
|
||||
config: SlashConfig,
|
||||
}
|
||||
|
||||
impl CtrlSlash {
|
||||
#[inline]
|
||||
pub fn new() -> Result<CtrlSlash, RogError> {
|
||||
let slash_type = get_maybe_slash_type()?;
|
||||
if matches!(slash_type, SlashType::Unsupported) {
|
||||
info!("No Slash capable laptop found");
|
||||
return Err(RogError::Slash(SlashError::NoDevice));
|
||||
}
|
||||
|
||||
let usb = USBRaw::new(rog_slash::usb::PROD_ID).ok();
|
||||
let hid = HidRaw::new(rog_slash::usb::PROD_ID_STR).ok();
|
||||
let node = if usb.is_some() {
|
||||
unsafe { Node::Usb(usb.unwrap_unchecked()) }
|
||||
} else if hid.is_some() {
|
||||
unsafe { Node::Hid(hid.unwrap_unchecked()) }
|
||||
} else {
|
||||
return Err(RogError::Slash(SlashError::NoDevice));
|
||||
};
|
||||
|
||||
let ctrl = CtrlSlash {
|
||||
node,
|
||||
config: SlashConfig::new().load(),
|
||||
};
|
||||
ctrl.do_initialization()?;
|
||||
|
||||
Ok(ctrl)
|
||||
}
|
||||
|
||||
fn do_initialization(&self) -> Result<(), RogError> {
|
||||
let init_packets = pkts_for_init();
|
||||
self.node.write_bytes(&init_packets[0])?;
|
||||
self.node.write_bytes(&init_packets[1])?;
|
||||
|
||||
// Apply config upon initialization
|
||||
let option_packets = pkt_set_options(
|
||||
self.config.slash_enabled,
|
||||
self.config.slash_brightness,
|
||||
self.config.slash_interval,
|
||||
);
|
||||
self.node.write_bytes(&option_packets)?;
|
||||
|
||||
let mode_packets = pkt_set_mode(self.config.slash_mode);
|
||||
self.node.write_bytes(&mode_packets[0])?;
|
||||
self.node.write_bytes(&mode_packets[1])?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_options(&self, enabled: bool, brightness: u8, interval: u8) -> Result<(), RogError> {
|
||||
let command_packets = pkt_set_options(enabled, brightness, interval);
|
||||
self.node.write_bytes(&command_packets)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_slash_mode(&self, slash_mode: SlashMode) -> Result<(), RogError> {
|
||||
let command_packets = pkt_set_mode(slash_mode);
|
||||
self.node.write_bytes(&command_packets[0])?;
|
||||
self.node.write_bytes(&command_packets[1])?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
165
asusd/src/ctrl_slash/trait_impls.rs
Normal file
165
asusd/src/ctrl_slash/trait_impls.rs
Normal file
@@ -0,0 +1,165 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use config_traits::StdConfig;
|
||||
use log::warn;
|
||||
use rog_slash::usb::{pkt_set_mode, pkt_set_options};
|
||||
use rog_slash::{DeviceState, SlashMode};
|
||||
use zbus::export::futures_util::lock::Mutex;
|
||||
use zbus::{interface, Connection, SignalContext};
|
||||
|
||||
use crate::ctrl_slash::CtrlSlash;
|
||||
use crate::error::RogError;
|
||||
|
||||
pub const SLASH_ZBUS_NAME: &str = "Slash";
|
||||
pub const SLASH_ZBUS_PATH: &str = "/org/asuslinux";
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CtrlSlashZbus(pub Arc<Mutex<CtrlSlash>>);
|
||||
|
||||
/// The struct with the main dbus methods requires this trait
|
||||
impl crate::ZbusRun for CtrlSlashZbus {
|
||||
async fn add_to_server(self, server: &mut Connection) {
|
||||
Self::add_to_server_helper(self, SLASH_ZBUS_PATH, server).await;
|
||||
}
|
||||
}
|
||||
|
||||
#[interface(name = "org.asuslinux.Slash")]
|
||||
impl CtrlSlashZbus {
|
||||
/// Get enabled or not
|
||||
#[zbus(property)]
|
||||
async fn enabled(&self) -> bool {
|
||||
let lock = self.0.lock().await;
|
||||
lock.config.slash_enabled
|
||||
}
|
||||
|
||||
/// Set enabled true or false
|
||||
#[zbus(property)]
|
||||
async fn set_enabled(&self, enabled: bool) {
|
||||
let mut lock = self.0.lock().await;
|
||||
let brightness = if enabled && lock.config.slash_brightness == 0 {
|
||||
0x88
|
||||
} else {
|
||||
lock.config.slash_brightness
|
||||
};
|
||||
lock.node
|
||||
.write_bytes(&pkt_set_options(
|
||||
enabled,
|
||||
brightness,
|
||||
lock.config.slash_interval,
|
||||
))
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_slash::set_options {}", err);
|
||||
})
|
||||
.ok();
|
||||
|
||||
lock.config.slash_enabled = enabled;
|
||||
lock.config.slash_brightness = brightness;
|
||||
lock.config.write();
|
||||
}
|
||||
|
||||
/// Get brightness level
|
||||
#[zbus(property)]
|
||||
async fn brightness(&self) -> u8 {
|
||||
let lock = self.0.lock().await;
|
||||
lock.config.slash_brightness
|
||||
}
|
||||
|
||||
/// Set brightness level
|
||||
#[zbus(property)]
|
||||
async fn set_brightness(&self, brightness: u8) {
|
||||
let mut lock = self.0.lock().await;
|
||||
let enabled = brightness > 0;
|
||||
lock.node
|
||||
.write_bytes(&pkt_set_options(
|
||||
enabled,
|
||||
brightness,
|
||||
lock.config.slash_interval,
|
||||
))
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_slash::set_options {}", err);
|
||||
})
|
||||
.ok();
|
||||
|
||||
lock.config.slash_enabled = enabled;
|
||||
lock.config.slash_brightness = brightness;
|
||||
lock.config.write();
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn interval(&self) -> u8 {
|
||||
let lock = self.0.lock().await;
|
||||
lock.config.slash_interval
|
||||
}
|
||||
|
||||
/// Set interval between slash animations (0-255)
|
||||
#[zbus(property)]
|
||||
async fn set_interval(&self, interval: u8) {
|
||||
let mut lock = self.0.lock().await;
|
||||
lock.node
|
||||
.write_bytes(&pkt_set_options(
|
||||
lock.config.slash_enabled,
|
||||
lock.config.slash_brightness,
|
||||
interval,
|
||||
))
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_slash::set_options {}", err);
|
||||
})
|
||||
.ok();
|
||||
|
||||
lock.config.slash_interval = interval;
|
||||
lock.config.write();
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn slash_mode(&self) -> u8 {
|
||||
let lock = self.0.lock().await;
|
||||
lock.config.slash_interval
|
||||
}
|
||||
|
||||
/// Set interval between slash animations (0-255)
|
||||
#[zbus(property)]
|
||||
async fn set_slash_mode(&self, slash_mode: SlashMode) {
|
||||
let mut lock = self.0.lock().await;
|
||||
|
||||
let command_packets = pkt_set_mode(slash_mode);
|
||||
|
||||
lock.node
|
||||
.write_bytes(&command_packets[0])
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_slash::set_options {}", err);
|
||||
})
|
||||
.ok();
|
||||
lock.node
|
||||
.write_bytes(&command_packets[1])
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_slash::set_options {}", err);
|
||||
})
|
||||
.ok();
|
||||
|
||||
lock.config.slash_mode = slash_mode;
|
||||
lock.config.write();
|
||||
}
|
||||
|
||||
/// Get the device state as stored by asusd
|
||||
// #[zbus(property)]
|
||||
async fn device_state(&self) -> DeviceState {
|
||||
let lock = self.0.lock().await;
|
||||
DeviceState::from(&lock.config)
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::CtrlTask for CtrlSlashZbus {
|
||||
fn zbus_path() -> &'static str {
|
||||
SLASH_ZBUS_PATH
|
||||
}
|
||||
|
||||
async fn create_tasks(&self, _: SignalContext<'static>) -> Result<(), RogError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::Reloadable for CtrlSlashZbus {
|
||||
async fn reload(&mut self) -> Result<(), RogError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,30 @@
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
use std::io::Write;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use ::zbus::export::futures_util::lock::Mutex;
|
||||
use ::zbus::Connection;
|
||||
use asusd::config::Config;
|
||||
use asusd::ctrl_anime::config::AnimeConfig;
|
||||
use asusd::ctrl_anime::trait_impls::CtrlAnimeZbus;
|
||||
use asusd::ctrl_anime::CtrlAnime;
|
||||
use asusd::ctrl_aura::controller::CtrlKbdLed;
|
||||
use asusd::ctrl_aura::trait_impls::CtrlAuraZbus;
|
||||
use asusd::ctrl_aura::manager::AuraManager;
|
||||
use asusd::ctrl_fancurves::CtrlFanCurveZbus;
|
||||
use asusd::ctrl_platform::CtrlPlatform;
|
||||
use asusd::{print_board_info, CtrlTask, Reloadable, ZbusRun, DBUS_NAME};
|
||||
use config_traits::{StdConfig, StdConfigLoad2, StdConfigLoad3};
|
||||
use log::{error, info, warn};
|
||||
use rog_aura::aura_detection::LaptopLedData;
|
||||
use tokio::time::sleep;
|
||||
use zbus::SignalContext;
|
||||
use asusd::ctrl_slash::trait_impls::CtrlSlashZbus;
|
||||
use asusd::ctrl_slash::CtrlSlash;
|
||||
use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME};
|
||||
use config_traits::{StdConfig, StdConfigLoad1};
|
||||
use log::{error, info};
|
||||
use zbus::fdo::ObjectManager;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// console_subscriber::init();
|
||||
let mut logger = env_logger::Builder::new();
|
||||
logger
|
||||
.parse_default_env()
|
||||
.target(env_logger::Target::Stdout)
|
||||
.format(|buf, record| writeln!(buf, "{}: {}", record.level(), record.args()))
|
||||
.format_timestamp(None)
|
||||
.init();
|
||||
|
||||
let is_service = match env::var_os("IS_SERVICE") {
|
||||
@@ -46,6 +43,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
info!(" daemon v{}", asusd::VERSION);
|
||||
info!(" rog-anime v{}", rog_anime::VERSION);
|
||||
info!(" rog-slash v{}", rog_slash::VERSION);
|
||||
info!(" rog-aura v{}", rog_aura::VERSION);
|
||||
info!(" rog-profiles v{}", rog_profiles::VERSION);
|
||||
info!("rog-platform v{}", rog_platform::VERSION);
|
||||
@@ -62,6 +60,11 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// Start zbus server
|
||||
let mut connection = Connection::system().await?;
|
||||
connection
|
||||
.object_server()
|
||||
.at("/", ObjectManager)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let config = Config::new().load();
|
||||
let cfg_path = config.file_path();
|
||||
@@ -69,6 +72,16 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// supported.add_to_server(&mut connection).await;
|
||||
|
||||
match CtrlFanCurveZbus::new() {
|
||||
Ok(ctrl) => {
|
||||
let sig_ctx = CtrlFanCurveZbus::signal_context(&connection)?;
|
||||
start_tasks(ctrl, &mut connection, sig_ctx).await?;
|
||||
}
|
||||
Err(err) => {
|
||||
error!("FanCurves: {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
match CtrlPlatform::new(
|
||||
config.clone(),
|
||||
&cfg_path,
|
||||
@@ -83,17 +96,7 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
}
|
||||
|
||||
match CtrlFanCurveZbus::new() {
|
||||
Ok(ctrl) => {
|
||||
let sig_ctx = CtrlFanCurveZbus::signal_context(&connection)?;
|
||||
start_tasks(ctrl, &mut connection, sig_ctx).await?;
|
||||
}
|
||||
Err(err) => {
|
||||
error!("FanCurves: {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
match CtrlAnime::new(AnimeConfig::new().load()) {
|
||||
match CtrlAnime::new() {
|
||||
Ok(ctrl) => {
|
||||
let zbus = CtrlAnimeZbus(Arc::new(Mutex::new(ctrl)));
|
||||
let sig_ctx = CtrlAnimeZbus::signal_context(&connection)?;
|
||||
@@ -104,44 +107,28 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
}
|
||||
|
||||
let laptop = LaptopLedData::get_data();
|
||||
// CtrlKbdLed deviates from the config pattern above due to requiring a keyboard
|
||||
// detection first
|
||||
match CtrlKbdLed::new(laptop) {
|
||||
match CtrlSlash::new() {
|
||||
Ok(ctrl) => {
|
||||
let zbus = CtrlAuraZbus(Arc::new(Mutex::new(ctrl)));
|
||||
let sig_ctx = CtrlAuraZbus::signal_context(&connection)?;
|
||||
let zbus = CtrlSlashZbus(Arc::new(Mutex::new(ctrl)));
|
||||
// Currently, the Slash has no need for a loop watching power events, however,
|
||||
// it could be cool to have the slash do some power-on/off animation
|
||||
// (It has a built-in power on animation which plays when u plug in the power
|
||||
// supply)
|
||||
let sig_ctx = CtrlSlashZbus::signal_context(&connection)?;
|
||||
start_tasks(zbus, &mut connection, sig_ctx).await?;
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Keyboard control: {}", err);
|
||||
info!("AniMe control: {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
let _ = AuraManager::new(connection.clone()).await?;
|
||||
|
||||
// Request dbus name after finishing initalizing all functions
|
||||
connection.request_name(DBUS_NAME).await?;
|
||||
|
||||
loop {
|
||||
// This is just a blocker to idle and ensure the reator reacts
|
||||
sleep(Duration::from_millis(1000)).await;
|
||||
connection.executor().tick().await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn start_tasks<T>(
|
||||
mut zbus: T,
|
||||
connection: &mut Connection,
|
||||
signal_ctx: SignalContext<'static>,
|
||||
) -> Result<(), Box<dyn Error>>
|
||||
where
|
||||
T: ZbusRun + Reloadable + CtrlTask + Clone,
|
||||
{
|
||||
let task = zbus.clone();
|
||||
|
||||
zbus.reload()
|
||||
.await
|
||||
.unwrap_or_else(|err| warn!("Controller error: {}", err));
|
||||
zbus.add_to_server(connection).await;
|
||||
|
||||
task.create_tasks(signal_ctx).await.ok();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use config_traits::ron;
|
||||
use rog_anime::error::AnimeError;
|
||||
use rog_platform::error::PlatformError;
|
||||
use rog_profiles::error::ProfileError;
|
||||
use rog_slash::error::SlashError;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum RogError {
|
||||
@@ -31,6 +32,7 @@ pub enum RogError {
|
||||
NoAuraKeyboard,
|
||||
NoAuraNode,
|
||||
Anime(AnimeError),
|
||||
Slash(SlashError),
|
||||
Platform(PlatformError),
|
||||
SystemdUnitAction(String),
|
||||
SystemdUnitWaitTimeout(String),
|
||||
@@ -72,6 +74,7 @@ impl fmt::Display for RogError {
|
||||
RogError::NoAuraKeyboard => write!(f, "No supported Aura keyboard"),
|
||||
RogError::NoAuraNode => write!(f, "No Aura keyboard node found"),
|
||||
RogError::Anime(deets) => write!(f, "AniMe Matrix error: {}", deets),
|
||||
RogError::Slash(deets) => write!(f, "Slash error: {}", deets),
|
||||
RogError::Platform(deets) => write!(f, "Asus Platform error: {}", deets),
|
||||
RogError::SystemdUnitAction(action) => {
|
||||
write!(f, "systemd unit action {} failed", action)
|
||||
@@ -103,6 +106,12 @@ impl From<AnimeError> for RogError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SlashError> for RogError {
|
||||
fn from(err: SlashError) -> Self {
|
||||
RogError::Slash(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PlatformError> for RogError {
|
||||
fn from(err: PlatformError) -> Self {
|
||||
RogError::Platform(err)
|
||||
|
||||
@@ -9,6 +9,8 @@ pub mod ctrl_aura;
|
||||
pub mod ctrl_fancurves;
|
||||
/// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode
|
||||
pub mod ctrl_platform;
|
||||
/// Control of Slash led bar
|
||||
pub mod ctrl_slash;
|
||||
|
||||
pub mod error;
|
||||
|
||||
@@ -50,11 +52,11 @@ pub static DBUS_IFACE: &str = "org.asuslinux.Daemon";
|
||||
/// task_watch_item!(panel_od platform);
|
||||
/// task_watch_item!(gpu_mux_mode platform);
|
||||
/// }
|
||||
/// ```
|
||||
/// ```\
|
||||
/// // TODO: this is kind of useless if it can't trigger some action
|
||||
#[macro_export]
|
||||
macro_rules! task_watch_item {
|
||||
($name:ident $self_inner:ident) => {
|
||||
($name:ident $name_str:literal $self_inner:ident) => {
|
||||
concat_idents::concat_idents!(fn_name = watch_, $name {
|
||||
async fn fn_name(
|
||||
&self,
|
||||
@@ -70,12 +72,15 @@ macro_rules! task_watch_item {
|
||||
let mut buffer = [0; 32];
|
||||
watch.into_event_stream(&mut buffer).unwrap().for_each(|_| async {
|
||||
if let Ok(value) = ctrl.$name() { // get new value from zbus method
|
||||
concat_idents::concat_idents!(notif_fn = $name, _changed {
|
||||
ctrl.notif_fn(&signal_ctxt).await.ok();
|
||||
});
|
||||
let mut lock = ctrl.config.lock().await;
|
||||
lock.$name = value;
|
||||
lock.write();
|
||||
if ctrl.config.lock().await.$name != value {
|
||||
log::debug!("{} was changed to {} externally", $name_str, value);
|
||||
concat_idents::concat_idents!(notif_fn = $name, _changed {
|
||||
ctrl.notif_fn(&signal_ctxt).await.ok();
|
||||
});
|
||||
let mut lock = ctrl.config.lock().await;
|
||||
lock.$name = value;
|
||||
lock.write();
|
||||
}
|
||||
}
|
||||
}).await;
|
||||
});
|
||||
@@ -130,7 +135,7 @@ pub fn print_board_info() {
|
||||
}
|
||||
|
||||
pub trait Reloadable {
|
||||
fn reload(&mut self) -> impl std::future::Future<Output = Result<(), RogError>> + Send;
|
||||
fn reload(&mut self) -> impl Future<Output = Result<(), RogError>> + Send;
|
||||
}
|
||||
|
||||
pub trait ReloadAndNotify {
|
||||
@@ -140,18 +145,17 @@ pub trait ReloadAndNotify {
|
||||
&mut self,
|
||||
signal_context: &SignalContext<'static>,
|
||||
data: Self::Data,
|
||||
) -> impl std::future::Future<Output = Result<(), RogError>> + Send;
|
||||
) -> impl Future<Output = Result<(), RogError>> + Send;
|
||||
}
|
||||
|
||||
pub trait ZbusRun {
|
||||
fn add_to_server(self, server: &mut Connection)
|
||||
-> impl std::future::Future<Output = ()> + Send;
|
||||
fn add_to_server(self, server: &mut Connection) -> impl Future<Output = ()> + Send;
|
||||
|
||||
fn add_to_server_helper(
|
||||
iface: impl zbus::Interface,
|
||||
path: &str,
|
||||
server: &mut Connection,
|
||||
) -> impl std::future::Future<Output = ()> + Send {
|
||||
) -> impl Future<Output = ()> + Send {
|
||||
async move {
|
||||
server
|
||||
.object_server()
|
||||
@@ -180,7 +184,7 @@ pub trait CtrlTask {
|
||||
fn create_tasks(
|
||||
&self,
|
||||
signal: SignalContext<'static>,
|
||||
) -> impl std::future::Future<Output = Result<(), RogError>> + Send;
|
||||
) -> impl Future<Output = Result<(), RogError>> + Send;
|
||||
|
||||
// /// Create a timed repeating task
|
||||
// async fn repeating_task(&self, millis: u64, mut task: impl FnMut() + Send +
|
||||
@@ -198,27 +202,18 @@ pub trait CtrlTask {
|
||||
///
|
||||
/// The closures can potentially block, so execution time should be the
|
||||
/// minimal possible such as save a variable.
|
||||
fn create_sys_event_tasks<
|
||||
Fut1,
|
||||
Fut2,
|
||||
Fut3,
|
||||
Fut4,
|
||||
F1: Send + 'static,
|
||||
F2: Send + 'static,
|
||||
F3: Send + 'static,
|
||||
F4: Send + 'static,
|
||||
>(
|
||||
fn create_sys_event_tasks<Fut1, Fut2, Fut3, Fut4, F1, F2, F3, F4>(
|
||||
&self,
|
||||
mut on_prepare_for_sleep: F1,
|
||||
mut on_prepare_for_shutdown: F2,
|
||||
mut on_lid_change: F3,
|
||||
mut on_external_power_change: F4,
|
||||
) -> impl std::future::Future<Output = ()> + Send
|
||||
) -> impl Future<Output = ()> + Send
|
||||
where
|
||||
F1: FnMut(bool) -> Fut1,
|
||||
F2: FnMut(bool) -> Fut2,
|
||||
F3: FnMut(bool) -> Fut3,
|
||||
F4: FnMut(bool) -> Fut4,
|
||||
F1: FnMut(bool) -> Fut1 + Send + 'static,
|
||||
F2: FnMut(bool) -> Fut2 + Send + 'static,
|
||||
F3: FnMut(bool) -> Fut3 + Send + 'static,
|
||||
F4: FnMut(bool) -> Fut4 + Send + 'static,
|
||||
Fut1: Future<Output = ()> + Send,
|
||||
Fut2: Future<Output = ()> + Send,
|
||||
Fut3: Future<Output = ()> + Send,
|
||||
@@ -298,3 +293,22 @@ pub trait GetSupported {
|
||||
|
||||
fn get_supported() -> Self::A;
|
||||
}
|
||||
|
||||
pub async fn start_tasks<T>(
|
||||
mut zbus: T,
|
||||
connection: &mut Connection,
|
||||
signal_ctx: SignalContext<'static>,
|
||||
) -> Result<(), RogError>
|
||||
where
|
||||
T: ZbusRun + Reloadable + CtrlTask + Clone,
|
||||
{
|
||||
let zbus_clone = zbus.clone();
|
||||
|
||||
zbus.reload()
|
||||
.await
|
||||
.unwrap_or_else(|err| warn!("Controller error: {}", err));
|
||||
zbus.add_to_server(connection).await;
|
||||
|
||||
zbus_clone.create_tasks(signal_ctx).await.ok();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<!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">
|
||||
<!--
|
||||
Writes a data stream of length. Will force system thread to exit until
|
||||
it is restarted
|
||||
-->
|
||||
<method name="Write">
|
||||
<arg name="input" type="(ays)" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
The main loop is the base system set action if the user isn't running
|
||||
the user daemon
|
||||
-->
|
||||
<method name="RunMainLoop">
|
||||
<arg name="start" type="b" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Get the device state as stored by asusd
|
||||
-->
|
||||
<method name="DeviceState">
|
||||
<arg type="(bub(ssss)bbbu)" direction="out"/>
|
||||
</method>
|
||||
<!--
|
||||
Set base brightness level
|
||||
-->
|
||||
<!--
|
||||
Set base brightness level
|
||||
-->
|
||||
<property name="Brightness" type="u" access="readwrite"/>
|
||||
<!--
|
||||
Set which builtin animation is used for each stage
|
||||
-->
|
||||
<property name="BuiltinAnimations" type="(ssss)" access="readwrite"/>
|
||||
<!--
|
||||
Enable the builtin animations or not. This is quivalent to "Powersave
|
||||
animations" in Armory crate
|
||||
-->
|
||||
<property name="BuiltinsEnabled" type="b" access="readwrite"/>
|
||||
<!--
|
||||
Set whether the AniMe is enabled at all
|
||||
-->
|
||||
<property name="EnableDisplay" type="b" access="readwrite"/>
|
||||
<!--
|
||||
Set if to turn the AniMe Matrix off when the lid is closed
|
||||
-->
|
||||
<property name="OffWhenLidClosed" type="b" access="readwrite"/>
|
||||
<!--
|
||||
Set if to turn the AniMe Matrix off when the laptop is suspended
|
||||
-->
|
||||
<property name="OffWhenSuspended" type="b" access="readwrite"/>
|
||||
<!--
|
||||
Set if to turn the AniMe Matrix off when external power is unplugged
|
||||
-->
|
||||
<property name="OffWhenUnplugged" type="b" access="readwrite"/>
|
||||
</interface>
|
||||
</node>
|
||||
@@ -1,67 +0,0 @@
|
||||
<!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">
|
||||
<!--
|
||||
Get the data set for every mode available
|
||||
-->
|
||||
<method name="AllModeData">
|
||||
<arg type="a{u(uu(yyy)(yyy)ss)}" direction="out"/>
|
||||
</method>
|
||||
<!--
|
||||
On machine that have some form of either per-key keyboard or per-zone
|
||||
this can be used to write custom effects over dbus. The input is a
|
||||
nested `Vec<Vec<8>>` where `Vec<u8>` is a raw USB packet
|
||||
-->
|
||||
<method name="DirectAddressingRaw">
|
||||
<arg name="data" type="aay" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Return the current LED brightness
|
||||
-->
|
||||
<!--
|
||||
Set the keyboard brightness level (0-3)
|
||||
-->
|
||||
<property name="Brightness" type="u" access="readwrite"/>
|
||||
<!--
|
||||
Return the device type for this Aura keyboard
|
||||
-->
|
||||
<property name="DeviceType" type="s" access="read"/>
|
||||
<!--
|
||||
The current mode data
|
||||
-->
|
||||
<!--
|
||||
Set an Aura effect if the effect mode or zone is supported.
|
||||
|
||||
On success the aura config file is read to refresh cached values, then
|
||||
the effect is stored and config written to disk.
|
||||
-->
|
||||
<property name="LedMode" type="u" access="readwrite"/>
|
||||
<!--
|
||||
The current mode data
|
||||
-->
|
||||
<!--
|
||||
Set an Aura effect if the effect mode or zone is supported.
|
||||
|
||||
On success the aura config file is read to refresh cached values, then
|
||||
the effect is stored and config written to disk.
|
||||
-->
|
||||
<property name="LedModeData" type="(uu(yyy)(yyy)ss)" access="readwrite"/>
|
||||
<!--
|
||||
Set a variety of states, input is array of enum.
|
||||
`enabled` sets if the sent array should be disabled or enabled
|
||||
|
||||
For Modern ROG devices the "enabled" flag is ignored.
|
||||
-->
|
||||
<property name="LedPower" type="(ayay((ubbbb)(ubbbb)(ubbbb)(ubbbb)(ubbbb)))" access="readwrite"/>
|
||||
<!--
|
||||
The total available modes
|
||||
-->
|
||||
<property name="SupportedBasicModes" type="au" access="read"/>
|
||||
<property name="SupportedBasicZones" type="au" access="read"/>
|
||||
<!--
|
||||
Total levels of brightness available
|
||||
-->
|
||||
<property name="SupportedBrightness" type="au" access="read"/>
|
||||
<property name="SupportedPowerZones" type="au" access="read"/>
|
||||
</interface>
|
||||
</node>
|
||||
@@ -1,56 +0,0 @@
|
||||
<!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">
|
||||
<!--
|
||||
Set all fan curves for a profile to enabled status. Will also activate a
|
||||
fan curve if in the same profile mode
|
||||
-->
|
||||
<method name="SetFanCurvesEnabled">
|
||||
<arg name="profile" type="s" direction="in"/>
|
||||
<arg name="enabled" type="b" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Set a single fan curve for a profile to enabled status. Will also
|
||||
activate a fan curve if in the same profile mode
|
||||
-->
|
||||
<method name="SetProfileFanCurveEnabled">
|
||||
<arg name="profile" type="s" direction="in"/>
|
||||
<arg name="fan" type="s" direction="in"/>
|
||||
<arg name="enabled" type="b" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Get the fan-curve data for the currently active ThrottlePolicy
|
||||
-->
|
||||
<method name="FanCurveData">
|
||||
<arg name="profile" type="s" direction="in"/>
|
||||
<arg type="a(s(yyyyyyyy)(yyyyyyyy)b)" direction="out"/>
|
||||
</method>
|
||||
<!--
|
||||
Set the fan curve for the specified profile.
|
||||
Will also activate the fan curve if the user is in the same mode.
|
||||
-->
|
||||
<method name="SetFanCurve">
|
||||
<arg name="profile" type="s" direction="in"/>
|
||||
<arg name="curve" type="(s(yyyyyyyy)(yyyyyyyy)b)" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Reset the stored (self) and device curve to the defaults of the
|
||||
platform.
|
||||
|
||||
Each platform_profile has a different default and the defualt can be
|
||||
read only for the currently active profile.
|
||||
-->
|
||||
<method name="SetActiveCurveToDefaults">
|
||||
</method>
|
||||
<!--
|
||||
Reset the stored (self) and device curve to the defaults of the
|
||||
platform.
|
||||
|
||||
Each platform_profile has a different default and the defualt can be
|
||||
read only for the currently active profile.
|
||||
-->
|
||||
<method name="ResetProfileCurves">
|
||||
<arg name="profile" type="s" direction="in"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
||||
@@ -1,46 +0,0 @@
|
||||
<!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">
|
||||
<!--
|
||||
Returns a list of property names that this system supports
|
||||
-->
|
||||
<method name="SupportedProperties">
|
||||
<arg type="as" direction="out"/>
|
||||
</method>
|
||||
<method name="SupportedInterfaces">
|
||||
<arg type="as" direction="out"/>
|
||||
</method>
|
||||
<!--
|
||||
Toggle to next platform_profile. Names provided by `Profiles`.
|
||||
If fan-curves are supported will also activate a fan curve for profile.
|
||||
-->
|
||||
<method name="NextThrottleThermalPolicy">
|
||||
</method>
|
||||
<property name="ChargeControlEndThreshold" type="y" access="readwrite"/>
|
||||
<property name="DgpuDisable" type="b" access="read"/>
|
||||
<property name="EgpuEnable" type="b" access="read"/>
|
||||
<property name="GpuMuxMode" type="y" access="readwrite"/>
|
||||
<!--
|
||||
Get the `panel_od` value from platform. Updates the stored value in
|
||||
internal config also.
|
||||
-->
|
||||
<property name="MiniLedMode" type="b" access="readwrite"/>
|
||||
<property name="NvDynamicBoost" type="y" access="readwrite"/>
|
||||
<property name="NvTempTarget" type="y" access="readwrite"/>
|
||||
<!--
|
||||
Get the `panel_od` value from platform. Updates the stored value in
|
||||
internal config also.
|
||||
-->
|
||||
<property name="PanelOd" type="b" access="readwrite"/>
|
||||
<property name="PostAnimationSound" type="b" access="readwrite"/>
|
||||
<property name="PptApuSppt" type="y" access="readwrite"/>
|
||||
<property name="PptFppt" type="y" access="readwrite"/>
|
||||
<!--
|
||||
************************************************************************
|
||||
-->
|
||||
<property name="PptPl1Spl" type="y" access="readwrite"/>
|
||||
<property name="PptPl2Sppt" type="y" access="readwrite"/>
|
||||
<property name="PptPlatformSppt" type="y" access="readwrite"/>
|
||||
<property name="ThrottleThermalPolicy" type="s" access="readwrite"/>
|
||||
</interface>
|
||||
</node>
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
Generated by typeshare 1.7.0
|
||||
*/
|
||||
|
||||
export enum AnimBooting {
|
||||
GlitchConstruction = "GlitchConstruction",
|
||||
StaticEmergence = "StaticEmergence",
|
||||
}
|
||||
|
||||
export enum AnimAwake {
|
||||
BinaryBannerScroll = "BinaryBannerScroll",
|
||||
RogLogoGlitch = "RogLogoGlitch",
|
||||
}
|
||||
|
||||
export enum AnimSleeping {
|
||||
BannerSwipe = "BannerSwipe",
|
||||
Starfield = "Starfield",
|
||||
}
|
||||
|
||||
export enum AnimShutdown {
|
||||
GlitchOut = "GlitchOut",
|
||||
SeeYa = "SeeYa",
|
||||
}
|
||||
|
||||
export interface Animations {
|
||||
boot: AnimBooting;
|
||||
awake: AnimAwake;
|
||||
sleep: AnimSleeping;
|
||||
shutdown: AnimShutdown;
|
||||
}
|
||||
|
||||
/** Base LED brightness of the display */
|
||||
export enum Brightness {
|
||||
Off = "Off",
|
||||
Low = "Low",
|
||||
Med = "Med",
|
||||
High = "High",
|
||||
}
|
||||
|
||||
export interface DeviceState {
|
||||
display_enabled: boolean;
|
||||
display_brightness: Brightness;
|
||||
builtin_anims_enabled: boolean;
|
||||
builtin_anims: Animations;
|
||||
off_when_unplugged: boolean;
|
||||
off_when_suspended: boolean;
|
||||
off_when_lid_closed: boolean;
|
||||
brightness_on_battery: Brightness;
|
||||
}
|
||||
|
||||
export enum AnimeType {
|
||||
GA401 = "GA401",
|
||||
GA402 = "GA402",
|
||||
GU604 = "GU604",
|
||||
Unknown = "Unknown",
|
||||
}
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
/*
|
||||
Generated by typeshare 1.7.0
|
||||
*/
|
||||
|
||||
/** Represents the per-key raw USB packets */
|
||||
export type UsbPackets = number[][];
|
||||
|
||||
/**
|
||||
* A `UsbPackets` contains all data to change the full set of keyboard
|
||||
* key colours individually.
|
||||
*
|
||||
* Each row of the internal array is a full HID packet that can be sent
|
||||
* to the keyboard EC. One row controls one group of keys, these keys are not
|
||||
* necessarily all on the same row of the keyboard, with some splitting between
|
||||
* two rows.
|
||||
*/
|
||||
export interface LedUsbPackets {
|
||||
/** The packet data used to send data to the USB keyboard */
|
||||
usb_packets: UsbPackets;
|
||||
/**
|
||||
* Wether or not this packet collection is zoned. The determines which
|
||||
* starting bytes are used and what the indexing is for lightbar RGB
|
||||
* colours
|
||||
*/
|
||||
zoned: boolean;
|
||||
}
|
||||
|
||||
export interface Colour {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
}
|
||||
|
||||
/** Enum of modes that convert to the actual number required by a USB HID packet */
|
||||
export enum AuraModeNum {
|
||||
Static = "Static",
|
||||
Breathe = "Breathe",
|
||||
Strobe = "Strobe",
|
||||
Rainbow = "Rainbow",
|
||||
Star = "Star",
|
||||
Rain = "Rain",
|
||||
Highlight = "Highlight",
|
||||
Laser = "Laser",
|
||||
Ripple = "Ripple",
|
||||
Pulse = "Pulse",
|
||||
Comet = "Comet",
|
||||
Flash = "Flash",
|
||||
}
|
||||
|
||||
/** Base effects have no zoning, while multizone is 1-4 */
|
||||
export enum AuraZone {
|
||||
/** Used if keyboard has no zones, or if setting all */
|
||||
None = "None",
|
||||
/** Leftmost zone */
|
||||
Key1 = "Key1",
|
||||
/** Zone after leftmost */
|
||||
Key2 = "Key2",
|
||||
/** Zone second from right */
|
||||
Key3 = "Key3",
|
||||
/** Rightmost zone */
|
||||
Key4 = "Key4",
|
||||
/** Logo on the lid (or elsewhere?) */
|
||||
Logo = "Logo",
|
||||
/** The left part of a lightbar (typically on the front of laptop) */
|
||||
BarLeft = "BarLeft",
|
||||
/** The right part of a lightbar */
|
||||
BarRight = "BarRight",
|
||||
}
|
||||
|
||||
export enum Speed {
|
||||
Low = "Low",
|
||||
Med = "Med",
|
||||
High = "High",
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for Rainbow mode.
|
||||
*
|
||||
* Enum corresponds to the required integer value
|
||||
*/
|
||||
export enum Direction {
|
||||
Right = "Right",
|
||||
Left = "Left",
|
||||
Up = "Up",
|
||||
Down = "Down",
|
||||
}
|
||||
|
||||
/**
|
||||
* Default factory modes structure. This easily converts to an USB HID packet
|
||||
* with:
|
||||
* ```rust
|
||||
* // let bytes: [u8; LED_MSG_LEN] = mode.into();
|
||||
* ```
|
||||
*/
|
||||
export interface AuraEffect {
|
||||
/** The effect type */
|
||||
mode: AuraModeNum;
|
||||
/** `AuraZone::None` for no zone or zoneless keyboards */
|
||||
zone: AuraZone;
|
||||
/** Primary colour for all modes */
|
||||
colour1: Colour;
|
||||
/** Secondary colour in some modes like Breathing or Stars */
|
||||
colour2: Colour;
|
||||
/** One of three speeds for modes that support speed (most that animate) */
|
||||
speed: Speed;
|
||||
/** Up, down, left, right. Only Rainbow mode seems to use this */
|
||||
direction: Direction;
|
||||
}
|
||||
|
||||
/** The powerr zones this laptop supports */
|
||||
export enum PowerZones {
|
||||
/** The logo on some laptop lids */
|
||||
Logo = "Logo",
|
||||
/** The full keyboard (not zones) */
|
||||
Keyboard = "Keyboard",
|
||||
/** The lightbar, typically on the front of the laptop */
|
||||
Lightbar = "Lightbar",
|
||||
/** The leds that may be placed around the edge of the laptop lid */
|
||||
Lid = "Lid",
|
||||
/** The led strip on the rear of some laptops */
|
||||
RearGlow = "RearGlow",
|
||||
}
|
||||
|
||||
export interface KbAuraPowerState {
|
||||
zone: PowerZones;
|
||||
boot: boolean;
|
||||
awake: boolean;
|
||||
sleep: boolean;
|
||||
shutdown: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Track and control the Aura keyboard power state
|
||||
*
|
||||
* # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models
|
||||
*
|
||||
* | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label |
|
||||
* |--------|---------|---------|---------|----------|
|
||||
* |00000001| 00000000| 00000000| 00000000|boot_logo_|
|
||||
* |00000010| 00000000| 00000000| 00000000|boot_keyb_|
|
||||
* |00000100| 00000000| 00000000| 00000000|awake_logo|
|
||||
* |00001000| 00000000| 00000000| 00000000|awake_keyb|
|
||||
* |00010000| 00000000| 00000000| 00000000|sleep_logo|
|
||||
* |00100000| 00000000| 00000000| 00000000|sleep_keyb|
|
||||
* |01000000| 00000000| 00000000| 00000000|shut_logo_|
|
||||
* |10000000| 00000000| 00000000| 00000000|shut_keyb_|
|
||||
* |00000000| 00000010| 00000000| 00000000|boot_bar__|
|
||||
* |00000000| 00000100| 00000000| 00000000|awake_bar_|
|
||||
* |00000000| 00001000| 00000000| 00000000|sleep_bar_|
|
||||
* |00000000| 00010000| 00000000| 00000000|shut_bar__|
|
||||
* |00000000| 00000000| 00000001| 00000000|boot_lid__|
|
||||
* |00000000| 00000000| 00000010| 00000000|awkae_lid_|
|
||||
* |00000000| 00000000| 00000100| 00000000|sleep_lid_|
|
||||
* |00000000| 00000000| 00001000| 00000000|shut_lid__|
|
||||
* |00000000| 00000000| 00000000| 00000001|boot_rear_|
|
||||
* |00000000| 00000000| 00000000| 00000010|awake_rear|
|
||||
* |00000000| 00000000| 00000000| 00000100|sleep_rear|
|
||||
* |00000000| 00000000| 00000000| 00001000|shut_rear_|
|
||||
*/
|
||||
export interface AuraPower {
|
||||
keyboard: KbAuraPowerState;
|
||||
logo: KbAuraPowerState;
|
||||
lightbar: KbAuraPowerState;
|
||||
lid: KbAuraPowerState;
|
||||
rear_glow: KbAuraPowerState;
|
||||
}
|
||||
|
||||
export enum AuraDevTuf {
|
||||
Boot = "Boot",
|
||||
Awake = "Awake",
|
||||
Sleep = "Sleep",
|
||||
Keyboard = "Keyboard",
|
||||
}
|
||||
|
||||
/**
|
||||
* # Bits for older 0x1866 keyboard model
|
||||
*
|
||||
* Keybord and Lightbar require Awake, Boot and Sleep apply to both
|
||||
* Keybord and Lightbar regardless of if either are enabled (or Awake is
|
||||
* enabled)
|
||||
*
|
||||
* | Byte 1 | Byte 2 | Byte 3 | function | hex |
|
||||
* |------------|------------|------------|----------|----------|
|
||||
* | 0000, 0000 | 0000, 0000 | 0000, 0010 | Awake | 00,00,02 |
|
||||
* | 0000, 1000 | 0000, 0000 | 0000, 0000 | Keyboard | 08,00,00 |
|
||||
* | 0000, 0100 | 0000, 0101 | 0000, 0000 | Lightbar | 04,05,00 |
|
||||
* | 1100, 0011 | 0001, 0010 | 0000, 1001 | Boot/Sht | c3,12,09 |
|
||||
* | 0011, 0000 | 0000, 1000 | 0000, 0100 | Sleep | 30,08,04 |
|
||||
* | 1111, 1111 | 0001, 1111 | 0000, 1111 | all on | |
|
||||
*/
|
||||
export enum AuraDevRog1 {
|
||||
Awake = "Awake",
|
||||
Keyboard = "Keyboard",
|
||||
Lightbar = "Lightbar",
|
||||
Boot = "Boot",
|
||||
Sleep = "Sleep",
|
||||
}
|
||||
|
||||
/** This struct is intended as a helper to pass args to generic dbus interface */
|
||||
export interface AuraPowerDev {
|
||||
/**
|
||||
* TUF laptops use a similar style of control to the older ROG devices but
|
||||
* through WMI
|
||||
*/
|
||||
tuf: AuraDevTuf[];
|
||||
/**
|
||||
* Pre-0x19b6 devices use a different smaller scheme to the newer ROG
|
||||
* devices
|
||||
*/
|
||||
old_rog: AuraDevRog1[];
|
||||
/** ASUS standardised control scheme from 2020 onwards */
|
||||
rog: AuraPower;
|
||||
}
|
||||
|
||||
export enum LedBrightness {
|
||||
Off = "Off",
|
||||
Low = "Low",
|
||||
Med = "Med",
|
||||
High = "High",
|
||||
}
|
||||
|
||||
export enum AuraDevice {
|
||||
Tuf = "Tuf",
|
||||
X1854 = "X1854",
|
||||
X1869 = "X1869",
|
||||
X1866 = "X1866",
|
||||
X18c6 = "X18c6",
|
||||
X19b6 = "X19b6",
|
||||
X1a30 = "X1a30",
|
||||
X1abe = "X1abe",
|
||||
Unknown = "Unknown",
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
Generated by typeshare 1.7.0
|
||||
*/
|
||||
|
||||
export enum CPUGovernor {
|
||||
Performance = "Performance",
|
||||
Powersave = "Powersave",
|
||||
BadValue = "BadValue",
|
||||
}
|
||||
|
||||
export enum CPUEPP {
|
||||
Default = "Default",
|
||||
Performance = "Performance",
|
||||
BalancePerformance = "BalancePerformance",
|
||||
BalancePower = "BalancePower",
|
||||
Power = "Power",
|
||||
}
|
||||
|
||||
export enum GpuMode {
|
||||
Discrete = "Discrete",
|
||||
Optimus = "Optimus",
|
||||
Integrated = "Integrated",
|
||||
Egpu = "Egpu",
|
||||
Vfio = "Vfio",
|
||||
Ultimate = "Ultimate",
|
||||
Error = "Error",
|
||||
NotSupported = "NotSupported",
|
||||
}
|
||||
|
||||
/** `throttle_thermal_policy` in asus_wmi */
|
||||
export enum ThrottlePolicy {
|
||||
Balanced = "Balanced",
|
||||
Performance = "Performance",
|
||||
Quiet = "Quiet",
|
||||
}
|
||||
|
||||
/** CamelCase names of the properties. Intended for use with DBUS */
|
||||
export enum Properties {
|
||||
ChargeControlEndThreshold = "ChargeControlEndThreshold",
|
||||
DgpuDisable = "DgpuDisable",
|
||||
GpuMuxMode = "GpuMuxMode",
|
||||
PostAnimationSound = "PostAnimationSound",
|
||||
PanelOd = "PanelOd",
|
||||
MiniLedMode = "MiniLedMode",
|
||||
EgpuEnable = "EgpuEnable",
|
||||
ThrottlePolicy = "ThrottlePolicy",
|
||||
PptPl1Spl = "PptPl1Spl",
|
||||
PptPl2Sppt = "PptPl2Sppt",
|
||||
PptFppt = "PptFppt",
|
||||
PptApuSppt = "PptApuSppt",
|
||||
PptPlatformSppt = "PptPlatformSppt",
|
||||
NvDynamicBoost = "NvDynamicBoost",
|
||||
NvTempTarget = "NvTempTarget",
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
Generated by typeshare 1.7.0
|
||||
*/
|
||||
|
||||
export enum FanCurvePU {
|
||||
CPU = "CPU",
|
||||
GPU = "GPU",
|
||||
MID = "MID",
|
||||
}
|
||||
|
||||
export interface CurveData {
|
||||
fan: FanCurvePU;
|
||||
pwm: [number, number, number, number, number, number, number, number];
|
||||
temp: [number, number, number, number, number, number, number, number];
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
/** Main purpose of `FanCurves` is to enable restoring state on system boot */
|
||||
export interface FanCurveProfiles {
|
||||
balanced: CurveData[];
|
||||
performance: CurveData[];
|
||||
quiet: CurveData[];
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
[package]
|
||||
name = "config-traits"
|
||||
license = "MPL-2.0"
|
||||
authors = ["Luke D Jones <luke@ljones.dev>"]
|
||||
edition = "2021"
|
||||
license.workspace = true
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
serde_json.workspace = true
|
||||
toml.workspace = true
|
||||
ron.workspace = true
|
||||
|
||||
log.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
cargo-husky.workspace = true
|
||||
cargo-husky.workspace = true
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
//! updating them from previous versions where fields or names are changed in
|
||||
//! some way.
|
||||
//!
|
||||
//! The end canonical file format is `.ron` as this supports rust types well,
|
||||
//! and includes the ability to add commenting, and is less verbose than `json`.
|
||||
//! Currently the crate will also try to parse from `json` and `toml` if the
|
||||
//! `ron` parsing fails, then update to `ron` format.
|
||||
//! The end canonical file format is `.ron` as this supports rust types well
|
||||
|
||||
use std::fs::{self, create_dir, File, OpenOptions};
|
||||
use std::io::{Read, Write};
|
||||
@@ -92,6 +89,7 @@ where
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(false)
|
||||
.open(self.file_path())
|
||||
.unwrap_or_else(|e| panic!("Could not open {:?} {e}", self.file_path()))
|
||||
}
|
||||
@@ -148,11 +146,7 @@ where
|
||||
|
||||
/// Renames the existing file to `<file>-old`
|
||||
fn rename_file_old(&self) {
|
||||
warn!(
|
||||
"Renaming {} to {}-old and recreating config",
|
||||
self.file_name(),
|
||||
self.file_name()
|
||||
);
|
||||
warn!("Renaming {} to {}-old", self.file_name(), self.file_name());
|
||||
let mut cfg_old = self.file_path().to_string_lossy().to_string();
|
||||
cfg_old.push_str("-old");
|
||||
std::fs::rename(self.file_path(), cfg_old).unwrap_or_else(|err| {
|
||||
@@ -220,21 +214,9 @@ macro_rules! std_config_load {
|
||||
if let Ok(data) = ron::from_str(&buf) {
|
||||
self = data;
|
||||
log::info!("Parsed RON for {:?}", std::any::type_name::<Self>());
|
||||
} else if let Ok(data) = serde_json::from_str(&buf) {
|
||||
self = data;
|
||||
log::info!("Parsed JSON for {:?}", std::any::type_name::<Self>());
|
||||
} else if let Ok(data) = toml::from_str(&buf) {
|
||||
self = data;
|
||||
log::info!("Parsed TOML for {:?}", std::any::type_name::<Self>());
|
||||
} $(else if let Ok(data) = ron::from_str::<$generic>(&buf) {
|
||||
} $(else if let Ok(data) = ron::from_str::<$generic>(&buf) {
|
||||
self = data.into();
|
||||
log::info!("New version failed, trying previous: Parsed RON for {:?}", std::any::type_name::<$generic>());
|
||||
} else if let Ok(data) = serde_json::from_str::<$generic>(&buf) {
|
||||
self = data.into();
|
||||
log::info!("New version failed, trying previous: Parsed JSON for {:?}", std::any::type_name::<$generic>());
|
||||
} else if let Ok(data) = toml::from_str::<$generic>(&buf) {
|
||||
self = data.into();
|
||||
log::info!("Newvious version failed, trying previous: Parsed TOML for {:?}", std::any::type_name::<$generic>());
|
||||
})* else {
|
||||
self.rename_file_old();
|
||||
self = Self::new();
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
[package]
|
||||
name = "cpuctl"
|
||||
license = "MPL-2.0"
|
||||
edition = "2021"
|
||||
license.workspace = true
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -7,6 +7,7 @@ ENV{DMI_FAMILY}=="*ROG*", GOTO="asusd_start"
|
||||
ENV{DMI_FAMILY}=="*Zephyrus*", GOTO="asusd_start"
|
||||
ENV{DMI_FAMILY}=="*Strix*", GOTO="asusd_start"
|
||||
ENV{DMI_FAMILY}=="*Vivo*ook*", GOTO="asusd_start"
|
||||
ENV{DMI_FAMILY}=="*Zenbook*", GOTO="asusd_start"
|
||||
# No match so
|
||||
GOTO="asusd_end"
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ After=nvidia-powerd.service systemd-udevd.service
|
||||
[Service]
|
||||
Environment=IS_SERVICE=1
|
||||
Environment=RUST_LOG="info"
|
||||
# ExecStartPre=/bin/sleep 2 # was required only for slow devices
|
||||
# required to prevent init issues with hid_asus and MCU
|
||||
ExecStartPre=/bin/sleep 1
|
||||
ExecStart=/usr/bin/asusd
|
||||
Restart=on-failure
|
||||
RestartSec=1
|
||||
Type=dbus
|
||||
BusName=org.asuslinux.Daemon
|
||||
SELinuxContext=system_u:system_r:unconfined_t:s0
|
||||
#SELinuxContext=system_u:object_r:modules_object_t:s0
|
||||
#SELinuxContext=system_u:object_r:modules_object_t:s0
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/* 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",
|
||||
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
},
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
# Generated files
|
||||
/@types/gir-generated/*
|
||||
|
||||
# Build outputes
|
||||
/dist/
|
||||
/build/
|
||||
|
||||
# Node configuration and modules
|
||||
/package.json
|
||||
/node_modules/
|
||||
|
||||
# Files I prefer not to be formatted
|
||||
*.md
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"printWidth": 100,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"trailingComma": "all",
|
||||
"bracketSpacing": true,
|
||||
"arrowParens": "always"
|
||||
}
|
||||
@@ -1,373 +0,0 @@
|
||||
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.
|
||||
@@ -1,21 +0,0 @@
|
||||
# asusctl
|
||||
|
||||
Requires `asusd` to be installed and running.
|
||||
|
||||
## build and install
|
||||
|
||||
```
|
||||
npm install
|
||||
npm run build && gnome-extensions install asusctl-gnome@asus-linux.org.zip --force
|
||||
npm run build && gnome-extensions enable asusctl-gnome@asus-linux.org.zip
|
||||
```
|
||||
|
||||
You will need to restart Gnome after installing or updating
|
||||
|
||||
## development
|
||||
|
||||
```
|
||||
npm run build
|
||||
gnome-extensions install asusctl-gnome@asus-linux.org.zip --force
|
||||
MUTTER_DEBUG_DUMMY_MODE_SPECS=1366x768 dbus-run-session -- gnome-shell --nested --wayland
|
||||
```
|
||||
@@ -1,67 +0,0 @@
|
||||
import { build } from "esbuild";
|
||||
import { exec } from "child_process";
|
||||
import { copyFileSync, cpSync } from "fs";
|
||||
import { resolve, dirname } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import AdmZip from "adm-zip";
|
||||
import metadata from "./src/metadata.json" assert { type: "json" };
|
||||
|
||||
build({
|
||||
entryPoints: ["src/extension.ts"],
|
||||
outdir: "dist",
|
||||
bundle: true,
|
||||
// Do not remove the functions `enable()`, `disable()` and `init()`
|
||||
treeShaking: false,
|
||||
// firefox60 // Since GJS 1.53.90
|
||||
// firefox68 // Since GJS 1.63.90
|
||||
// firefox78 // Since GJS 1.65.90
|
||||
// firefox91 // Since GJS 1.71.1
|
||||
// firefox102 // Since GJS 1.73.2
|
||||
target: "firefox102",
|
||||
//platform: "neutral",
|
||||
platform: "node",
|
||||
// mainFields: ['main'],
|
||||
// conditions: ['require', 'default'],
|
||||
format: "esm",
|
||||
external: ["gi://*", "resource://*", "system", "gettext", "cairo"],
|
||||
}).then(() => {
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const metaSrc = resolve(__dirname, "src/metadata.json");
|
||||
const metaDist = resolve(__dirname, "dist/metadata.json");
|
||||
const schemaSrc = resolve(__dirname, "schemas");
|
||||
const schemaDist = resolve(__dirname, "dist/schemas");
|
||||
const dbusXmlSrc = resolve(__dirname, "../../bindings/dbus-xml");
|
||||
const dbusXmlDist = resolve(__dirname, "dist/resources/dbus");
|
||||
const zipFilename = `${metadata.uuid}.zip`;
|
||||
const zipDist = resolve(__dirname, zipFilename);
|
||||
|
||||
exec("glib-compile-schemas schemas/", (error, stdout, stderr) => {
|
||||
console.log("stdout: " + stdout);
|
||||
console.log("stderr: " + stderr);
|
||||
});
|
||||
|
||||
copyFileSync(metaSrc, metaDist);
|
||||
|
||||
cpSync(schemaSrc, schemaDist, { recursive: true }, (err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
cpSync(dbusXmlSrc, dbusXmlDist, { recursive: true }, (err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
const zip = new AdmZip();
|
||||
zip.addLocalFolder(resolve(__dirname, "dist"));
|
||||
zip.writeZip(zipDist);
|
||||
|
||||
console.log(`Build complete. Zip file: ${zipFilename}\n`);
|
||||
console.log(`Install with: gnome-extensions install ${zipFilename}`);
|
||||
console.log(`Update with: gnome-extensions install ${zipFilename} --force`);
|
||||
console.log(`Enable with: gnome-extensions enable ${metadata.uuid} --user`);
|
||||
});
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
## Script to initialise dev-environment (types)
|
||||
gv="44"
|
||||
wd=${PWD}
|
||||
|
||||
# cleanup
|
||||
rm -rf @types
|
||||
|
||||
# generate GJS from gir (this does not include the extensions)
|
||||
echo "Generating GJS types from gir.."
|
||||
npx ts-for-gir generate Shell-12 St-12 Gtk-4.0 \
|
||||
-g /usr/share/gir-1.0 \
|
||||
-g /usr/share/gnome-shell \
|
||||
-g /usr/share/gnome-shell/gir-1.0 \
|
||||
-g /usr/lib64/mutter-12 \
|
||||
-t esm -o @types/Gjs
|
||||
|
||||
# get latest js (44) in this case and create the types for it
|
||||
echo "Generating GJS Extension (Gex) types from extension source.."
|
||||
mkdir -p ./_tmp/
|
||||
cd ./_tmp
|
||||
wget -q -O gnome-shell-js-${gv}.tar.gz https://gitlab.gnome.org/GNOME/gnome-shell/-/archive/gnome-${gv}/gnome-shell-gnome-${gv}.tar.gz?path=js
|
||||
tar xf gnome-shell-js-${gv}.tar.gz
|
||||
cd gnome-shell-gnome-${gv}-js
|
||||
cat >tsconfig.json <<EOL
|
||||
{
|
||||
"include": ["js/ui/*"],
|
||||
"exclude": [
|
||||
"js/ui/shellDBus.js",
|
||||
"node_modules",
|
||||
"**/node_modules/*"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "gex-types",
|
||||
"declarationMap": true,
|
||||
"lib": ["es2019"]
|
||||
}
|
||||
}
|
||||
EOL
|
||||
npx tsc
|
||||
cd ${wd}
|
||||
mv ./_tmp/gnome-shell-gnome-${gv}-js/gex-types @types/Gex
|
||||
# rm -rf ./_tmp/
|
||||
|
||||
echo "done."
|
||||
|
||||
exit 0
|
||||
2747
desktop-extensions/gnome-45/package-lock.json
generated
2747
desktop-extensions/gnome-45/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,55 +0,0 @@
|
||||
{
|
||||
"name": "asusctl-gnome",
|
||||
"version": "5.0.0-RC1",
|
||||
"description": "asusctl-gnome a gnome extension exposing some of the base features of asusd in a helpful and easy to use way",
|
||||
"type": "module",
|
||||
"main": "dist/extension.js",
|
||||
"scripts": {
|
||||
"clear": "rm -rf dist",
|
||||
"compile": "tsc --build tsconfig.json",
|
||||
"build:app": "node esbuild.js",
|
||||
"build": "yarn run clear && yarn run build:app",
|
||||
"validate": "tsc --noEmit",
|
||||
"generate:gir-types": "ts-for-gir generate",
|
||||
"check:types": "tsc --build tsconfig.types.json",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier . -w"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@girs/gnome-shell": "^45.0.0-beta2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
||||
"@typescript-eslint/parser": "^5.60.1",
|
||||
"adm-zip": "^0.5.10",
|
||||
"esbuild": "^0.19.5",
|
||||
"eslint": "^8.51.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-promise": "^6.1.1",
|
||||
"prettier": "^3.0.3",
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@girs/gjs": "^3.2.5",
|
||||
"@girs/gobject-2.0": "^2.78.0-3.2.5",
|
||||
"@girs/st-13": "^13.0.0-3.2.5"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/asus-linux/asusctl.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"
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist gettext-domain="AsusctlGnomeExtension">
|
||||
<schema id="org.gnome.shell.extensions.asusctl-gnome" path="/org/gnome/shell/extensions/asusctl-gnome/" >
|
||||
<key type="b" name="mini-led-enabled">
|
||||
<default>false</default>
|
||||
</key>
|
||||
<key type="b" name="panel-od-enabled">
|
||||
<default>false</default>
|
||||
</key>
|
||||
<key type="b" name="anime-power">
|
||||
<default>false</default>
|
||||
</key>
|
||||
<key type="b" name="anime-builtins">
|
||||
<default>false</default>
|
||||
</key>
|
||||
<key name="charge-level" type="u">
|
||||
<range min="20" max="100"/>
|
||||
<default>100</default>
|
||||
</key>
|
||||
<key type="s" name="primary-quickmenu-toggle">
|
||||
<default>"mini-led"</default>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
||||
@@ -1 +0,0 @@
|
||||
../../../bindings/ts
|
||||
@@ -1,127 +0,0 @@
|
||||
import { Extension, gettext as _ } from "@girs/gnome-shell/extensions/extension";
|
||||
import * as platform from "./bindings/platform";
|
||||
import { AsusQuickToggle } from "./modules/rog_quick_toggle";
|
||||
import { AsusMenuToggle } from "./modules/rog_menu_toggle";
|
||||
import { AsusIndicator } from "./modules/rog_indicator";
|
||||
import { AsusSlider } from "./modules/rog_slider_100pc";
|
||||
import { FeatureMenuToggle } from "./modules/quick_menus/laptop_features";
|
||||
import { DbusBase } from "./modules/dbus_proxy";
|
||||
import { main } from "@girs/gnome-shell/ui";
|
||||
|
||||
export const uuid = "asusctl-gnome@asus-linux.org";
|
||||
export default class AsusExtension extends Extension {
|
||||
// public dbus_aura: AuraDbus = new AuraDbus;
|
||||
// public dbus_anime: AnimeDbus = new AnimeDbus;
|
||||
public dbus_platform: DbusBase | undefined;
|
||||
public dbus_anime: DbusBase | undefined;
|
||||
|
||||
private individual = false;
|
||||
public supported_properties!: platform.Properties;
|
||||
public supported_interfaces: string[] = [];
|
||||
private feature_menu = null;
|
||||
private panel_od = null;
|
||||
private mini_led = null;
|
||||
private anime_display = null;
|
||||
private anime_builtins = null;
|
||||
private charge_thres = null;
|
||||
// private _feature: typeof FeatureMenuToggle;
|
||||
|
||||
async enable() {
|
||||
log(this.path);
|
||||
|
||||
if (this.dbus_platform == undefined) {
|
||||
this.dbus_platform = new DbusBase("org-asuslinux-platform-4.xml", "/org/asuslinux/Platform");
|
||||
await this.dbus_platform.start();
|
||||
}
|
||||
|
||||
if (this.dbus_anime == undefined) {
|
||||
this.dbus_anime = new DbusBase("org-asuslinux-anime-4.xml", "/org/asuslinux/Anime");
|
||||
await this.dbus_anime.start();
|
||||
}
|
||||
|
||||
this.supported_interfaces = this.dbus_platform?.proxy.SupportedInterfacesSync()[0];
|
||||
this.supported_properties = this.dbus_platform?.proxy.SupportedPropertiesSync()[0];
|
||||
log(this.supported_interfaces);
|
||||
log(this.supported_properties);
|
||||
|
||||
// new AsusIndicator("selection-mode-symbolic", "mini-led-enabled");
|
||||
// new AsusIndicator("selection-mode-symbolic", "panel-od-enabled");
|
||||
|
||||
if (!this.individual) {
|
||||
if (this.feature_menu == null)
|
||||
this.feature_menu = new FeatureMenuToggle(this.dbus_platform, this.dbus_anime);
|
||||
} else {
|
||||
if (this.supported_properties.includes("PanelOd") && this.dbus_platform.proxy.PanelOd != null)
|
||||
if (this.panel_od == null) {
|
||||
this.panel_od = new AsusQuickToggle(
|
||||
this.dbus_platform,
|
||||
"PanelOd",
|
||||
"panel-od-enabled",
|
||||
"Panel Overdrive",
|
||||
);
|
||||
}
|
||||
|
||||
if (this.supported_properties.includes("MiniLed") && this.dbus_platform.proxy.MiniLed != null)
|
||||
if (this.mini_led == null) {
|
||||
this.mini_led = new AsusQuickToggle(
|
||||
this.dbus_platform,
|
||||
"MiniLed",
|
||||
"mini-led-enabled",
|
||||
"Mini-LED",
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
this.supported_interfaces.includes("Anime") &&
|
||||
this.dbus_anime.proxy.EnableDisplay != null
|
||||
)
|
||||
if (this.anime_display == null) {
|
||||
this.anime_display = new AsusQuickToggle(
|
||||
this.dbus_anime,
|
||||
"EnableDisplay",
|
||||
"anime-power",
|
||||
"AniMe Display",
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
this.supported_interfaces.includes("Anime") &&
|
||||
this.dbus_anime.proxy.BuiltinsEnabled != null
|
||||
)
|
||||
if (this.anime_builtins == null) {
|
||||
this.anime_builtins = new AsusQuickToggle(
|
||||
this.dbus_anime,
|
||||
"BuiltinsEnabled",
|
||||
"anime-builtins",
|
||||
"Use builtins",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
this.supported_properties.includes("ChargeControlEndThreshold") &&
|
||||
this.dbus_platform.proxy.ChargeControlEndThreshold != null
|
||||
)
|
||||
if (this.charge_thres == null) {
|
||||
this.charge_thres = new AsusSlider(
|
||||
this.dbus_platform,
|
||||
"ChargeControlEndThreshold",
|
||||
"charge-level",
|
||||
"Charge Level",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
disable() {
|
||||
this.dbus_platform?.stop();
|
||||
this.dbus_anime?.stop();
|
||||
|
||||
this.feature_menu?.destroy();
|
||||
feature_menu?.destroy();
|
||||
panel_od?.destroy();
|
||||
mini_led?.destroy();
|
||||
anime_display?.destroy();
|
||||
anime_builtins?.destroy();
|
||||
charge_thres?.destroy();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"name": "asusctl-gnome",
|
||||
"description": "asusctl-gnome a gnome extension exposing some of the base features of asusd in a helpful and easy to use way",
|
||||
"uuid": "asusctl-gnome@asus-linux.org",
|
||||
"uuid-dev": "asusctl-gnome-dev@asus-linux.org",
|
||||
"settings-schema": "org.gnome.shell.extensions.asusctl-gnome",
|
||||
"version": "4.3.2",
|
||||
"shell-version": ["45"]
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
import { DbusBase } from "../dbus_proxy";
|
||||
import {
|
||||
DeviceState,
|
||||
AnimBooting,
|
||||
Brightness,
|
||||
AnimAwake,
|
||||
AnimSleeping,
|
||||
AnimShutdown,
|
||||
} from "../../bindings/anime";
|
||||
|
||||
export class AnimeDbus extends DbusBase {
|
||||
deviceState: DeviceState = {
|
||||
display_enabled: false,
|
||||
display_brightness: Brightness.Med,
|
||||
builtin_anims_enabled: false,
|
||||
builtin_anims: {
|
||||
boot: AnimBooting.GlitchConstruction,
|
||||
awake: AnimAwake.BinaryBannerScroll,
|
||||
sleep: AnimSleeping.BannerSwipe,
|
||||
shutdown: AnimShutdown.GlitchOut,
|
||||
},
|
||||
off_when_unplugged: false,
|
||||
off_when_suspended: false,
|
||||
off_when_lid_closed: false,
|
||||
};
|
||||
|
||||
// TODO: interface or something to enforce requirement of "sync()" method
|
||||
public notifyAnimeStateSubscribers: any[] = [];
|
||||
|
||||
constructor() {
|
||||
super("org-asuslinux-anime-4", "/org/asuslinux/Anime");
|
||||
}
|
||||
|
||||
_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][3] as AnimShutdown];
|
||||
this.deviceState.off_when_unplugged = data[4];
|
||||
this.deviceState.off_when_suspended = data[5];
|
||||
this.deviceState.off_when_lid_closed = data[6];
|
||||
}
|
||||
}
|
||||
|
||||
public getDeviceState() {
|
||||
if (this.isRunning()) {
|
||||
try {
|
||||
// janky shit going on with DeviceStateSync
|
||||
this._parseData(this.dbus_proxy.DeviceStateSync());
|
||||
//@ts-ignore
|
||||
log("Anime Matrix: display_enabled: " + this.deviceState.display_enabled);
|
||||
//@ts-ignore
|
||||
log("Anime Matrix: display_brightness: " + this.deviceState.display_brightness);
|
||||
//@ts-ignore
|
||||
log("Anime Matrix: builtin_anims_enabled: " + this.deviceState.builtin_anims_enabled);
|
||||
//@ts-ignore
|
||||
log("Anime Matrix: builtin_anims: " + this.deviceState.builtin_anims);
|
||||
//@ts-ignore
|
||||
log("Anime Matrix: off_when_unplugged: " + this.deviceState.off_when_unplugged);
|
||||
//@ts-ignore
|
||||
log("Anime Matrix: off_when_suspended: " + this.deviceState.off_when_suspended);
|
||||
//@ts-ignore
|
||||
log("Anime Matrix: off_when_lid_closed: " + this.deviceState.off_when_lid_closed);
|
||||
} catch (e) {
|
||||
//@ts-ignore
|
||||
log("Failed to fetch DeviceState!", e);
|
||||
}
|
||||
}
|
||||
return this.deviceState;
|
||||
}
|
||||
|
||||
async start() {
|
||||
await super.start();
|
||||
this.getDeviceState();
|
||||
|
||||
this.dbus_proxy.connectSignal(
|
||||
"NotifyDeviceState",
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(proxy: any = null, name: string, data: string) => {
|
||||
if (proxy) {
|
||||
// idiot xml parsing mneans the get is not nested while this is
|
||||
this._parseData(data[0]);
|
||||
this.notifyAnimeStateSubscribers.forEach((sub) => {
|
||||
sub.sync();
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async stop() {
|
||||
await super.stop();
|
||||
}
|
||||
}
|
||||
@@ -1,300 +0,0 @@
|
||||
import {
|
||||
AuraDevRog1,
|
||||
AuraDevTuf,
|
||||
AuraDevice,
|
||||
AuraEffect,
|
||||
AuraModeNum,
|
||||
AuraPower,
|
||||
AuraPowerDev,
|
||||
AuraZone,
|
||||
Direction,
|
||||
PowerZones,
|
||||
Speed,
|
||||
} from "../../bindings/aura";
|
||||
import { DbusBase } from "./base";
|
||||
|
||||
export class AuraDbus extends DbusBase {
|
||||
public device: AuraDevice = AuraDevice.Unknown;
|
||||
public current_aura_mode: AuraModeNum = AuraModeNum.Static;
|
||||
public aura_modes: Map<AuraModeNum, AuraEffect> = new Map();
|
||||
public leds_powered: AuraPowerDev = {
|
||||
tuf: [],
|
||||
old_rog: [],
|
||||
rog: {
|
||||
keyboard: {
|
||||
zone: PowerZones.Keyboard,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
},
|
||||
logo: {
|
||||
zone: PowerZones.Logo,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
},
|
||||
lightbar: {
|
||||
zone: PowerZones.Lightbar,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
},
|
||||
lid: {
|
||||
zone: PowerZones.Lid,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
},
|
||||
rear_glow: {
|
||||
zone: PowerZones.RearGlow,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
// TODO: interface or something to enforce requirement of "sync()" method
|
||||
public notifyAuraModeSubscribers: any[] = [];
|
||||
public notifyAuraPowerSubscribers: any[] = [];
|
||||
|
||||
constructor() {
|
||||
super("org-asuslinux-aura-4", "/org/asuslinux/Aura");
|
||||
}
|
||||
|
||||
public getDevice() {
|
||||
if (this.isRunning()) {
|
||||
try {
|
||||
this.device = AuraDevice[this.dbus_proxy.DeviceTypeSync() as AuraDevice];
|
||||
//@ts-ignore
|
||||
log("LED device: " + this.device);
|
||||
} catch (e) {
|
||||
//@ts-ignore
|
||||
log("Failed to fetch supported functionalities", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_parsePowerStates(data: any[]) {
|
||||
const power: AuraPowerDev = this.leds_powered;
|
||||
|
||||
power.tuf = data[0].map((value: string) => {
|
||||
return AuraDevTuf[value as AuraDevTuf];
|
||||
});
|
||||
power.old_rog = data[1].map((value: string) => {
|
||||
return AuraDevRog1[value as AuraDevRog1];
|
||||
});
|
||||
power.rog = {
|
||||
keyboard: {
|
||||
zone: PowerZones[data[2][0][0] as PowerZones],
|
||||
boot: data[2][0][1],
|
||||
awake: data[2][0][2],
|
||||
sleep: data[2][0][3],
|
||||
shutdown: data[2][0][4],
|
||||
},
|
||||
logo: {
|
||||
zone: PowerZones[data[2][1][0] as PowerZones],
|
||||
boot: data[2][1][1],
|
||||
awake: data[2][1][2],
|
||||
sleep: data[2][1][3],
|
||||
shutdown: data[2][1][4],
|
||||
},
|
||||
lightbar: {
|
||||
zone: PowerZones[data[2][2][0] as PowerZones],
|
||||
boot: data[2][2][1],
|
||||
awake: data[2][2][2],
|
||||
sleep: data[2][2][3],
|
||||
shutdown: data[2][2][4],
|
||||
},
|
||||
lid: {
|
||||
zone: PowerZones[data[2][3][0] as PowerZones],
|
||||
boot: data[2][3][1],
|
||||
awake: data[2][3][2],
|
||||
sleep: data[2][3][3],
|
||||
shutdown: data[2][3][4],
|
||||
},
|
||||
rear_glow: {
|
||||
zone: PowerZones[data[2][4][0] as PowerZones],
|
||||
boot: data[2][4][1],
|
||||
awake: data[2][4][2],
|
||||
sleep: data[2][4][3],
|
||||
shutdown: data[2][4][4],
|
||||
},
|
||||
};
|
||||
|
||||
return power;
|
||||
}
|
||||
|
||||
public getLedPower() {
|
||||
if (this.isRunning()) {
|
||||
try {
|
||||
const data = this.dbus_proxy.LedPowerSync();
|
||||
this.leds_powered = this._parsePowerStates(data);
|
||||
//@ts-ignore
|
||||
log("LED power tuf: " + this.leds_powered.tuf);
|
||||
//@ts-ignore
|
||||
log("LED power x1866: " + this.leds_powered.old_rog);
|
||||
//@ts-ignore
|
||||
log("LED power x19b6: " + this.leds_powered.rog);
|
||||
} catch (e) {
|
||||
//@ts-ignore
|
||||
log("Failed to fetch supported functionalities", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getLedMode() {
|
||||
if (this.isRunning()) {
|
||||
try {
|
||||
this.current_aura_mode = AuraModeNum[this.dbus_proxy.LedModeSync() as AuraModeNum];
|
||||
//@ts-ignore
|
||||
log("Current LED mode:", this.current_aura_mode);
|
||||
} catch (e) {
|
||||
//@ts-ignore
|
||||
log("Failed to fetch supported functionalities", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setLedMode(mode: AuraEffect) {
|
||||
if (this.isRunning()) {
|
||||
try {
|
||||
this.dbus_proxy.SetLedModeSync([
|
||||
mode.mode,
|
||||
mode.zone,
|
||||
[mode.colour1.r, mode.colour1.g, mode.colour1.b],
|
||||
[mode.colour2.r, mode.colour2.g, mode.colour2.b],
|
||||
mode.speed,
|
||||
mode.direction,
|
||||
]);
|
||||
} catch (e) {
|
||||
//@ts-ignore
|
||||
log("Failed to fetch supported functionalities", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_parseAuraEffect(data: any[]) {
|
||||
const aura: AuraEffect = {
|
||||
mode: AuraModeNum[data[0] as AuraModeNum],
|
||||
zone: AuraZone[data[1] as AuraZone],
|
||||
colour1: {
|
||||
r: parseInt(data[2][0]),
|
||||
g: parseInt(data[2][1]),
|
||||
b: parseInt(data[2][2]),
|
||||
},
|
||||
colour2: {
|
||||
r: parseInt(data[3][0]),
|
||||
g: parseInt(data[3][1]),
|
||||
b: parseInt(data[3][2]),
|
||||
},
|
||||
speed: Speed[data[4] as Speed],
|
||||
direction: Direction[data[5] as Direction],
|
||||
};
|
||||
return aura;
|
||||
}
|
||||
|
||||
// Return a list of the available modes, and the current settings for each
|
||||
public getLedModes() {
|
||||
// {'Breathe': ('Breathe', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
||||
// 'Comet': ('Comet', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
||||
// 'Static': ('Static', 'None', (78, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
||||
// 'Strobe': ('Strobe', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right')}
|
||||
if (this.isRunning()) {
|
||||
try {
|
||||
const _data = this.dbus_proxy.LedModesSync();
|
||||
for (const key in _data[0]) {
|
||||
const data = _data[0][key];
|
||||
const aura: AuraEffect = this._parseAuraEffect(data);
|
||||
this.aura_modes.set(AuraModeNum[key as AuraModeNum], aura);
|
||||
}
|
||||
|
||||
for (const [key, value] of this.aura_modes) {
|
||||
//@ts-ignore
|
||||
log(key, value.zone, value.colour1.r, value.speed, value.direction);
|
||||
}
|
||||
} catch (e) {
|
||||
//@ts-ignore
|
||||
log("Failed to fetch supported functionalities", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async start() {
|
||||
try {
|
||||
await super.start();
|
||||
this.getDevice();
|
||||
this.getLedPower();
|
||||
this.getLedMode();
|
||||
this.getLedModes();
|
||||
|
||||
//@ts-ignore
|
||||
log("Current LED mode data:", this.aura_modes.get(this.current_aura_mode)?.speed);
|
||||
|
||||
this.dbus_proxy.connectSignal("NotifyLed", (proxy: any = null, name: string, data: any) => {
|
||||
if (proxy) {
|
||||
const aura: AuraEffect = this._parseAuraEffect(data[0]);
|
||||
this.current_aura_mode = aura.mode;
|
||||
this.aura_modes.set(aura.mode, aura);
|
||||
//@ts-ignore
|
||||
log(
|
||||
"LED data has changed to ",
|
||||
aura.mode,
|
||||
aura.zone,
|
||||
aura.colour1.r,
|
||||
aura.speed,
|
||||
aura.direction,
|
||||
);
|
||||
this.notifyAuraModeSubscribers.forEach((sub) => {
|
||||
sub.sync();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.dbus_proxy.connectSignal(
|
||||
"NotifyPowerStates",
|
||||
(proxy: any = null, name: string, data: any) => {
|
||||
if (proxy) {
|
||||
const power: AuraPowerDev = this._parsePowerStates(data[0]);
|
||||
this.leds_powered = power;
|
||||
switch (this.device) {
|
||||
case AuraDevice.Tuf:
|
||||
//@ts-ignore
|
||||
log("LED power has changed to ", this.leds_powered.tuf);
|
||||
break;
|
||||
case AuraDevice.X1854:
|
||||
case AuraDevice.X1869:
|
||||
case AuraDevice.X18c6:
|
||||
//@ts-ignore
|
||||
log("LED power has changed to ", this.leds_powered.old_rog);
|
||||
break;
|
||||
case AuraDevice.X19b6:
|
||||
case AuraDevice.X1a30:
|
||||
//@ts-ignore
|
||||
log("LED power has changed to ", this.leds_powered.rog);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//@ts-ignore
|
||||
log("LED power has changed to ", this.leds_powered.rog);
|
||||
this.notifyAuraPowerSubscribers.forEach((sub) => {
|
||||
sub.sync();
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
//@ts-ignore
|
||||
log("Supported DBus initialization failed!", e);
|
||||
}
|
||||
}
|
||||
|
||||
async stop() {
|
||||
await super.stop();
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
import { Extension, gettext as _ } from "@girs/gnome-shell/extensions/extension";
|
||||
import { Gio } from "@girs/gio-2.0";
|
||||
import { GLib } from "@girs/glib-2.0";
|
||||
import { imports } from "@girs/gjs";
|
||||
|
||||
// Reads the contents of a file contained in the global resources archive. The data
|
||||
// is returned as a string.
|
||||
export function getStringResource(path: string | null) {
|
||||
const data = Gio.resources_lookup_data(path, 0);
|
||||
return new TextDecoder().decode(data.get_data()?.buffer);
|
||||
}
|
||||
|
||||
export class DbusBase {
|
||||
proxy!: Gio.DBusProxy;
|
||||
connected = false;
|
||||
ifaceXml = "";
|
||||
dbus_path = "";
|
||||
|
||||
constructor(file_name: string, dbus_path: string) {
|
||||
let extensionObject = Extension.lookupByUUID("asusctl-gnome@asus-linux.org");
|
||||
const path = extensionObject?.path + "/resources/dbus/" + file_name;
|
||||
const [ok, data] = GLib.file_get_contents(path);
|
||||
if (!ok) {
|
||||
throw new Error("could not read interface file");
|
||||
}
|
||||
this.ifaceXml = imports.byteArray.toString(data);
|
||||
this.dbus_path = dbus_path;
|
||||
}
|
||||
|
||||
async start() {
|
||||
//@ts-ignore
|
||||
log(`Starting ${this.dbus_path} dbus module`);
|
||||
try {
|
||||
log(this.ifaceXml);
|
||||
this.proxy = Gio.DBusProxy.makeProxyWrapper(this.ifaceXml)(
|
||||
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
|
||||
logError(`${this.xml_resource} dbus init failed!`, e);
|
||||
}
|
||||
}
|
||||
|
||||
async stop() {
|
||||
//@ts-ignore
|
||||
log(`Stopping ${this.xml_resource} dbus module`);
|
||||
|
||||
if (this.connected && this.proxy != undefined) {
|
||||
this.proxy.run_dispose();
|
||||
this.proxy = undefined;
|
||||
this.connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
isRunning(): boolean {
|
||||
return this.connected;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import * as Main from "resource:///org/gnome/shell/ui/main.js";
|
||||
import { QuickToggle } from "resource:///org/gnome/shell/ui/quickSettings.js";
|
||||
|
||||
export function addQuickSettingsItems(items: [typeof QuickToggle], width = 1) {
|
||||
const QuickSettingsMenu = Main.panel.statusArea.quickSettings;
|
||||
items.forEach((item) => QuickSettingsMenu.menu.addItem(item, width));
|
||||
// Ensure the tile(s) are above the background apps menu
|
||||
for (const item of items) {
|
||||
QuickSettingsMenu.menu._grid.set_child_below_sibling(
|
||||
item,
|
||||
QuickSettingsMenu._backgroundApps.quickSettingsItems[0],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
import { addQuickSettingsItems } from "../helpers";
|
||||
import { AuraDbus } from "../dbus/aura";
|
||||
import { AuraEffect, AuraModeNum } from "../../bindings/aura";
|
||||
import GObject from "gi://GObject";
|
||||
|
||||
import * as PopupMenu from "resource:///org/gnome/shell/ui/popupMenu.js";
|
||||
import * as QuickSettings from "resource:///org/gnome/shell/ui/quickSettings.js";
|
||||
|
||||
export const AuraMenuToggle = GObject.registerClass(
|
||||
class AuraMenuToggle extends QuickSettings.QuickMenuToggle {
|
||||
private _dbus_aura: AuraDbus;
|
||||
private _last_mode: AuraModeNum = AuraModeNum.Static;
|
||||
|
||||
constructor(dbus_aura: AuraDbus) {
|
||||
super({
|
||||
title: "Aura Modes",
|
||||
iconName: "selection-mode-symbolic",
|
||||
toggleMode: true,
|
||||
});
|
||||
this._dbus_aura = dbus_aura;
|
||||
|
||||
this.connectObject(this);
|
||||
|
||||
this.menu.setHeader("selection-mode-symbolic", this._dbus_aura.current_aura_mode);
|
||||
|
||||
this._itemsSection = new PopupMenu.PopupMenuSection();
|
||||
|
||||
this._dbus_aura.aura_modes.forEach((mode, key) => {
|
||||
this._itemsSection.addAction(
|
||||
key,
|
||||
() => {
|
||||
this._dbus_aura.setLedMode(mode);
|
||||
this.sync();
|
||||
},
|
||||
"",
|
||||
);
|
||||
});
|
||||
|
||||
this.menu.addMenuItem(this._itemsSection);
|
||||
|
||||
// Add an entry-point for more settings
|
||||
// this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
// const settingsItem = this.menu.addAction("More Settings",
|
||||
// () => ExtensionUtils.openPrefs());
|
||||
// // Ensure the settings are unavailable when the screen is locked
|
||||
// settingsItem.visible = Main.sessionMode.allowSettings;
|
||||
// this.menu._settingsActions[Me.uuid] = settingsItem;
|
||||
|
||||
this.connectObject(
|
||||
"clicked",
|
||||
() => {
|
||||
let mode: AuraEffect | undefined;
|
||||
if (this._dbus_aura.current_aura_mode == AuraModeNum.Static) {
|
||||
mode = this._dbus_aura.aura_modes.get(this._last_mode);
|
||||
} else {
|
||||
mode = this._dbus_aura.aura_modes.get(AuraModeNum.Static);
|
||||
}
|
||||
if (mode != undefined) {
|
||||
this._dbus_aura.setLedMode(mode);
|
||||
this.sync();
|
||||
}
|
||||
},
|
||||
this,
|
||||
);
|
||||
|
||||
this._dbus_aura.notifyAuraModeSubscribers.push(this);
|
||||
this.sync();
|
||||
|
||||
addQuickSettingsItems([this]);
|
||||
}
|
||||
|
||||
sync() {
|
||||
const checked = this._dbus_aura.current_aura_mode != AuraModeNum.Static;
|
||||
this.title = this._dbus_aura.current_aura_mode;
|
||||
if (
|
||||
this._last_mode != this._dbus_aura.current_aura_mode &&
|
||||
this._dbus_aura.current_aura_mode != AuraModeNum.Static
|
||||
) {
|
||||
this._last_mode = this._dbus_aura.current_aura_mode;
|
||||
}
|
||||
|
||||
if (this.checked !== checked) this.set({ checked });
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -1,216 +0,0 @@
|
||||
import { Extension, gettext as _ } from "@girs/gnome-shell/extensions/extension";
|
||||
import { quickSettings, popupMenu } from "@girs/gnome-shell/ui";
|
||||
import { GObject } from "@girs/gobject-2.0";
|
||||
|
||||
import { DbusBase } from "../../modules/dbus_proxy";
|
||||
|
||||
import { addQuickSettingsItems } from "../helpers";
|
||||
|
||||
import * as AsusExtension from "../../extension";
|
||||
import * as platform from "../../bindings/platform";
|
||||
import { uuid } from "../../extension";
|
||||
import { AsusMenuToggle } from "../rog_menu_toggle";
|
||||
|
||||
export const FeatureMenuToggle = GObject.registerClass(
|
||||
class FeatureMenuToggle extends quickSettings.QuickMenuToggle {
|
||||
private dbus_platform: DbusBase;
|
||||
private dbus_anime: DbusBase;
|
||||
private last_selection = "mini-led";
|
||||
private supported_properties!: platform.Properties;
|
||||
private supported_interfaces: string[] = [];
|
||||
|
||||
private miniLed?: typeof AsusMenuToggle;
|
||||
private panelOd?: typeof AsusMenuToggle;
|
||||
private animeDisplayPower?: typeof AsusMenuToggle;
|
||||
private animePowersaveAnim?: typeof AsusMenuToggle;
|
||||
_itemsSection: popupMenu.PopupMenuSection;
|
||||
|
||||
constructor(dbus_platform: DbusBase, dbus_anime: DbusBase) {
|
||||
super({
|
||||
label: "Laptop",
|
||||
toggle_mode: true,
|
||||
icon_name: "selection-mode-symbolic",
|
||||
});
|
||||
this.label = "Laptop";
|
||||
this.title = "Laptop";
|
||||
this.dbus_platform = dbus_platform;
|
||||
this.dbus_anime = dbus_anime;
|
||||
|
||||
this.menu.setHeader("selection-mode-symbolic", "Laptop features");
|
||||
|
||||
this.last_selection = Extension.lookupByUUID(AsusExtension.uuid)
|
||||
?.getSettings()
|
||||
.get_string("primary-quickmenu-toggle")!;
|
||||
|
||||
this.supported_interfaces = this.dbus_platform?.proxy.SupportedInterfacesSync()[0];
|
||||
this.supported_properties = this.dbus_platform?.proxy.SupportedPropertiesSync()[0];
|
||||
|
||||
// TODO: temporary block
|
||||
if (this.last_selection == "mini-led" && !this.supported_properties.includes("MiniLed")) {
|
||||
this.last_selection = "panel-od";
|
||||
} else if (
|
||||
this.last_selection == "panel-od" &&
|
||||
!this.supported_properties.includes("PanelOd")
|
||||
) {
|
||||
this.last_selection = "anime-power";
|
||||
} else if (
|
||||
this.last_selection == "anime-power" &&
|
||||
!this.supported_interfaces.includes("Anime")
|
||||
) {
|
||||
this.last_selection = "mini-led";
|
||||
} else if (this.last_selection.length == 0) {
|
||||
this.last_selection = "panel-od";
|
||||
}
|
||||
|
||||
// AsusExtension.extension._settings.connect('changed::primary-quickmenu-toggle', this.sync);
|
||||
Extension.lookupByUUID(uuid)
|
||||
?.getSettings()
|
||||
.set_string("primary-quickmenu-toggle", this.last_selection);
|
||||
|
||||
this._itemsSection = new popupMenu.PopupMenuSection();
|
||||
if (this.supported_properties.includes("MiniLed")) {
|
||||
if (this.miniLed == null) {
|
||||
this.miniLed = new AsusMenuToggle(
|
||||
this.dbus_platform,
|
||||
"MiniLed",
|
||||
"mini-led-enabled",
|
||||
"Mini-LED Enabled",
|
||||
);
|
||||
this._itemsSection.addMenuItem(this.miniLed, 0);
|
||||
this.miniLed.toggle_callback = () => {
|
||||
this.last_selection = "mini-led";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (this.supported_properties.includes("PanelOd")) {
|
||||
if (this.panelOd == null) {
|
||||
this.panelOd = new AsusMenuToggle(
|
||||
this.dbus_platform,
|
||||
"PanelOd",
|
||||
"panel-od-enabled",
|
||||
"Panel Overdrive Enabled",
|
||||
);
|
||||
this._itemsSection.addMenuItem(this.panelOd, 1);
|
||||
this.panelOd.toggle_callback = () => {
|
||||
this.last_selection = "panel-od";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (this.supported_interfaces.includes("Anime")) {
|
||||
if (this.animeDisplayPower == null) {
|
||||
this.animeDisplayPower = new AsusMenuToggle(
|
||||
this.dbus_anime,
|
||||
"EnableDisplay",
|
||||
"anime-power",
|
||||
"AniMe Display Enabled",
|
||||
);
|
||||
this._itemsSection.addMenuItem(this.animeDisplayPower, 2);
|
||||
this.animeDisplayPower.toggle_callback = () => {
|
||||
this.last_selection = "anime-power";
|
||||
};
|
||||
}
|
||||
|
||||
if (this.animePowersaveAnim == null) {
|
||||
this.animePowersaveAnim = new AsusMenuToggle(
|
||||
this.dbus_anime,
|
||||
"BuiltinsEnabled",
|
||||
"anime-builtins",
|
||||
"AniMe Built-in Animations",
|
||||
);
|
||||
this._itemsSection.addMenuItem(this.animePowersaveAnim, 3);
|
||||
this.animePowersaveAnim.toggle_callback = () => {
|
||||
this.last_selection = "anime-builtins";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
this.connectObject(
|
||||
"clicked",
|
||||
() => {
|
||||
this._toggle();
|
||||
},
|
||||
this,
|
||||
);
|
||||
|
||||
this.menu.addMenuItem(this._itemsSection, 0);
|
||||
|
||||
this.dbus_platform?.proxy.connect("g-properties-changed", (_proxy, changed, invalidated) => {
|
||||
//const properties = changed.deepUnpack();
|
||||
this.sync();
|
||||
});
|
||||
|
||||
this.dbus_anime?.proxy.connect("g-properties-changed", (_proxy, changed, invalidated) => {
|
||||
//const properties = changed.deepUnpack();
|
||||
this.sync();
|
||||
});
|
||||
|
||||
// // Add an entry-point for more extension._settings
|
||||
// this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
// const settingsItem = this.menu.addAction("More Settings",
|
||||
// () => ExtensionUtils.openPrefs());
|
||||
// // Ensure the extension._settings are unavailable when the screen is locked
|
||||
// settingsItem.visible = Main.sessionMode.allowSettings;
|
||||
// this.menu._settingsActions[Me.uuid] = settingsItem;
|
||||
|
||||
this.sync();
|
||||
addQuickSettingsItems([this]);
|
||||
}
|
||||
|
||||
_toggle() {
|
||||
if (this.last_selection == "mini-led" && this.miniLed != null) {
|
||||
if (this.checked !== this.dbus_platform.proxy.MiniLed)
|
||||
this.dbus_platform.proxy.MiniLed = this.checked;
|
||||
}
|
||||
|
||||
if (this.last_selection == "panel-od" && this.panelOd != null) {
|
||||
if (this.checked !== this.dbus_platform.proxy.PanelOd) {
|
||||
this.dbus_platform.proxy.PanelOd = this.checked;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.last_selection == "anime-power" && this.animeDisplayPower != null) {
|
||||
if (this.checked !== this.dbus_anime.proxy.EnableDisplay)
|
||||
this.dbus_anime.proxy.EnableDisplay = this.checked;
|
||||
}
|
||||
|
||||
if (this.last_selection == "anime-builtins" && this.animePowersaveAnim != null) {
|
||||
if (this.checked !== this.dbus_anime.proxy.BuiltinsEnabled)
|
||||
this.dbus_anime.proxy.BuiltinsEnabled = this.checked;
|
||||
}
|
||||
}
|
||||
|
||||
sync() {
|
||||
let checked = false;
|
||||
if (this.last_selection == "mini-led" && this.miniLed != null) {
|
||||
this.title = this.miniLed.title;
|
||||
checked = this.dbus_platform.proxy.MiniLed;
|
||||
}
|
||||
|
||||
if (this.last_selection == "panel-od" && this.panelOd != null) {
|
||||
this.title = this.panelOd.title;
|
||||
checked = this.dbus_platform.proxy.PanelOd;
|
||||
}
|
||||
|
||||
if (this.last_selection == "anime-power" && this.animeDisplayPower != null) {
|
||||
this.title = this.animeDisplayPower.title;
|
||||
checked = this.dbus_anime.proxy.EnableDisplay;
|
||||
}
|
||||
|
||||
if (this.last_selection == "anime-builtins" && this.animePowersaveAnim != null) {
|
||||
this.title = this.animePowersaveAnim.title;
|
||||
checked = this.dbus_anime.proxy.BuiltinsEnabled;
|
||||
}
|
||||
|
||||
// if (this.animePowersaveAnim != null) {
|
||||
// }
|
||||
|
||||
if (this.checked !== checked) this.set({ checked });
|
||||
}
|
||||
|
||||
destroy() {
|
||||
// this.panelOd?.destroy();
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -1,26 +0,0 @@
|
||||
import { Extension, gettext as _ } from "@girs/gnome-shell/extensions/extension";
|
||||
import { quickSettings, main } from "@girs/gnome-shell/ui";
|
||||
import { Gio } from "@girs/gio-2.0";
|
||||
import { GObject } from "@girs/gobject-2.0";
|
||||
import { uuid } from "../extension";
|
||||
//import { DbusBase } from '../dbus_proxy';
|
||||
|
||||
export const AsusIndicator = GObject.registerClass(
|
||||
class AsusIndicator extends quickSettings.SystemIndicator {
|
||||
private _indicator: any;
|
||||
private _settings: Gio.Settings | undefined;
|
||||
|
||||
constructor(icon_name: string, setting_name: string) {
|
||||
super();
|
||||
// Create an icon for the indicator
|
||||
this._indicator = this._addIndicator();
|
||||
this._indicator.icon_name = icon_name;
|
||||
|
||||
// Showing an indicator when the feature is enabled
|
||||
this._settings = Extension.lookupByUUID(uuid)?.getSettings();
|
||||
this._settings?.bind(setting_name, this._indicator, "visible", Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
main.panel.statusArea.quickSettings.addExternalIndicator(this);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -1,50 +0,0 @@
|
||||
import { popupMenu } from "@girs/gnome-shell/ui";
|
||||
import { GObject } from "@girs/gobject-2.0";
|
||||
import { DbusBase } from "./dbus_proxy";
|
||||
|
||||
export const AsusMenuToggle = GObject.registerClass(
|
||||
class AsusMenuToggle extends popupMenu.PopupSwitchMenuItem {
|
||||
public title: string = "";
|
||||
dbus!: DbusBase;
|
||||
prop_name: string = "";
|
||||
public toggle_callback = () => {};
|
||||
|
||||
constructor(dbus: DbusBase, prop_name: string, setting: string, title: string) {
|
||||
super(title, true);
|
||||
this.prop_name = prop_name;
|
||||
this.dbus = dbus;
|
||||
this.title = title;
|
||||
|
||||
this.dbus?.proxy.connect("g-properties-changed", (_proxy, changed, invalidated) => {
|
||||
const properties = changed.deepUnpack();
|
||||
// .find() fails on some shit for some reason
|
||||
for (const v of Object.entries(properties)) {
|
||||
if (v[0] == this.prop_name) {
|
||||
this.sync();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.connectObject("toggled", () => this._toggleMode(), this);
|
||||
|
||||
this.connect("destroy", () => {
|
||||
this.destroy();
|
||||
});
|
||||
|
||||
this.sync();
|
||||
}
|
||||
|
||||
_toggleMode() {
|
||||
// hacky shit, index to get base object property and set it
|
||||
const state = this.dbus.proxy[this.prop_name];
|
||||
if (this.state !== state) this.dbus.proxy[this.prop_name] = this.state;
|
||||
this.toggle_callback();
|
||||
}
|
||||
|
||||
sync() {
|
||||
const state = this.dbus.proxy[this.prop_name];
|
||||
if (this.state !== state) this.setToggleState(state);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -1,64 +0,0 @@
|
||||
import { Extension, gettext as _ } from "@girs/gnome-shell/extensions/extension";
|
||||
import { addQuickSettingsItems } from "./helpers";
|
||||
import { quickSettings } from "@girs/gnome-shell/ui";
|
||||
import { Gio } from "@girs/gio-2.0";
|
||||
import { GObject } from "@girs/gobject-2.0";
|
||||
import { uuid } from "../extension";
|
||||
import { DbusBase } from "./dbus_proxy";
|
||||
|
||||
export const AsusQuickToggle = GObject.registerClass(
|
||||
class AsusQuickToggle extends quickSettings.QuickToggle {
|
||||
dbus!: DbusBase;
|
||||
prop_name: string = "";
|
||||
public toggle_callback = () => {};
|
||||
|
||||
constructor(dbus: DbusBase, prop_name: string, setting: string, title: string) {
|
||||
super({
|
||||
label: title,
|
||||
icon_name: "selection-mode-symbolic",
|
||||
toggle_mode: true,
|
||||
});
|
||||
this.prop_name = prop_name;
|
||||
this.label = title;
|
||||
this.dbus = dbus;
|
||||
|
||||
this.dbus?.proxy.connect("g-properties-changed", (_proxy, changed, invalidated) => {
|
||||
const properties = changed.deepUnpack();
|
||||
// .find() fails on some shit for some reason
|
||||
for (const v of Object.entries(properties)) {
|
||||
if (v[0] == this.prop_name) {
|
||||
const checked = v[1].unpack();
|
||||
if (this.checked !== checked) this.checked = checked;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.connectObject("clicked", () => this._toggleMode(), this);
|
||||
|
||||
this.connect("destroy", () => {
|
||||
this.destroy();
|
||||
});
|
||||
|
||||
Extension.lookupByUUID(uuid)
|
||||
?.getSettings()
|
||||
.bind(setting, this, "checked", Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
this.sync();
|
||||
|
||||
addQuickSettingsItems([this]);
|
||||
}
|
||||
|
||||
_toggleMode() {
|
||||
// hacky shit, index to get base object property and set it
|
||||
const checked = this.dbus.proxy[this.prop_name];
|
||||
if (this.checked !== checked) this.dbus.proxy[this.prop_name] = this.checked;
|
||||
this.toggle_callback();
|
||||
}
|
||||
|
||||
sync() {
|
||||
const checked = this.dbus.proxy[this.prop_name];
|
||||
if (this.checked !== checked) this.set({ checked });
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -1,75 +0,0 @@
|
||||
import { Extension, gettext as _ } from "@girs/gnome-shell/extensions/extension";
|
||||
import { addQuickSettingsItems } from "./helpers";
|
||||
import { quickSettings } from "@girs/gnome-shell/ui";
|
||||
import { Gio } from "@girs/gio-2.0";
|
||||
import { GObject } from "@girs/gobject-2.0";
|
||||
import { uuid } from "../extension";
|
||||
import { DbusBase } from "./dbus_proxy";
|
||||
|
||||
export const AsusSlider = GObject.registerClass(
|
||||
class AsusSlider extends quickSettings.QuickSlider {
|
||||
private dbus: DbusBase;
|
||||
private settings: any = undefined;
|
||||
private setting = "";
|
||||
private prop_name = "";
|
||||
|
||||
constructor(dbus: DbusBase, prop_name: string, setting: string, title: string) {
|
||||
super({
|
||||
label: title,
|
||||
icon_name: "selection-mode-symbolic",
|
||||
});
|
||||
this.label = title;
|
||||
this.dbus = dbus;
|
||||
this.setting = setting;
|
||||
this.prop_name = prop_name;
|
||||
this.settings = Extension.lookupByUUID(uuid)?.getSettings();
|
||||
|
||||
this._sliderChangedId = this.slider.connect("drag-end", this._onSliderChanged.bind(this));
|
||||
|
||||
// Binding the slider to a GSettings key
|
||||
|
||||
this.settings.connect(`changed::${this.setting}`, this._onSettingsChanged.bind(this));
|
||||
|
||||
// Set an accessible name for the slider
|
||||
this.slider.accessible_name = title;
|
||||
|
||||
this.dbus?.proxy.connect("g-properties-changed", (_proxy, changed, invalidated) => {
|
||||
const properties = changed.deepUnpack();
|
||||
// .find() fails on some shit for some reason
|
||||
for (const v of Object.entries(properties)) {
|
||||
if (v[0] == this.prop_name) {
|
||||
const checked = v[1].unpack();
|
||||
this._sync();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this._sync();
|
||||
this._onSettingsChanged();
|
||||
|
||||
addQuickSettingsItems([this], 2);
|
||||
}
|
||||
|
||||
_onSettingsChanged() {
|
||||
// Prevent the slider from emitting a change signal while being updated
|
||||
this.slider.block_signal_handler(this._sliderChangedId);
|
||||
this.slider.value = this.settings.get_uint(this.setting) / 100.0;
|
||||
this.slider.unblock_signal_handler(this._sliderChangedId);
|
||||
}
|
||||
|
||||
_onSliderChanged() {
|
||||
// Assuming our GSettings holds values between 0..100, adjust for the
|
||||
// slider taking values between 0..1
|
||||
const percent = Math.floor(this.slider.value * 100);
|
||||
const stored = Math.floor(this.settings.get_uint(this.setting) / 100.0);
|
||||
if (this.slider.value !== stored) this.dbus.proxy[this.prop_name] = percent;
|
||||
this.settings.set_uint(this.setting, percent);
|
||||
}
|
||||
|
||||
_sync() {
|
||||
const value = this.dbus.proxy[this.prop_name];
|
||||
if (this.slider.value !== value / 100) this.settings.set_uint(this.setting, value);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
// "extends": "@tsconfig/strictest/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNext"],
|
||||
"types": [],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"strict": true,
|
||||
"allowJs": true,
|
||||
"paths": {},
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"files": ["./src/extension.ts"],
|
||||
"include": ["src/*.ts"],
|
||||
"exclude": [".ts-for-girrc.js", ".eslintrc.cjs"]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,13 +20,14 @@
|
||||
%global debug_package %{nil}
|
||||
%endif
|
||||
|
||||
%global rpm_dkms_opt 1
|
||||
%define specrelease %{?dist}
|
||||
%define pkg_release 3%{specrelease}
|
||||
|
||||
# Use hardening ldflags.
|
||||
%global rustflags -Clink-arg=-Wl,-z,relro,-z,now
|
||||
Name: asusctl
|
||||
Version: 4.7.0
|
||||
Release: 2
|
||||
Version: 6.0.7
|
||||
Release: %{pkg_release}
|
||||
Summary: Control fan speeds, LEDs, graphics modes, and charge levels for ASUS notebooks
|
||||
License: MPLv2
|
||||
|
||||
@@ -34,8 +35,8 @@ Group: System Environment/Kernel
|
||||
|
||||
URL: https://gitlab.com/asus-linux/asusctl
|
||||
Source: %{name}-%{version}.tar.gz
|
||||
Source1: vendor-%{name}-%{version}.tar.gz
|
||||
Source2: cargo_config
|
||||
Source1: vendor_%{name}_%{version}.tar.xz
|
||||
Source2: cargo-config
|
||||
|
||||
BuildRequires: cargo
|
||||
BuildRequires: rust-packaging
|
||||
@@ -44,12 +45,20 @@ BuildRequires: clang-devel
|
||||
BuildRequires: cmake
|
||||
BuildRequires: rust
|
||||
BuildRequires: rust-std-static
|
||||
BuildRequires: pkgconfig(expat)
|
||||
BuildRequires: pkgconfig(gbm)
|
||||
BuildRequires: pkgconfig(dbus-1)
|
||||
BuildRequires: pkgconfig(libdrm)
|
||||
BuildRequires: pkgconfig(libinput)
|
||||
BuildRequires: pkgconfig(libseat)
|
||||
BuildRequires: pkgconfig(libudev)
|
||||
BuildRequires: pkgconfig(xkbcommon)
|
||||
BuildRequires: pkgconfig(libzstd)
|
||||
BuildRequires: pkgconfig(gtk+-3.0)
|
||||
BuildRequires: pkgconfig(gdk-3.0)
|
||||
BuildRequires: desktop-file-utils
|
||||
Requires: libappindicator-gtk3
|
||||
|
||||
# expat-devel pcre2-devel
|
||||
|
||||
%description
|
||||
asus-nb-ctrl is a utility for Linux to control many aspects of various
|
||||
@@ -67,9 +76,10 @@ A one-stop-shop GUI tool for asusd/asusctl. It aims to provide most controls,
|
||||
a notification service, and ability to run in the background.
|
||||
|
||||
%prep
|
||||
# %setup -D -T -a 1 -c -n %{name}-%{version}/vendor
|
||||
# %setup -D -T -a 0 -c
|
||||
%autosetup
|
||||
%setup -D -T -a 1 -c -n %{name}-%{version}/vendor
|
||||
cd ..
|
||||
%setup -D -T -a 1
|
||||
|
||||
mv Cargo.lock{,.bak}
|
||||
%cargo_prep
|
||||
@@ -86,7 +96,7 @@ export RUSTFLAGS="%{rustflags}"
|
||||
export RUSTFLAGS="%{rustflags}"
|
||||
mkdir -p "%{buildroot}/%{_bindir}" "%{buildroot}%{_docdir}"
|
||||
%make_install
|
||||
|
||||
|
||||
install -D -m 0644 README.md %{buildroot}/%{_docdir}/%{name}/README.md
|
||||
install -D -m 0644 rog-anime/README.md %{buildroot}/%{_docdir}/%{name}/README-anime.md
|
||||
install -D -m 0644 rog-anime/data/diagonal-template.png %{buildroot}/%{_docdir}/%{name}/diagonal-template.png
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
[package]
|
||||
name = "dmi_id"
|
||||
edition = "2021"
|
||||
license.workspace = true
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
log.workspace = true
|
||||
udev.workspace = true
|
||||
udev.workspace = true
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 47 KiB |
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<body>
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
window.setTimeout('window.location="room4doom/index.html"; ', 0);
|
||||
// -->
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 35 KiB |
BIN
extra/system.png
BIN
extra/system.png
Binary file not shown.
|
Before Width: | Height: | Size: 50 KiB |
@@ -1,15 +1,15 @@
|
||||
[package]
|
||||
name = "rog_anime"
|
||||
license = "MPL-2.0"
|
||||
license.workspace = true
|
||||
version.workspace = true
|
||||
readme = "README.md"
|
||||
authors = ["Luke <luke@ljones.dev>"]
|
||||
repository = "https://gitlab.com/asus-linux/asus-nb-ctrl"
|
||||
homepage = "https://gitlab.com/asus-linux/asus-nb-ctrl"
|
||||
readme.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
edition.workspace = true
|
||||
documentation = "https://docs.rs/rog-anime"
|
||||
description = "Types useful for translating images and other data for display on the ASUS AniMe Matrix display"
|
||||
keywords = ["ROG", "ASUS", "AniMe"]
|
||||
edition = "2021"
|
||||
exclude = ["data"]
|
||||
|
||||
[features]
|
||||
@@ -38,4 +38,7 @@ zbus = { workspace = true, optional = true }
|
||||
dmi_id = { path = "../dmi-id", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
cargo-husky.workspace = true
|
||||
cargo-husky.workspace = true
|
||||
|
||||
[package.metadata.cargo-machete]
|
||||
ignored = ["serde"]
|
||||
|
||||
@@ -62,7 +62,7 @@ pub enum AnimeType {
|
||||
GA401,
|
||||
GA402,
|
||||
GU604,
|
||||
Unknown,
|
||||
Unsupported,
|
||||
}
|
||||
|
||||
impl FromStr for AnimeType {
|
||||
@@ -73,7 +73,7 @@ impl FromStr for AnimeType {
|
||||
"ga401" | "GA401" => Self::GA401,
|
||||
"ga402" | "GA402" => Self::GA402,
|
||||
"gu604" | "GU604" => Self::GU604,
|
||||
_ => Self::Unknown,
|
||||
_ => Self::Unsupported,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ impl TryFrom<AnimeDataBuffer> for AnimePacketType {
|
||||
|
||||
let mut buffers = match anime.anime {
|
||||
AnimeType::GA401 => vec![[0; 640]; 2],
|
||||
AnimeType::GA402 | AnimeType::GU604 | AnimeType::Unknown => vec![[0; 640]; 3],
|
||||
AnimeType::GA402 | AnimeType::GU604 | AnimeType::Unsupported => vec![[0; 640]; 3],
|
||||
};
|
||||
|
||||
for (idx, chunk) in anime.data.as_slice().chunks(PANE_LEN).enumerate() {
|
||||
@@ -176,7 +176,7 @@ impl TryFrom<AnimeDataBuffer> for AnimePacketType {
|
||||
|
||||
if matches!(
|
||||
anime.anime,
|
||||
AnimeType::GA402 | AnimeType::GU604 | AnimeType::Unknown
|
||||
AnimeType::GA402 | AnimeType::GU604 | AnimeType::Unsupported
|
||||
) {
|
||||
buffers[2][..7].copy_from_slice(&USB_PREFIX3);
|
||||
}
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
|
||||
use log::error;
|
||||
|
||||
use crate::data::AnimeDataBuffer;
|
||||
use crate::error::{AnimeError, Result};
|
||||
use crate::AnimeType;
|
||||
|
||||
/// Mostly intended to be used with ASUS gifs, but can be used for other
|
||||
/// purposes (like images)
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct AnimeDiagonal(AnimeType, Vec<Vec<u8>>, Option<Duration>);
|
||||
|
||||
impl AnimeDiagonal {
|
||||
@@ -49,7 +51,10 @@ impl AnimeDiagonal {
|
||||
bright: f32,
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
let data = std::fs::read(path)?;
|
||||
let data = std::fs::read(path).map_err(|e| {
|
||||
error!("Could not open {path:?}: {e:?}");
|
||||
e
|
||||
})?;
|
||||
let data = std::io::Cursor::new(data);
|
||||
let decoder = png_pong::Decoder::new(data)?.into_steps();
|
||||
let png_pong::Step { raster, delay: _ } = decoder.last().ok_or(AnimeError::NoFrames)??;
|
||||
|
||||
@@ -4,6 +4,7 @@ use std::path::Path;
|
||||
use std::time::Duration;
|
||||
|
||||
use glam::Vec2;
|
||||
use log::error;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::error::{AnimeError, Result};
|
||||
@@ -107,7 +108,10 @@ impl AnimeGif {
|
||||
// Configure the decoder such that it will expand the image to RGBA.
|
||||
decoder.set_color_output(gif::ColorOutput::RGBA);
|
||||
// Read the file header
|
||||
let file = File::open(file_name)?;
|
||||
let file = File::open(file_name).map_err(|e| {
|
||||
error!("Could not open {file_name:?}: {e:?}");
|
||||
e
|
||||
})?;
|
||||
let mut decoder = decoder.read_info(file)?;
|
||||
|
||||
let mut frames = Vec::default();
|
||||
@@ -186,12 +190,14 @@ impl AnimeGif {
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
let mut frames = Vec::new();
|
||||
|
||||
let mut decoder = gif::DecodeOptions::new();
|
||||
// Configure the decoder such that it will expand the image to RGBA.
|
||||
decoder.set_color_output(gif::ColorOutput::RGBA);
|
||||
// Read the file header
|
||||
let file = File::open(file_name)?;
|
||||
let file = File::open(file_name).map_err(|e| {
|
||||
error!("Could not open {file_name:?}: {e:?}");
|
||||
e
|
||||
})?;
|
||||
let mut decoder = decoder.read_info(file)?;
|
||||
|
||||
let height = decoder.height();
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::path::Path;
|
||||
|
||||
pub use glam::Vec2;
|
||||
use glam::{Mat3, Vec3};
|
||||
use log::error;
|
||||
|
||||
use crate::data::AnimeDataBuffer;
|
||||
use crate::error::{AnimeError, Result};
|
||||
@@ -421,7 +422,10 @@ impl AnimeImage {
|
||||
bright: f32,
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
let data = std::fs::read(path)?;
|
||||
let data = std::fs::read(path).map_err(|e| {
|
||||
error!("Could not open {path:?}: {e:?}");
|
||||
e
|
||||
})?;
|
||||
let data = std::io::Cursor::new(data);
|
||||
let decoder = png_pong::Decoder::new(data)?.into_steps();
|
||||
let png_pong::Step { raster, delay: _ } = decoder.last().ok_or(AnimeError::NoFrames)??;
|
||||
|
||||
@@ -58,13 +58,25 @@ impl From<u8> for Brightness {
|
||||
fn from(v: u8) -> Brightness {
|
||||
match v {
|
||||
0 => Brightness::Off,
|
||||
2 => Brightness::Low,
|
||||
1 => Brightness::Low,
|
||||
3 => Brightness::High,
|
||||
_ => Brightness::Med,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for Brightness {
|
||||
fn from(v: i32) -> Brightness {
|
||||
(v as u8).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Brightness> for i32 {
|
||||
fn from(v: Brightness) -> i32 {
|
||||
v as i32
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
@@ -90,6 +102,22 @@ impl FromStr for AnimBooting {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for AnimBooting {
|
||||
fn from(value: i32) -> Self {
|
||||
match value {
|
||||
0 => Self::GlitchConstruction,
|
||||
1 => Self::StaticEmergence,
|
||||
_ => Self::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AnimBooting> for i32 {
|
||||
fn from(value: AnimBooting) -> Self {
|
||||
value as i32
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
@@ -115,6 +143,22 @@ impl FromStr for AnimAwake {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for AnimAwake {
|
||||
fn from(value: i32) -> Self {
|
||||
match value {
|
||||
0 => Self::BinaryBannerScroll,
|
||||
1 => Self::RogLogoGlitch,
|
||||
_ => Self::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AnimAwake> for i32 {
|
||||
fn from(value: AnimAwake) -> Self {
|
||||
value as i32
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
@@ -140,6 +184,22 @@ impl FromStr for AnimSleeping {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for AnimSleeping {
|
||||
fn from(value: i32) -> Self {
|
||||
match value {
|
||||
0 => Self::BannerSwipe,
|
||||
1 => Self::Starfield,
|
||||
_ => Self::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AnimSleeping> for i32 {
|
||||
fn from(value: AnimSleeping) -> Self {
|
||||
value as i32
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
@@ -165,13 +225,29 @@ impl FromStr for AnimShutdown {
|
||||
}
|
||||
}
|
||||
|
||||
/// `get_anime_type` is very broad, matching on part of the laptop board name
|
||||
/// only. For this reason `find_node()` must be used also to verify if the USB
|
||||
/// device is available.
|
||||
impl From<i32> for AnimShutdown {
|
||||
fn from(value: i32) -> Self {
|
||||
match value {
|
||||
0 => Self::GlitchOut,
|
||||
1 => Self::SeeYa,
|
||||
_ => Self::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AnimShutdown> for i32 {
|
||||
fn from(value: AnimShutdown) -> Self {
|
||||
value as i32
|
||||
}
|
||||
}
|
||||
|
||||
/// `get_maybe_anime_type` is very broad, matching on part of the laptop board
|
||||
/// name only. For this reason `find_node()` must be used also to verify if the
|
||||
/// USB device is available.
|
||||
///
|
||||
/// The currently known USB device is `19b6`.
|
||||
#[inline]
|
||||
pub fn get_anime_type() -> Result<AnimeType, AnimeError> {
|
||||
pub fn get_maybe_anime_type() -> Result<AnimeType, AnimeError> {
|
||||
let dmi = DMIID::new().map_err(|_| AnimeError::NoDevice)?; // TODO: better error
|
||||
let board_name = dmi.board_name;
|
||||
|
||||
@@ -182,8 +258,8 @@ pub fn get_anime_type() -> Result<AnimeType, AnimeError> {
|
||||
} else if board_name.contains("GU604V") {
|
||||
return Ok(AnimeType::GU604);
|
||||
}
|
||||
log::warn!("AniMe Matrix device found but not yet supported, will default to a GA402 layout");
|
||||
Ok(AnimeType::Unknown)
|
||||
log::warn!("AniMe Matrix device found but could be a slash");
|
||||
Ok(AnimeType::Unsupported)
|
||||
}
|
||||
|
||||
/// Get the two device initialization packets. These are required for device
|
||||
|
||||
@@ -29,4 +29,4 @@ typeshare.workspace = true
|
||||
ron = { version = "*", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
cargo-husky.workspace = true
|
||||
cargo-husky.workspace = true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
([
|
||||
(
|
||||
board_name: "FA506I",
|
||||
device_name: "FA506I",
|
||||
product_id: "",
|
||||
layout_name: "fa506i",
|
||||
basic_modes: [Static, Breathe, Strobe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -8,7 +9,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "FA506Q",
|
||||
device_name: "FA506Q",
|
||||
product_id: "",
|
||||
layout_name: "fa506i",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow],
|
||||
basic_zones: [],
|
||||
@@ -16,7 +18,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "FA507",
|
||||
device_name: "FA507",
|
||||
product_id: "",
|
||||
layout_name: "fa507",
|
||||
basic_modes: [Static, Breathe, Strobe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -24,7 +27,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "FX505D",
|
||||
device_name: "FX505",
|
||||
product_id: "",
|
||||
layout_name: "fx505d",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -32,15 +36,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "FX505G",
|
||||
layout_name: "fx505d",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "FX506H",
|
||||
device_name: "FX506",
|
||||
product_id: "",
|
||||
layout_name: "fa506i",
|
||||
basic_modes: [Static, Breathe, Strobe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -48,7 +45,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "FX506L",
|
||||
device_name: "FX507Z",
|
||||
product_id: "",
|
||||
layout_name: "fa506i",
|
||||
basic_modes: [Static, Breathe, Strobe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -56,15 +54,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "FX507Z",
|
||||
layout_name: "fa506i",
|
||||
basic_modes: [Static, Breathe, Strobe, Pulse],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "FX516P",
|
||||
device_name: "FX516P",
|
||||
product_id: "",
|
||||
layout_name: "fa506i",
|
||||
basic_modes: [Static, Breathe, Strobe],
|
||||
basic_zones: [],
|
||||
@@ -72,7 +63,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "FX705D",
|
||||
device_name: "FX705D",
|
||||
product_id: "",
|
||||
layout_name: "fx505d",
|
||||
basic_modes: [Static, Breathe, Strobe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -80,23 +72,26 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G512",
|
||||
device_name: "G512L",
|
||||
product_id: "",
|
||||
layout_name: "g512",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G512LV",
|
||||
layout_name: "ga401q",
|
||||
device_name: "G512LI",
|
||||
product_id: "",
|
||||
layout_name: "g512",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G513I",
|
||||
device_name: "G513I",
|
||||
product_id: "",
|
||||
layout_name: "g513i",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -104,39 +99,26 @@
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G513QE",
|
||||
device_name: "G513Q",
|
||||
product_id: "",
|
||||
layout_name: "g513i",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G513QM",
|
||||
layout_name: "g513i",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G513QR",
|
||||
device_name: "G513QR",
|
||||
product_id: "",
|
||||
layout_name: "g513i-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard],
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G513QY",
|
||||
layout_name: "g513i-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G513RC",
|
||||
device_name: "G513RC",
|
||||
product_id: "",
|
||||
layout_name: "g513i",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -144,15 +126,26 @@
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G513RM",
|
||||
layout_name: "g513i",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
device_name: "G513RS",
|
||||
product_id: "",
|
||||
layout_name: "g513i-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]),
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G513RW",
|
||||
device_name: "G513RW",
|
||||
product_id: "",
|
||||
layout_name: "g513i-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
device_name: "G531",
|
||||
product_id: "",
|
||||
layout_name: "g513i-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -160,23 +153,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G531",
|
||||
layout_name: "g513i-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G531",
|
||||
layout_name: "g513i-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G531GD",
|
||||
device_name: "G531GD",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -184,7 +162,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G531GT",
|
||||
device_name: "G531GT",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow],
|
||||
basic_zones: [],
|
||||
@@ -192,7 +171,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G531GU",
|
||||
device_name: "G531GU",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -200,7 +180,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G531GV",
|
||||
device_name: "G531GV",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -208,7 +189,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G531GW",
|
||||
device_name: "G531GW",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -216,7 +198,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G532",
|
||||
device_name: "G532",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -224,7 +207,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G533Q",
|
||||
device_name: "G533Q",
|
||||
product_id: "1866",
|
||||
layout_name: "g533q-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -232,7 +216,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G533Z",
|
||||
device_name: "G533Z",
|
||||
product_id: "",
|
||||
layout_name: "g533q-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -240,7 +225,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G614J",
|
||||
device_name: "G614J",
|
||||
product_id: "",
|
||||
layout_name: "g634j-per-key",
|
||||
basic_modes: [Static, Breathe, Pulse, Strobe, Rainbow],
|
||||
basic_zones: [],
|
||||
@@ -248,7 +234,8 @@
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G634J",
|
||||
device_name: "G634J",
|
||||
product_id: "",
|
||||
layout_name: "g634j-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -256,7 +243,8 @@
|
||||
power_zones: [Keyboard, Lightbar, Logo, RearGlow],
|
||||
),
|
||||
(
|
||||
board_name: "G712LI",
|
||||
device_name: "G712LI",
|
||||
product_id: "",
|
||||
layout_name: "gl503",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -264,7 +252,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G712LV",
|
||||
device_name: "G712LV",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -272,7 +261,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G712LW",
|
||||
device_name: "G712LW",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -280,7 +270,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G713IC",
|
||||
device_name: "G713IC",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -288,7 +279,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G713QM",
|
||||
device_name: "G713P",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -296,7 +288,17 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G713QR",
|
||||
device_name: "G713QM",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "G713QR",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -304,7 +306,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G713RC",
|
||||
device_name: "G713RC",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -312,7 +315,8 @@
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G713RM",
|
||||
device_name: "G713RM",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -320,7 +324,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G713RS",
|
||||
device_name: "G713RS",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -328,15 +333,17 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G713RW",
|
||||
device_name: "G713RW",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
basic_zones: [Key1, Key2, Key3, Key4, BarLeft, BarRight],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G731",
|
||||
device_name: "G731",
|
||||
product_id: "",
|
||||
layout_name: "g533q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -344,7 +351,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G731GT",
|
||||
device_name: "G731GT",
|
||||
product_id: "",
|
||||
layout_name: "g533q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow],
|
||||
basic_zones: [],
|
||||
@@ -352,7 +360,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G731GU",
|
||||
device_name: "G731GU",
|
||||
product_id: "",
|
||||
layout_name: "g533q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow],
|
||||
basic_zones: [],
|
||||
@@ -360,7 +369,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G731GV",
|
||||
device_name: "G731GV",
|
||||
product_id: "",
|
||||
layout_name: "g533q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -368,7 +378,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G731GW",
|
||||
device_name: "G731GW",
|
||||
product_id: "",
|
||||
layout_name: "g533q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -376,15 +387,17 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G733C",
|
||||
device_name: "G733C",
|
||||
product_id: "",
|
||||
layout_name: "g513i-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [Logo, BarLeft, BarRight],
|
||||
basic_zones: [],
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard],
|
||||
power_zones: [Keyboard, Lightbar, Logo, Lid],
|
||||
),
|
||||
(
|
||||
board_name: "G733PZ",
|
||||
device_name: "G733PZ",
|
||||
product_id: "",
|
||||
layout_name: "g733pz-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -392,7 +405,8 @@
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G733Q",
|
||||
device_name: "G733Q",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -400,7 +414,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G733Z",
|
||||
device_name: "G733Z",
|
||||
product_id: "",
|
||||
layout_name: "g513i-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -408,7 +423,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "G814JI",
|
||||
device_name: "G814J",
|
||||
product_id: "",
|
||||
layout_name: "g814ji-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -416,15 +432,8 @@
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G814JZ",
|
||||
layout_name: "g814ji-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
board_name: "G834JZ",
|
||||
device_name: "G834J",
|
||||
product_id: "",
|
||||
layout_name: "g814ji-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -432,7 +441,8 @@
|
||||
power_zones: [Keyboard, Lightbar, Logo, RearGlow],
|
||||
),
|
||||
(
|
||||
board_name: "GA401Q",
|
||||
device_name: "GA401I",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -440,31 +450,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GA402R",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse, Rainbow],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GA402X",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse, Rainbow],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GA503Q",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse, Rainbow, Strobe],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GA503QE",
|
||||
device_name: "GA401Q",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -472,7 +459,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GA503R",
|
||||
device_name: "GA402N",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse, Rainbow, Strobe],
|
||||
basic_zones: [],
|
||||
@@ -480,7 +468,71 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GL503",
|
||||
device_name: "GA402R",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse, Rainbow],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "GA402X",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse, Rainbow],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "GA402XV",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Comet],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "GA403U",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "GA503Q",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse, Rainbow, Strobe],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "GA503QE",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "GA503R",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse, Rainbow, Strobe],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "GL503",
|
||||
product_id: "",
|
||||
layout_name: "gl503",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -488,7 +540,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GL503V",
|
||||
device_name: "GL503V",
|
||||
product_id: "",
|
||||
layout_name: "gl503",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -496,7 +549,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GL504G",
|
||||
device_name: "GL504G",
|
||||
product_id: "",
|
||||
layout_name: "gl503",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4, Logo, BarLeft, BarRight],
|
||||
@@ -504,7 +558,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GL531",
|
||||
device_name: "GL531",
|
||||
product_id: "",
|
||||
layout_name: "g512",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -512,7 +567,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GL553VE",
|
||||
device_name: "GL553V",
|
||||
product_id: "",
|
||||
layout_name: "g533q",
|
||||
basic_modes: [Static, Breathe, Strobe],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -520,7 +576,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GL703G",
|
||||
device_name: "GL703G",
|
||||
product_id: "",
|
||||
layout_name: "gl503",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow],
|
||||
basic_zones: [],
|
||||
@@ -528,7 +585,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GM501G",
|
||||
device_name: "GM501G",
|
||||
product_id: "",
|
||||
layout_name: "fa507",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -536,7 +594,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GU502",
|
||||
device_name: "GU502",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -544,7 +603,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GU502G",
|
||||
device_name: "GU502L",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -552,15 +612,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GU502L",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GU502LU",
|
||||
device_name: "GU502LU",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -568,7 +621,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GU603H",
|
||||
device_name: "GU603H",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -576,7 +630,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GU603VV",
|
||||
device_name: "GU603V",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -584,7 +639,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GU603Z",
|
||||
device_name: "GU603Z",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -592,7 +648,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GU604V",
|
||||
device_name: "GU604V",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -600,7 +657,17 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GV301Q",
|
||||
device_name: "GU605M",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
advanced_type: Zoned([SingleZone]),
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "GV301Q",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -608,7 +675,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GV301V",
|
||||
device_name: "GV301V",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -616,7 +684,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GV301VIC",
|
||||
device_name: "GV301VIC",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -624,7 +693,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GV601R",
|
||||
device_name: "GV601R",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -632,7 +702,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GV601V",
|
||||
device_name: "GV601V",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -640,7 +711,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GV604V",
|
||||
device_name: "GV604V",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Strobe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -648,7 +720,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GX502",
|
||||
device_name: "GX502",
|
||||
product_id: "",
|
||||
layout_name: "gx502",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -656,7 +729,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GX531",
|
||||
device_name: "GX531",
|
||||
product_id: "",
|
||||
layout_name: "gx531-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
@@ -664,7 +738,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GX550L",
|
||||
device_name: "GX550L",
|
||||
product_id: "",
|
||||
layout_name: "gx531-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -672,7 +747,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GX551Q",
|
||||
device_name: "GX551Q",
|
||||
product_id: "",
|
||||
layout_name: "gx531-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -680,7 +756,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GX650P",
|
||||
device_name: "GX650P",
|
||||
product_id: "",
|
||||
layout_name: "gx531-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -688,7 +765,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GX701",
|
||||
device_name: "GX650R",
|
||||
product_id: "",
|
||||
layout_name: "gx531-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -696,7 +774,17 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GX703H",
|
||||
device_name: "GX701",
|
||||
product_id: "",
|
||||
layout_name: "gx531-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "GX703H",
|
||||
product_id: "",
|
||||
layout_name: "gx531-per-key",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
@@ -704,7 +792,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GZ301V",
|
||||
device_name: "GZ301V",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -712,7 +801,8 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "GZ301VIC",
|
||||
device_name: "GZ301VIC",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
@@ -720,7 +810,35 @@
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
board_name: "RC71L",
|
||||
device_name: "GZ301Z",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "GZ301Z",
|
||||
product_id: "18c6",
|
||||
layout_name: "",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [None],
|
||||
),
|
||||
(
|
||||
device_name: "GZ301Z",
|
||||
product_id: "1a30",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "RC71L",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
use crate::advanced::LedCode;
|
||||
|
||||
impl From<LedCode> for &str {
|
||||
fn from(k: LedCode) -> Self {
|
||||
(&k).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&LedCode> for &str {
|
||||
fn from(k: &LedCode) -> Self {
|
||||
#[allow(clippy::match_same_arms)]
|
||||
match k {
|
||||
LedCode::VolUp => "Volume Up",
|
||||
LedCode::VolDown => "Volume Down",
|
||||
LedCode::MicMute => "Mute Mic",
|
||||
LedCode::RogApp => "ROG",
|
||||
LedCode::RogFan => "Fan Control",
|
||||
LedCode::Esc => "Escape",
|
||||
LedCode::F1 => "F1",
|
||||
LedCode::F2 => "F2",
|
||||
LedCode::F3 => "F3",
|
||||
LedCode::F4 => "F4",
|
||||
LedCode::F5 => "F5",
|
||||
LedCode::F6 => "F6",
|
||||
LedCode::F7 => "F7",
|
||||
LedCode::F8 => "F8",
|
||||
LedCode::F9 => "F9",
|
||||
LedCode::F10 => "F10",
|
||||
LedCode::F11 => "F11",
|
||||
LedCode::F12 => "F12",
|
||||
LedCode::Del => "Delete",
|
||||
LedCode::Tilde => "Tilde",
|
||||
LedCode::N1 => "1",
|
||||
LedCode::N2 => "2",
|
||||
LedCode::N3 => "3",
|
||||
LedCode::N4 => "4",
|
||||
LedCode::N5 => "5",
|
||||
LedCode::N6 => "6",
|
||||
LedCode::N7 => "7",
|
||||
LedCode::N8 => "8",
|
||||
LedCode::N9 => "9",
|
||||
LedCode::N0 => "0",
|
||||
LedCode::Hyphen => "-",
|
||||
LedCode::Equals => "=",
|
||||
LedCode::Backspace => "Backspace",
|
||||
LedCode::Backspace3_1 => "Backspace LED 1",
|
||||
LedCode::Backspace3_2 => "Backspace LED 2",
|
||||
LedCode::Backspace3_3 => "Backspace LED 3",
|
||||
LedCode::Home => "Home",
|
||||
LedCode::Tab => "Tab",
|
||||
LedCode::Q => "Q",
|
||||
LedCode::W => "W",
|
||||
LedCode::E => "E",
|
||||
LedCode::R => "R",
|
||||
LedCode::T => "T",
|
||||
LedCode::Y => "Y",
|
||||
LedCode::U => "U",
|
||||
LedCode::I => "I",
|
||||
LedCode::O => "O",
|
||||
LedCode::P => "P",
|
||||
LedCode::LBracket => "[",
|
||||
LedCode::RBracket => "]",
|
||||
LedCode::BackSlash => "\\",
|
||||
LedCode::PgUp => "Page Up",
|
||||
LedCode::Caps => "Caps Lock",
|
||||
LedCode::A => "A",
|
||||
LedCode::S => "S",
|
||||
LedCode::D => "D",
|
||||
LedCode::F => "F",
|
||||
LedCode::G => "G",
|
||||
LedCode::H => "H",
|
||||
LedCode::J => "J",
|
||||
LedCode::K => "K",
|
||||
LedCode::L => "L",
|
||||
LedCode::SemiColon => ";",
|
||||
LedCode::Quote => "'",
|
||||
LedCode::Return => "Return",
|
||||
LedCode::Return3_1 => "Return LED 1",
|
||||
LedCode::Return3_2 => "Return LED 2",
|
||||
LedCode::Return3_3 => "Return LED 3",
|
||||
LedCode::PgDn => "Page Down",
|
||||
LedCode::LShift => "Left Shift",
|
||||
LedCode::LShift3_1 => "Left Shift LED 1",
|
||||
LedCode::LShift3_2 => "Left Shift LED 2",
|
||||
LedCode::LShift3_3 => "Left Shift LED 3",
|
||||
LedCode::Z => "Z",
|
||||
LedCode::X => "X",
|
||||
LedCode::C => "C",
|
||||
LedCode::V => "V",
|
||||
LedCode::B => "B",
|
||||
LedCode::N => "N",
|
||||
LedCode::M => "M",
|
||||
LedCode::Comma => ",",
|
||||
LedCode::Period => ".",
|
||||
LedCode::Star => "*",
|
||||
LedCode::NumPadDel => "Delete",
|
||||
LedCode::NumPadPlus => "+",
|
||||
LedCode::NumPadEnter => "Enter",
|
||||
LedCode::NumPadPause => "Pause",
|
||||
LedCode::NumPadPrtSc => "Print Screen",
|
||||
LedCode::NumPadHome => "Home",
|
||||
LedCode::NumLock => "Num-Lock",
|
||||
LedCode::FwdSlash => "/",
|
||||
LedCode::Rshift => "Right Shift",
|
||||
LedCode::Rshift3_1 => "Right Shift LED 1",
|
||||
LedCode::Rshift3_2 => "Right Shift LED 2",
|
||||
LedCode::Rshift3_3 => "Right Shift LED 3",
|
||||
LedCode::End => "End",
|
||||
LedCode::LCtrl => "Left Control",
|
||||
LedCode::LFn => "Left Fn",
|
||||
LedCode::Meta => "Meta",
|
||||
LedCode::LAlt => "Left Alt",
|
||||
LedCode::Spacebar => "Space",
|
||||
LedCode::Spacebar5_1 => "Space LED 1",
|
||||
LedCode::Spacebar5_2 => "Space LED 2",
|
||||
LedCode::Spacebar5_3 => "Space LED 3",
|
||||
LedCode::Spacebar5_4 => "Space LED 4",
|
||||
LedCode::Spacebar5_5 => "Space LED 5",
|
||||
LedCode::RAlt => "Right Alt",
|
||||
LedCode::PrtSc => "Print Screen",
|
||||
LedCode::RCtrl => "Right Control",
|
||||
LedCode::Pause => "Pause",
|
||||
LedCode::Up => "Up",
|
||||
LedCode::Down => "Down",
|
||||
LedCode::Left => "Left",
|
||||
LedCode::Right => "Right",
|
||||
LedCode::RFn => "Right Fn",
|
||||
LedCode::MediaPlay => "Media Play",
|
||||
LedCode::MediaStop => "Media Stop",
|
||||
LedCode::MediaNext => "Media Next",
|
||||
LedCode::MediaPrev => "Media Previous",
|
||||
LedCode::LidLogo => "Lid Logo",
|
||||
LedCode::LidLeft => "Lid Left",
|
||||
LedCode::LidRight => "Lid Right",
|
||||
LedCode::LightbarRight => "Lightbar Right",
|
||||
LedCode::LightbarRightCorner => "Lightbar Right Corner",
|
||||
LedCode::LightbarRightBottom => "Lightbar Right Bottom",
|
||||
LedCode::LightbarLeftBottom => "Lightbar Left Bottom",
|
||||
LedCode::LightbarLeftCorner => "Lightbar Left Corner",
|
||||
LedCode::LightbarLeft => "Lightbar Left",
|
||||
LedCode::Spacing | LedCode::Blocking => "",
|
||||
LedCode::SingleZone => "Single Zoned Keyboard",
|
||||
LedCode::ZonedKbLeft => "Left Zone (zone 1)",
|
||||
LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)",
|
||||
LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)",
|
||||
LedCode::ZonedKbRight => "Right Zone (zone 4)",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,98 +1,123 @@
|
||||
use std::env;
|
||||
|
||||
use dmi_id::DMIID;
|
||||
use log::{error, info, warn};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
use zbus::zvariant::{OwnedValue, Type, Value};
|
||||
|
||||
use crate::usb::AuraDevice;
|
||||
use crate::{AdvancedAuraType, AuraModeNum, AuraZone};
|
||||
use crate::keyboard::AdvancedAuraType;
|
||||
use crate::{AuraModeNum, AuraZone, PowerZones};
|
||||
|
||||
pub const ASUS_LED_MODE_CONF: &str = "/usr/share/asusd/aura_support.ron";
|
||||
pub const ASUS_LED_MODE_USER_CONF: &str = "/etc/asusd/asusd_user_ledmodes.ron";
|
||||
pub const ASUS_KEYBOARD_DEVICES: [AuraDevice; 8] = [
|
||||
AuraDevice::Tuf,
|
||||
AuraDevice::X1854,
|
||||
AuraDevice::X1869,
|
||||
AuraDevice::X1866,
|
||||
AuraDevice::X18c6,
|
||||
AuraDevice::X19b6,
|
||||
AuraDevice::X1a30,
|
||||
AuraDevice::X1abe,
|
||||
];
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct LedSupportFile(Vec<LaptopLedData>);
|
||||
|
||||
/// The powerr zones this laptop supports
|
||||
#[typeshare]
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
zvariant(signature = "u")
|
||||
)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Copy, Clone)]
|
||||
pub enum PowerZones {
|
||||
/// The logo on some laptop lids
|
||||
#[default]
|
||||
Logo = 0,
|
||||
/// The full keyboard (not zones)
|
||||
Keyboard = 1,
|
||||
/// The lightbar, typically on the front of the laptop
|
||||
Lightbar = 2,
|
||||
/// The leds that may be placed around the edge of the laptop lid
|
||||
Lid = 3,
|
||||
/// The led strip on the rear of some laptops
|
||||
RearGlow = 4,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct LaptopLedData {
|
||||
/// Found via `cat /sys/class/dmi/id/board_name`, e.g `GU603ZW`.
|
||||
/// The match doesn't have to be the complete model number as it is
|
||||
/// typically broken down such:
|
||||
pub struct LedSupportData {
|
||||
/// This can be many different types of name:
|
||||
/// - `/sys/class/dmi/id/board_name` (must use for laptops)
|
||||
/// - The device name from `lsusb`
|
||||
///
|
||||
/// The laptop board_name is found via `cat /sys/class/dmi/id/board_name`,
|
||||
/// e.g `GU603ZW`. The match doesn't have to be the complete model
|
||||
/// number as it is typically broken down such:
|
||||
/// - GU = product
|
||||
/// - 603 = model/platform
|
||||
/// - Z = variant/year or perhaps dGPU model (such as RTX 3xxx)
|
||||
/// - W = possibly dGPU model (such as RTX 3060Ti)
|
||||
pub board_name: String,
|
||||
///
|
||||
/// If using a device name the match is similar to the above where it can be
|
||||
/// partial, so `ASUSTek Computer, Inc. ROG STRIX Arion` can be `STRIX
|
||||
/// Arion` for short. Case insensitive.
|
||||
pub device_name: String,
|
||||
/// The product ID (usb only)
|
||||
/// Example of using a product ID is:
|
||||
/// ```ignore
|
||||
/// $ lsusb
|
||||
/// $ Bus 003 Device 003: ID 0b05:19b6 ASUSTek Computer, Inc. N-KEY Device
|
||||
/// ```
|
||||
/// here `19b6` is all that is required. Case insensitive.
|
||||
#[serde(default)]
|
||||
pub product_id: String,
|
||||
/// Keyboard or device LED layout, this is the name of the externally
|
||||
/// defined layout file. Optional, can be an empty string
|
||||
#[serde(default)]
|
||||
pub layout_name: String,
|
||||
/// If empty will default to `Static` mode
|
||||
pub basic_modes: Vec<AuraModeNum>,
|
||||
/// Available on some laptops. This is where the keyboard may be split in to
|
||||
/// 4 zones and may have a logo and lightbar.
|
||||
///
|
||||
/// Ignored if empty.
|
||||
#[serde(default)]
|
||||
pub basic_zones: Vec<AuraZone>,
|
||||
/// `Zoned` or `PerKey`.
|
||||
// TODO: remove and use layouts only
|
||||
#[serde(default)]
|
||||
pub advanced_type: AdvancedAuraType,
|
||||
/// If empty will default to `Keyboard` power zone
|
||||
pub power_zones: Vec<PowerZones>,
|
||||
}
|
||||
|
||||
impl LaptopLedData {
|
||||
pub fn get_data() -> Self {
|
||||
let dmi = DMIID::new().unwrap_or_default();
|
||||
impl LedSupportData {
|
||||
/// Find the data for the device. This function will check DMI info for
|
||||
/// matches against laptops first, then will proceed with matching the
|
||||
/// `device_name` if there are no DMI matches.
|
||||
pub fn get_data(product_id: &str) -> Self {
|
||||
let mut dmi = DMIID::new().unwrap_or_default();
|
||||
if let Ok(board_name) = env::var("BOARD_NAME") {
|
||||
dmi.board_name = board_name;
|
||||
}
|
||||
// let prod_family = dmi.product_family().expect("Could not get
|
||||
// product_family");
|
||||
|
||||
if let Some(modes) = LedSupportFile::load_from_supoprt_db() {
|
||||
if let Some(data) = modes.matcher(&dmi.board_name) {
|
||||
return data;
|
||||
}
|
||||
if let Some(data) = LedSupportFile::load_from_supoprt_db() {
|
||||
return data.match_device(&dmi.board_name, product_id);
|
||||
}
|
||||
info!("Using generic LED control for keyboard brightness only");
|
||||
LaptopLedData::default()
|
||||
info!("Using generic LED control for keyboard brightness only. No aura_support file found");
|
||||
let mut data = LedSupportData::default();
|
||||
data.power_zones.push(PowerZones::Keyboard);
|
||||
data
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct LedSupportFile(Vec<LedSupportData>);
|
||||
|
||||
impl LedSupportFile {
|
||||
pub fn get(&self) -> &[LaptopLedData] {
|
||||
pub fn get(&self) -> &[LedSupportData] {
|
||||
&self.0
|
||||
}
|
||||
|
||||
/// The list is stored in ordered format, so the iterator must be reversed
|
||||
/// to ensure we match to *whole names* first before doing a glob match
|
||||
pub fn matcher(self, board_name: &str) -> Option<LaptopLedData> {
|
||||
fn match_device(&self, device_name: &str, product_id: &str) -> LedSupportData {
|
||||
for config in self.0.iter().rev() {
|
||||
if board_name.contains(&config.board_name) {
|
||||
info!("LedSupport: Matched to {}", config.board_name);
|
||||
return Some(config.clone());
|
||||
if device_name.contains(&config.device_name) {
|
||||
info!("Matched to {}", config.device_name);
|
||||
if !config.product_id.is_empty() {
|
||||
info!("Checking product ID");
|
||||
if config.product_id == product_id {
|
||||
info!("Matched to {}", config.product_id);
|
||||
return config.clone();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return config.clone();
|
||||
}
|
||||
}
|
||||
None
|
||||
warn!(
|
||||
"the aura_support.ron file has no entry for this model: {device_name}, {product_id}. \
|
||||
Using a default"
|
||||
);
|
||||
LedSupportData {
|
||||
device_name: device_name.to_owned(),
|
||||
product_id: product_id.to_owned(),
|
||||
layout_name: "Default".to_owned(),
|
||||
basic_modes: vec![AuraModeNum::Static],
|
||||
basic_zones: vec![],
|
||||
advanced_type: AdvancedAuraType::None,
|
||||
power_zones: vec![PowerZones::Keyboard],
|
||||
}
|
||||
}
|
||||
|
||||
/// Load `LedSupportFile` from the `aura_support.ron` file at
|
||||
@@ -133,7 +158,7 @@ impl LedSupportFile {
|
||||
);
|
||||
}
|
||||
}
|
||||
data.0.sort_by(|a, b| a.board_name.cmp(&b.board_name));
|
||||
data.0.sort_by(|a, b| a.device_name.cmp(&b.device_name));
|
||||
|
||||
if loaded {
|
||||
return Some(data);
|
||||
@@ -152,16 +177,17 @@ mod tests {
|
||||
|
||||
use ron::ser::PrettyConfig;
|
||||
|
||||
use super::LaptopLedData;
|
||||
use crate::advanced::LedCode;
|
||||
use super::LedSupportData;
|
||||
use crate::aura_detection::{LedSupportFile, PowerZones};
|
||||
use crate::keyboard::{AdvancedAuraType, LedCode};
|
||||
// use crate::zoned::Zone;
|
||||
use crate::{AdvancedAuraType, AuraModeNum, AuraZone};
|
||||
use crate::{AuraModeNum, AuraZone};
|
||||
|
||||
#[test]
|
||||
fn check_data_parse() {
|
||||
let led = LaptopLedData {
|
||||
board_name: "Test".to_owned(),
|
||||
let led = LedSupportData {
|
||||
device_name: "Test".to_owned(),
|
||||
product_id: String::new(),
|
||||
layout_name: "ga401".to_owned(),
|
||||
basic_modes: vec![AuraModeNum::Static],
|
||||
basic_zones: vec![AuraZone::Key1, AuraZone::Logo, AuraZone::BarLeft],
|
||||
@@ -184,7 +210,8 @@ mod tests {
|
||||
|
||||
// Ensure the data is sorted
|
||||
let mut tmp_sort = tmp.clone();
|
||||
tmp_sort.0.sort_by(|a, b| a.board_name.cmp(&b.board_name));
|
||||
tmp_sort.0.sort_by(|a, b| a.product_id.cmp(&b.product_id));
|
||||
tmp_sort.0.sort_by(|a, b| a.device_name.cmp(&b.device_name));
|
||||
if tmp != tmp_sort {
|
||||
let sorted =
|
||||
ron::ser::to_string_pretty(&tmp_sort, PrettyConfig::new().depth_limit(2)).unwrap();
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
pub const LED_INIT1: [u8; 2] = [0x5d, 0xb9];
|
||||
pub const LED_INIT2: &str = "]ASUS Tech.Inc."; // ] == 0x5d
|
||||
pub const LED_INIT3: [u8; 6] = [0x5d, 0x05, 0x20, 0x31, 0, 0x08];
|
||||
pub const LED_INIT4: &str = "^ASUS Tech.Inc."; // ^ == 0x5e
|
||||
pub const LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08];
|
||||
|
||||
use std::fmt::Display;
|
||||
use std::str::FromStr;
|
||||
|
||||
@@ -67,6 +61,24 @@ impl From<LedBrightness> for u8 {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LedBrightness> for i32 {
|
||||
fn from(l: LedBrightness) -> Self {
|
||||
l as i32
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for LedBrightness {
|
||||
fn from(l: i32) -> Self {
|
||||
match l {
|
||||
0 => LedBrightness::Off,
|
||||
1 => LedBrightness::Low,
|
||||
2 => LedBrightness::Med,
|
||||
3 => LedBrightness::High,
|
||||
_ => LedBrightness::Med,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Copy, Deserialize, Serialize)]
|
||||
@@ -156,6 +168,26 @@ impl FromStr for Speed {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for Speed {
|
||||
fn from(value: i32) -> Self {
|
||||
match value {
|
||||
0 => Self::Low,
|
||||
2 => Self::High,
|
||||
_ => Self::Med,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Speed> for i32 {
|
||||
fn from(value: Speed) -> Self {
|
||||
match value {
|
||||
Speed::Low => 0,
|
||||
Speed::Med => 1,
|
||||
Speed::High => 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Speed> for u8 {
|
||||
fn from(s: Speed) -> u8 {
|
||||
match s {
|
||||
@@ -198,6 +230,23 @@ impl FromStr for Direction {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for Direction {
|
||||
fn from(value: i32) -> Self {
|
||||
match value {
|
||||
1 => Self::Left,
|
||||
2 => Self::Up,
|
||||
3 => Self::Down,
|
||||
_ => Self::Right,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Direction> for i32 {
|
||||
fn from(value: Direction) -> Self {
|
||||
value as i32
|
||||
}
|
||||
}
|
||||
|
||||
/// Enum of modes that convert to the actual number required by a USB HID packet
|
||||
#[typeshare]
|
||||
#[cfg_attr(
|
||||
@@ -292,6 +341,18 @@ impl From<u8> for AuraModeNum {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for AuraModeNum {
|
||||
fn from(mode: i32) -> Self {
|
||||
(mode as u8).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AuraModeNum> for i32 {
|
||||
fn from(value: AuraModeNum) -> Self {
|
||||
value as i32
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AuraEffect> for AuraModeNum {
|
||||
fn from(value: AuraEffect) -> Self {
|
||||
value.mode
|
||||
@@ -345,6 +406,27 @@ impl FromStr for AuraZone {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for AuraZone {
|
||||
fn from(value: i32) -> Self {
|
||||
match value {
|
||||
1 => Self::Key1,
|
||||
2 => Self::Key2,
|
||||
3 => Self::Key3,
|
||||
4 => Self::Key4,
|
||||
5 => Self::Logo,
|
||||
6 => Self::BarLeft,
|
||||
7 => Self::BarRight,
|
||||
_ => Self::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AuraZone> for i32 {
|
||||
fn from(value: AuraZone) -> Self {
|
||||
value as i32
|
||||
}
|
||||
}
|
||||
|
||||
/// Default factory modes structure. This easily converts to an USB HID packet
|
||||
/// with:
|
||||
/// ```rust
|
||||
@@ -352,7 +434,7 @@ impl FromStr for AuraZone {
|
||||
/// ```
|
||||
#[typeshare]
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||
pub struct AuraEffect {
|
||||
/// The effect type
|
||||
pub mode: AuraModeNum,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user