Compare commits

...

63 Commits

Author SHA1 Message Date
Luke Jones 5fb0e26331 Fix git losing the last set of fixes. Prep new release
Signed-off-by: Luke Jones <luke@ljones.dev>
2025-02-14 22:23:11 +13:00
Luke Jones 4dd29952c8 Fix the handling of of the kernel change from "quiet" to "low-power"
A coming kernel change will convert "quiet" to "low-power" due to how
platform_profile can now have multiple registered handlers.
(kernel 6.14 est)

Fixes #609
2025-02-14 20:02:08 +13:00
Luke Jones 2c006699f2 Reformat with trailing comma 2025-02-14 20:00:11 +13:00
Luke Jones 0bdf0474c9 Small error message fix 2025-02-14 20:00:11 +13:00
Kamo Kuma 66196ceb17 systemctl is-enabled can return 'linked' even if service is enabled. 2025-02-10 21:00:21 -05:00
Luke Jones b2726f3a67 Fix: charge control 2025-02-10 22:18:34 +13:00
Luke Jones 663f87d5e2 Checkpoint 2025-02-10 13:56:26 +13:00
Luke Jones 377bb4d6ad Merge branch 'private/Rohitrajak1807/G513RW-ledfix' into 'main'
Add ROG G513RW led cfgs

See merge request asus-linux/asusctl!217
2025-02-10 00:55:33 +00:00
Rohit Rajak 98e60db2da Add ROG G513RW led cfgs 2025-02-10 00:55:33 +00:00
Luke Jones 11ac46df11 Edit README.md 2025-02-08 02:39:30 +00:00
Luke Jones 05bec93644 Edit README.md 2025-02-08 02:33:08 +00:00
Luke Jones c77e7cf1ce Fix: correction to wrong matching function used for aura data find
Closes #607
2025-02-07 09:45:05 +13:00
Luke Jones d30f7dc2ea Merge branch 'main' into 'main'
feat (rog-aura): ASUS TUF FA617NS AURA Support

See merge request asus-linux/asusctl!214
2025-02-05 02:58:05 +00:00
Luke Jones 759606fca3 Merge branch 'aura' into 'main'
Update 'led-mode' -> 'aura' in example command.

See merge request asus-linux/asusctl!215
2025-02-05 02:57:38 +00:00
Luke Jones 25ed8bdeed Fix spelling mistake 2025-02-05 14:35:17 +13:00
Luke Jones de61a15b7a Prep 6.1.0 2025-02-04 18:52:55 +13:00
Luke Jones 16700e55f4 ROGCC: refactor many more parts of the PPT settings 2025-02-04 18:50:48 +13:00
Luke Jones 5833a011ce Merge branch 'g513rc-zonefix' into 'main'
Add basic zones for G513RC

See merge request asus-linux/asusctl!216
2025-02-03 04:08:29 +00:00
loystonpais 62577ee0e4 Add basic zones for G513RC 2025-02-03 07:36:32 +05:30
Luke Jones dac35996b1 Enable use of GAMESCOPE_WAYLAND_DISPLAY 2025-02-02 20:02:51 +13:00
Luke Jones 5c2bcad7c6 Various UI fixes 2025-02-01 20:31:09 +13:00
armdebug 81f6c18a24 Update 'led-mode' -> 'aura' in example command.
led-mode is renamed to aura in 19ffcf3376
2025-01-28 02:18:56 +05:30
riarumoda bcc3d42789 feat (rog-aura): ASUS TUF FA617NS AURA Support 2025-01-23 15:14:52 +08:00
Luke Jones 36c34cb3dd Merge branch 'fix/anime-animation-crash' into 'main'
fix: Use spawn instead of spawn_local in anime animation callback

Closes #588

See merge request asus-linux/asusctl!213
2025-01-22 02:05:04 +00:00
I-Al-Istannen 9b82b875f1 fix: Use spawn instead of spawn_local in anime animation callback
Closes #588
2025-01-21 21:04:20 +01:00
Luke D. Jones bddccc696f Update deps 2025-01-21 19:49:20 +13:00
Luke D. Jones 51e9f10087 Prep 6.1.0-rc7 2025-01-21 16:44:58 +13:00
Luke D. Jones 911ff8690e feature: rework PPT tuning handling more
1. Per profile, per-ac/dc
2. Do not apply unless group is enabled
3. Better reset/disable handling
4. Selecting a profile defaults PPT to off/disabled
2025-01-21 16:39:34 +13:00
Luke D. Jones 25823dc6b7 asusd: anime: don't cause async deadlocks damnit
Same old song, an async mutex lock being held for a wide scope.
In particular being held for a scope that includes a function call which
also tries to get the lock.

Fix it by copy/clone of the config interior values required.

Fixes #588
2025-01-21 12:24:24 +13:00
Luke D. Jones cba8e1a473 Add extra debug logging to anime path 2025-01-20 13:43:38 +13:00
Luke D. Jones fb98827a1a Prep 6.1.0-rc6 2025-01-19 23:35:32 +13:00
Luke D. Jones b9296862df Move entirely to using only platform-profile
throttle_thermal_policy is not ideal anymore and may be
removed from kernel in the future.
2025-01-19 21:52:32 +13:00
Luke D. Jones 450205f9a9 Bug fix: correctly set charge limit from UI 2025-01-19 17:29:36 +13:00
Luke D. Jones 82431ee25b Prep 6.1.0-rc5 2025-01-19 16:11:48 +13:00
Luke D. Jones f11aea02a8 Add help and reset to UI for ppt values 2025-01-19 16:01:57 +13:00
Luke D. Jones 2d6d669c22 PPT restor defaults (WIP) 2025-01-19 12:02:22 +13:00
Luke D. Jones f9cebf9221 Per-AC/DC per-profile tunings enabled 2025-01-19 11:33:48 +13:00
Luke D. Jones a00808313e Prep 6.1.0-rc4 2025-01-18 23:11:46 +13:00
Luke D. Jones 3426591d32 Finalise per-profile PPT settings 2025-01-18 22:46:50 +13:00
Luke D. Jones ef3b6636f5 Allow each performance profile to have different PPT values 2025-01-18 21:54:37 +13:00
Luke D. Jones ee9e0a1e31 Fix: ROGCC: fix anime matrix settings 2025-01-18 21:27:57 +13:00
Luke D. Jones 9e84997cbf Fix: ROGCC: don't crash out if no tray area available 2025-01-18 20:54:25 +13:00
Luke D. Jones 2b22f82b72 Cleanup unsafe sysfs interfaces. Bugfixes for UI 2025-01-16 23:56:12 +13:00
Luke D. Jones 7a1b45071d Correct changelog rc3 tag 2025-01-15 22:25:24 +13:00
Luke D. Jones ad63c429cb Bugfix: urgent small fixes 2025-01-15 22:19:46 +13:00
Luke D. Jones a790d9a499 Remove dangerous use of ppt* in platform, add use of ppt_pl3_fppt in asus_armoury handler 2025-01-13 23:18:19 +13:00
Luke D. Jones be51a1ab77 Disable strip in Makefile 2025-01-13 22:38:30 +13:00
Luke D. Jones d9a88e7cc3 Notify user via message in UI if asus-armoury not loaded 2025-01-13 14:32:13 +13:00
Luke D. Jones d785e17f95 Allow version in makefile to have '-rc*' 2025-01-12 18:52:45 +13:00
Luke D. Jones efe64119c6 Prep 6.1.0-rc2 2025-01-12 17:53:32 +13:00
Luke D. Jones 128bc3fce1 Update readme, slash configs 2025-01-12 17:51:43 +13:00
Luke D. Jones 2123f369ad Small clippy cleanups 2025-01-04 20:04:07 +13:00
Luke D. Jones 2b7a2a5be3 Remove typeshare use 2025-01-03 16:37:22 +13:00
Luke D. Jones 1d9e89ef3d Update deps 2025-01-02 19:08:48 +13:00
Luke D. Jones 4011b3ebd4 ROGCC: begin using the new asus_armoury API 2025-01-01 14:47:08 +13:00
Luke D. Jones f7456f0144 Allow changing of platform values with cli 2024-12-29 12:03:50 +13:00
Luke D. Jones 2ed2d82e03 Better print of firmware attributes in CLI 2024-12-29 11:36:22 +13:00
Luke D. Jones d40f4733e2 Fix: prevent event loop error in ROGCC
Leftover code from parts of the refactor and tray crate change were
causing the app to crash due to the UI trying to issue a command on the
slint thread when the slint thread had not been created yet.

Closes #579
2024-12-28 22:06:16 +13:00
Luke Jones 98dc155e41 Merge branch 'feat/add-g533qs' into 'main'
feat(rog-aura): 🎸 Add G533QS aura support

See merge request asus-linux/asusctl!210
2024-12-28 04:32:17 +00:00
Luke D. Jones fd3384decc Minor test of platform attributes 2024-12-28 10:56:34 +13:00
Luke D. Jones a1a9c7077a Rename dbus. Add asus_armoury client source 2024-12-26 21:36:07 +13:00
Luke D. Jones 62aa1fe04f Add initial dbus draft of asus_armoury attrs 2024-12-26 16:41:17 +13:00
kamack38 72c0b24ead feat(rog-aura): 🎸 Add G533QS aura support 2024-12-23 00:18:46 +01:00
109 changed files with 5343 additions and 3388 deletions
+74
View File
@@ -2,6 +2,80 @@
## [Unreleased] ## [Unreleased]
## [v6.1.4]
### Changed
- Fix git doing me a dirty
## [v6.1.3]
### Changed
- Many small bugfixes such as for platform profile switching
## [v6.1.2]
### Changed
- Try a slightly different tact to fix charge control slider
## [v6.1.1]
### Changed
- Fix aura data matching
- Fix charge control slider
## [v6.1.0]
### Changed
- Update deps
- Add support for G513RC RGB modes
- Many UI fixes
- Fixes to PPT settings in UI
## [v6.1.0-rc7]
- Refactor PPT handling more:
1. Per profile, per-ac/dc
2. Do not apply unless group is enabled
3. Better reset/disable handling
4. Selecting a profile defaults PPT to off/disabled
- Bugfix: prevent an AniMe thread async deadlock
## [v6.1.0-rc6]
### Changed
- Two small fixes, one for `low-power` profile name, and one for base gpu tdp
- Move to using platform_profile api only (no throttle_thermal_policy)
## [v6.1.0-rc5]
### Changed
- Per-AC/DC, per-profile tunings enabled (Battery vs AC power + platform profile)
- Add ability to restore PPT defaults
- Add PPT help dialogue to UI
- Bug fix: correctly set charge limit from UI
## [v6.1.0-rc4]
### Changed
- Bug fix: UI was setting incorrect value for FPPT
- Bug fix: Re-add callbacks for the throttle and epp settings in UI
- Bug fix: Fix UI settigns for AniMe Matrix display
- Bug fix: better handle missing tray (for example gnome)
- Strip out all outdated and unsafe tuning stuff
- Allow each performance profile to have different PPT settings
## [v6.1.0-rc3]
### Changed
- Bug fixes
- Partial support for per-profile CPU tunings (WIP)
## [v6.1.0-rc2]
### Added
- asus-armoury driver support. WIP, will be adjusted/changed further
- More "Slash" display controls
## [v6.1.0-rc1] ## [v6.1.0-rc1]
### Added ### Added
Generated
+1136 -542
View File
File diff suppressed because it is too large Load Diff
+30 -35
View File
@@ -1,5 +1,5 @@
[workspace.package] [workspace.package]
version = "6.1.0-rc1" version = "6.1.4"
rust-version = "1.82" rust-version = "1.82"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
@@ -12,48 +12,43 @@ edition = "2021"
[workspace] [workspace]
resolver = "2" resolver = "2"
members = [ members = [
"asusctl", "asusctl",
"asusd", "asusd",
"asusd-user", "asusd-user",
"config-traits", "config-traits",
"cpuctl", "dmi-id",
"dmi-id", "rog-platform",
"rog-platform", "rog-dbus",
"rog-dbus", "rog-anime",
"rog-anime", "rog-aura",
"rog-aura", "rog-profiles",
"rog-profiles", "rog-control-center",
"rog-control-center", "rog-slash",
"rog-slash", "simulators",
"simulators", "rog-scsi", "rog-scsi",
]
default-members = [
"asusctl",
"asusd",
"asusd-user",
"cpuctl",
"rog-control-center",
] ]
default-members = ["asusctl", "asusd", "asusd-user", "rog-control-center"]
[workspace.dependencies] [workspace.dependencies]
tokio = { version = "^1.39.0", default-features = false, features = [ tokio = { version = "^1.39.0", default-features = false, features = [
"macros", "macros",
"sync", "sync",
"time", "time",
"rt", "rt",
"rt-multi-thread", "rt-multi-thread",
] } ] }
concat-idents = "^1.1" concat-idents = "^1.1"
dirs = "^4.0" dirs = "^4.0"
smol = "^2.0" smol = "^2.0"
mio = "0.8.11" mio = "0.8.11"
zbus = "5.1" futures-util = "0.3.31"
zbus = "5.1.1"
logind-zbus = { version = "5.0.0" } #, default-features = false, features = ["non_blocking"] } logind-zbus = { version = "5.0.0" } #, default-features = false, features = ["non_blocking"] }
serde = { version = "^1.0", features = ["serde_derive"] } serde = { version = "^1.0", features = ["serde_derive"] }
ron = "*" ron = "*"
typeshare = "1.0.0"
log = "^0.4" log = "^0.4"
env_logger = "^0.10.0" env_logger = "^0.10.0"
@@ -71,26 +66,26 @@ gif = "^0.12.0"
versions = "6.2" versions = "6.2"
notify-rust = { version = "4.11.0", features = ["z", "async"] } notify-rust = { version = "4.11.4", features = ["z", "async"] }
sg = {git = "https://github.com/flukejones/sg-rs.git"} sg = { git = "https://github.com/flukejones/sg-rs.git" }
[profile.release] [profile.release]
# thin = 57s, asusd = 9.0M # thin = 57s, asusd = 9.0M
# fat = 72s, asusd = 6.4M # fat = 72s, asusd = 6.4M
lto = "fat" lto = "thin"
debug = false debug = false
opt-level = 3 opt-level = 3
panic = "abort" panic = "abort"
codegen-units = 1 # codegen-units = 1
[profile.dev] [profile.dev]
opt-level = 1 opt-level = 1
codegen-units = 16 # codegen-units = 1
[profile.dev.package."*"] [profile.dev.package."*"]
opt-level = 1 opt-level = 1
codegen-units = 16 # codegen-units = 1
[profile.bench] [profile.bench]
debug = false debug = false
+2 -8
View File
@@ -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 = install
INSTALL_PROGRAM = ${INSTALL} -D -m 0755 INSTALL_PROGRAM = ${INSTALL} -D -m 0755
@@ -19,7 +19,7 @@ LEDCFG := aura_support.ron
SRC := Cargo.toml Cargo.lock Makefile $(shell find -type f -wholename '**/src/*.rs') SRC := Cargo.toml Cargo.lock Makefile $(shell find -type f -wholename '**/src/*.rs')
STRIP_BINARIES ?= 1 STRIP_BINARIES ?= 0
DEBUG ?= 0 DEBUG ?= 0
ifeq ($(DEBUG),0) ifeq ($(DEBUG),0)
@@ -122,12 +122,6 @@ vendor:
tar pcfJ vendor_asusctl_$(VERSION).tar.xz vendor tar pcfJ vendor_asusctl_$(VERSION).tar.xz vendor
rm -rf vendor rm -rf vendor
bindings:
typeshare ./rog-anime/src/ --lang=typescript --output-file=bindings/ts/anime.ts
typeshare ./rog-aura/src/ --lang=typescript --output-file=bindings/ts/aura.ts
typeshare ./rog-profiles/src/ --lang=typescript --output-file=bindings/ts/profiles.ts
typeshare ./rog-platform/src/ --lang=typescript --output-file=bindings/ts/platform.ts
translate: translate:
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
+5 -3
View File
@@ -1,6 +1,6 @@
# `asusctl` for ASUS ROG # `asusctl` for ASUS ROG
[Become a Patron!](https://www.patreon.com/bePatron?u=7602281) - [Asus Linux Website](https://asus-linux.org/) [![Become a Patron!](https://github.com/codebard/patron-button-and-widgets-by-codebard/blob/master/images/become_a_patron_button.png?raw=true)](https://www.patreon.com/bePatron?u=7602281) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/V7V5CLU67) - [Asus Linux Website](https://asus-linux.org/)
**WARNING:** Many features are developed in tandem with kernel patches. If you see a feature is missing you either need a patched kernel or latest release. **WARNING:** Many features are developed in tandem with kernel patches. If you see a feature is missing you either need a patched kernel or latest release.
@@ -11,7 +11,9 @@ Now includes a GUI, `rog-control-center`.
## Kernel support ## Kernel support
**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 late 2022 devices. Due to on-going driver work the minimum suggested kernel version is always **the latest*, as improvements and fixes are continuous.
Support for some new features is not avilable unless you run a patched kernel with the work I am doing [in this github repo](https://github.com/flukejones/linux/tree/wip/ally-6.13). Use the linked branch, or `wip/ally-6.12`. Everything that is done here is upstreamed eventually (a long process).
Z13 devices will need [these](https://lore.kernel.org/linux-input/20240416090402.31057-1-luke@ljones.dev/T/#t) Z13 devices will need [these](https://lore.kernel.org/linux-input/20240416090402.31057-1-luke@ljones.dev/T/#t)
@@ -37,7 +39,7 @@ See the [rog-aura readme](./rog-aura/README.md) for more details.
## Discord ## Discord
[![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/z8y99XqPb7) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/B8GftRW2Hd)
## SUPPORTED LAPTOPS ## SUPPORTED LAPTOPS
+3 -1
View File
@@ -18,10 +18,12 @@ rog_profiles = { path = "../rog-profiles" }
rog_platform = { path = "../rog-platform" } rog_platform = { path = "../rog-platform" }
dmi_id = { path = "../dmi-id" } dmi_id = { path = "../dmi-id" }
log.workspace = true
env_logger.workspace = true
ron.workspace = true ron.workspace = true
gumdrop.workspace = true gumdrop.workspace = true
zbus.workspace = true zbus.workspace = true
[dev-dependencies] [dev-dependencies]
rog_dbus = { path = "../rog-dbus" } rog_dbus = { path = "../rog-dbus" }
+5 -8
View File
@@ -21,14 +21,11 @@ fn main() {
let brightness = args[2].parse::<f32>().unwrap(); let brightness = args[2].parse::<f32>().unwrap();
let anime_type = get_anime_type(); let anime_type = get_anime_type();
let mut seq = Sequences::new(anime_type); let mut seq = Sequences::new(anime_type);
seq.insert( seq.insert(0, &ActionLoader::AsusAnimation {
0, file: path.into(),
&ActionLoader::AsusAnimation { time: rog_anime::AnimTime::Infinite,
file: path.into(), brightness,
time: rog_anime::AnimTime::Infinite, })
brightness,
},
)
.unwrap(); .unwrap();
loop { loop {
+11 -30
View File
@@ -1,5 +1,5 @@
use gumdrop::Options; use gumdrop::Options;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use crate::anime_cli::AnimeCommand; use crate::anime_cli::AnimeCommand;
use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin}; use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin};
@@ -49,8 +49,11 @@ pub enum CliCommand {
Slash(SlashCommand), Slash(SlashCommand),
#[options(name = "scsi", help = "Manage SCSI external drive")] #[options(name = "scsi", help = "Manage SCSI external drive")]
Scsi(ScsiCommand), Scsi(ScsiCommand),
#[options(help = "Change bios settings")] #[options(
Platform(PlatformCommand), help = "Change platform settings. This is a new interface exposed by the asus-armoury \
driver, some of the settings will be the same as the older platform interface"
)]
Armoury(ArmouryCommand),
} }
#[derive(Debug, Clone, Options)] #[derive(Debug, Clone, Options)]
@@ -68,7 +71,7 @@ pub struct ProfileCommand {
pub profile_get: bool, pub profile_get: bool,
#[options(meta = "", help = "set the active profile")] #[options(meta = "", help = "set the active profile")]
pub profile_set: Option<ThrottlePolicy>, pub profile_set: Option<PlatformProfile>,
} }
#[derive(Options)] #[derive(Options)]
@@ -90,34 +93,12 @@ pub struct GraphicsCommand {
} }
#[derive(Options, Debug)] #[derive(Options, Debug)]
pub struct PlatformCommand { pub struct ArmouryCommand {
#[options(help = "print help message")] #[options(help = "print help message")]
pub help: bool, pub help: bool,
#[options( #[options(
meta = "", free,
short = "S", help = "append each value name followed by the value to set. `-1` sets to default"
no_long,
help = "set bios POST sound: asusctl -S <true/false>"
)] )]
pub post_sound_set: Option<bool>, pub free: Vec<String>,
#[options(no_long, short = "s", help = "read bios POST sound")]
pub post_sound_get: bool,
#[options(
meta = "",
short = "D",
no_long,
help = "Switch GPU MUX mode: 0 = Discrete, 1 = Optimus, reboot required"
)]
pub gpu_mux_mode_set: Option<u8>,
#[options(no_long, short = "d", help = "get GPU mode")]
pub gpu_mux_mode_get: bool,
#[options(
meta = "",
short = "O",
no_long,
help = "Set device panel overdrive <true/false>"
)]
pub panel_overdrive_set: Option<bool>,
#[options(no_long, short = "o", help = "get panel overdrive")]
pub panel_overdrive_get: bool,
} }
+2 -2
View File
@@ -1,5 +1,5 @@
use gumdrop::Options; use gumdrop::Options;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
@@ -18,7 +18,7 @@ pub struct FanCurveCommand {
meta = "", meta = "",
help = "profile to modify fan-curve for. Shows data if no options provided" help = "profile to modify fan-curve for. Shows data if no options provided"
)] )]
pub mod_profile: Option<ThrottlePolicy>, pub mod_profile: Option<PlatformProfile>,
#[options( #[options(
meta = "", meta = "",
+185 -109
View File
@@ -9,10 +9,12 @@ use aura_cli::{LedPowerCommand1, LedPowerCommand2};
use dmi_id::DMIID; use dmi_id::DMIID;
use fan_curve_cli::FanCurveCommand; use fan_curve_cli::FanCurveCommand;
use gumdrop::{Opt, Options}; use gumdrop::{Opt, Options};
use log::{error, info};
use rog_anime::usb::get_anime_type; use rog_anime::usb::get_anime_type;
use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2}; use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2};
use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower}; use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower};
use rog_aura::{self, AuraDeviceType, AuraEffect, PowerZones}; use rog_aura::{self, AuraDeviceType, AuraEffect, PowerZones};
use rog_dbus::asus_armoury::AsusArmouryProxyBlocking;
use rog_dbus::list_iface_blocking; use rog_dbus::list_iface_blocking;
use rog_dbus::scsi_aura::ScsiAuraProxyBlocking; use rog_dbus::scsi_aura::ScsiAuraProxyBlocking;
use rog_dbus::zbus_anime::AnimeProxyBlocking; use rog_dbus::zbus_anime::AnimeProxyBlocking;
@@ -20,7 +22,7 @@ use rog_dbus::zbus_aura::AuraProxyBlocking;
use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking; use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking;
use rog_dbus::zbus_platform::PlatformProxyBlocking; use rog_dbus::zbus_platform::PlatformProxyBlocking;
use rog_dbus::zbus_slash::SlashProxyBlocking; use rog_dbus::zbus_slash::SlashProxyBlocking;
use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy}; use rog_platform::platform::{PlatformProfile, Properties};
use rog_profiles::error::ProfileError; use rog_profiles::error::ProfileError;
use rog_scsi::AuraMode; use rog_scsi::AuraMode;
use rog_slash::SlashMode; use rog_slash::SlashMode;
@@ -41,6 +43,14 @@ mod scsi_cli;
mod slash_cli; mod slash_cli;
fn main() { fn main() {
let mut logger = env_logger::Builder::new();
logger
.parse_default_env()
.target(env_logger::Target::Stdout)
.format_timestamp(None)
.filter_level(log::LevelFilter::Debug)
.init();
let self_version = env!("CARGO_PKG_VERSION"); let self_version = env!("CARGO_PKG_VERSION");
println!("Starting version {self_version}"); println!("Starting version {self_version}");
let args: Vec<String> = args().skip(1).collect(); let args: Vec<String> = args().skip(1).collect();
@@ -64,7 +74,15 @@ fn main() {
println!("\nError: {e}\n"); println!("\nError: {e}\n");
print_info(); print_info();
}) { }) {
let asusd_version = platform_proxy.version().unwrap(); let asusd_version = platform_proxy
.version()
.map_err(|e| {
error!(
"Could not get asusd version: {e:?}\nIs asusd.service running? {}",
check_service("asusd")
);
})
.unwrap();
if asusd_version != self_version { if asusd_version != self_version {
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}"); println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
return; return;
@@ -132,8 +150,7 @@ where
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>, T: ProxyImpl<'static> + From<zbus::Proxy<'static>>,
{ {
let conn = zbus::blocking::Connection::system().unwrap(); let conn = zbus::blocking::Connection::system().unwrap();
let f = let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").unwrap();
let interfaces = f.get_managed_objects().unwrap(); let interfaces = f.get_managed_objects().unwrap();
let mut paths = Vec::new(); let mut paths = Vec::new();
for v in interfaces.iter() { for v in interfaces.iter() {
@@ -141,28 +158,29 @@ where
// e.to_owned()).collect(); println!("{}, {:?}", v.0, o); // e.to_owned()).collect(); println!("{}, {:?}", v.0, o);
for k in v.1.keys() { for k in v.1.keys() {
if k.as_str() == iface_name { if k.as_str() == iface_name {
println!("Found {iface_name} device at {}, {}", v.0, k); // println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone()); paths.push(v.0.clone());
} }
} }
} }
if paths.len() > 1 { if paths.len() > 1 {
println!("Multiple aura devices found: {paths:?}"); println!("Multiple asusd interfaces devices found");
} }
if !paths.is_empty() { if !paths.is_empty() {
let mut ctrl = Vec::new(); let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(b));
for path in paths { for path in paths {
ctrl.push( ctrl.push(
T::builder(&conn) T::builder(&conn)
.path(path.clone())? .path(path.clone())?
.destination("org.asuslinux.Daemon")? .destination("xyz.ljones.Asusd")?
.build()?, .build()?,
); );
} }
return Ok(ctrl); return Ok(ctrl);
} }
Err("No Aura interface".into()) Err(format!("Did not find {iface_name}").into())
} }
fn do_parsed( fn do_parsed(
@@ -185,9 +203,7 @@ fn do_parsed(
Some(CliCommand::Anime(cmd)) => handle_anime(cmd)?, Some(CliCommand::Anime(cmd)) => handle_anime(cmd)?,
Some(CliCommand::Slash(cmd)) => handle_slash(cmd)?, Some(CliCommand::Slash(cmd)) => handle_slash(cmd)?,
Some(CliCommand::Scsi(cmd)) => handle_scsi(cmd)?, Some(CliCommand::Scsi(cmd)) => handle_scsi(cmd)?,
Some(CliCommand::Platform(cmd)) => { Some(CliCommand::Armoury(cmd)) => handle_armoury_command(cmd)?,
handle_platform_properties(&conn, supported_properties, cmd)?
}
None => { None => {
if (!parsed.show_supported if (!parsed.show_supported
&& parsed.kbd_bright.is_none() && parsed.kbd_bright.is_none()
@@ -201,7 +217,7 @@ fn do_parsed(
println!(); println!();
if let Some(cmdlist) = CliStart::command_list() { if let Some(cmdlist) = CliStart::command_list() {
let dev_type = let dev_type =
if let Ok(proxy) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") { if let Ok(proxy) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
// TODO: commands on all? // TODO: commands on all?
proxy proxy
.first() .first()
@@ -214,32 +230,37 @@ fn do_parsed(
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect(); let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
for command in commands.iter().filter(|command| { for command in commands.iter().filter(|command| {
if command.trim().starts_with("fan-curve") if command.trim().starts_with("fan-curve")
&& !supported_interfaces && !supported_interfaces.contains(&"xyz.ljones.FanCurves".to_string())
.contains(&"org.asuslinux.FanCurves".to_string())
{ {
return false; return false;
} }
if command.trim().starts_with("aura") if command.trim().starts_with("aura")
&& !supported_interfaces.contains(&"org.asuslinux.Aura".to_string()) && !supported_interfaces.contains(&"xyz.ljones.Aura".to_string())
{ {
return false; return false;
} }
if command.trim().starts_with("anime") if command.trim().starts_with("anime")
&& !supported_interfaces.contains(&"org.asuslinux.Anime".to_string()) && !supported_interfaces.contains(&"xyz.ljones.Anime".to_string())
{ {
return false; return false;
} }
if command.trim().starts_with("slash") if command.trim().starts_with("slash")
&& !supported_interfaces.contains(&"org.asuslinux.Slash".to_string()) && !supported_interfaces.contains(&"xyz.ljones.Slash".to_string())
{ {
return false; return false;
} }
if command.trim().starts_with("platform") if command.trim().starts_with("platform")
&& !supported_interfaces.contains(&"org.asuslinux.Platform".to_string()) && !supported_interfaces.contains(&"xyz.ljones.Platform".to_string())
{
return false;
}
if command.trim().starts_with("platform")
&& !supported_interfaces.contains(&"xyz.ljones.AsusArmoury".to_string())
{ {
return false; return false;
} }
@@ -260,14 +281,14 @@ fn do_parsed(
} }
println!("\nExtra help can be requested on any command or subcommand:"); println!("\nExtra help can be requested on any command or subcommand:");
println!(" asusctl led-mode --help"); println!(" asusctl aura --help");
println!(" asusctl led-mode static --help"); println!(" asusctl aura static --help");
} }
} }
} }
if let Some(brightness) = &parsed.kbd_bright { if let Some(brightness) = &parsed.kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") { if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() { for aura in aura.iter() {
match brightness.level() { match brightness.level() {
None => { None => {
@@ -283,7 +304,7 @@ fn do_parsed(
} }
if parsed.next_kbd_bright { if parsed.next_kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") { if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() { for aura in aura.iter() {
let brightness = aura.brightness()?; let brightness = aura.brightness()?;
aura.set_brightness(brightness.next())?; aura.set_brightness(brightness.next())?;
@@ -294,7 +315,7 @@ fn do_parsed(
} }
if parsed.prev_kbd_bright { if parsed.prev_kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") { if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() { for aura in aura.iter() {
let brightness = aura.brightness()?; let brightness = aura.brightness()?;
aura.set_brightness(brightness.prev())?; aura.set_brightness(brightness.prev())?;
@@ -310,7 +331,7 @@ fn do_parsed(
"Supported Platform Properties:\n{:#?}", "Supported Platform Properties:\n{:#?}",
supported_properties supported_properties
); );
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") { if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
// TODO: multiple RGB check // TODO: multiple RGB check
let bright = aura.first().unwrap().supported_brightness()?; let bright = aura.first().unwrap().supported_brightness()?;
let modes = aura.first().unwrap().supported_basic_modes()?; let modes = aura.first().unwrap().supported_basic_modes()?;
@@ -363,7 +384,12 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
println!("\n{}", lst); println!("\n{}", lst);
} }
} }
let animes = find_iface::<AnimeProxyBlocking>("org.asuslinux.Anime")?;
let animes = find_iface::<AnimeProxyBlocking>("xyz.ljones.Anime").map_err(|e| {
error!("Did not find any interface for xyz.ljones.Anime: {e:?}");
e
})?;
for proxy in animes { for proxy in animes {
if let Some(enable) = cmd.enable_display { if let Some(enable) = cmd.enable_display {
proxy.set_enable_display(enable)?; proxy.set_enable_display(enable)?;
@@ -544,7 +570,12 @@ fn verify_brightness(brightness: f32) {
fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> { fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
if (cmd.brightness.is_none() if (cmd.brightness.is_none()
&& cmd.interval.is_none() && cmd.interval.is_none()
&& cmd.slash_mode.is_none() && cmd.show_on_boot.is_none()
&& cmd.show_on_shutdown.is_none()
&& cmd.show_on_sleep.is_none()
&& cmd.show_on_battery.is_none()
&& cmd.show_battery_warning.is_none()
&& cmd.mode.is_none()
&& !cmd.list && !cmd.list
&& !cmd.enable && !cmd.enable
&& !cmd.disable) && !cmd.disable)
@@ -556,7 +587,7 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
} }
} }
let slashes = find_iface::<SlashProxyBlocking>("org.asuslinux.Slash")?; let slashes = find_iface::<SlashProxyBlocking>("xyz.ljones.Slash")?;
for proxy in slashes { for proxy in slashes {
if cmd.enable { if cmd.enable {
proxy.set_enabled(true)?; proxy.set_enabled(true)?;
@@ -570,8 +601,24 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
if let Some(interval) = cmd.interval { if let Some(interval) = cmd.interval {
proxy.set_interval(interval)?; proxy.set_interval(interval)?;
} }
if let Some(slash_mode) = cmd.slash_mode { if let Some(slash_mode) = cmd.mode {
proxy.set_slash_mode(slash_mode)?; proxy.set_mode(slash_mode)?;
}
if let Some(show) = cmd.show_on_boot {
proxy.set_show_on_boot(show)?;
}
if let Some(show) = cmd.show_on_shutdown {
proxy.set_show_on_shutdown(show)?;
}
if let Some(show) = cmd.show_on_sleep {
proxy.set_show_on_sleep(show)?;
}
if let Some(show) = cmd.show_on_battery {
proxy.set_show_on_battery(show)?;
}
if let Some(show) = cmd.show_battery_warning {
proxy.set_show_battery_warning(show)?;
} }
} }
if cmd.list { if cmd.list {
@@ -594,7 +641,7 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box<dyn std::error::Error>> {
} }
} }
let scsis = find_iface::<ScsiAuraProxyBlocking>("org.asuslinux.ScsiAura")?; let scsis = find_iface::<ScsiAuraProxyBlocking>("xyz.ljones.ScsiAura")?;
for scsi in scsis { for scsi in scsis {
if let Some(enable) = cmd.enable { if let Some(enable) = cmd.enable {
@@ -609,8 +656,7 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box<dyn std::error::Error>> {
let mut mode = scsi.led_mode_data()?; let mut mode = scsi.led_mode_data()?;
let mut do_update = false; let mut do_update = false;
if !cmd.colours.is_empty() { if !cmd.colours.is_empty() {
let mut count = 0; for (count, c) in cmd.colours.iter().enumerate() {
for c in &cmd.colours {
if count == 0 { if count == 0 {
mode.colour1 = *c; mode.colour1 = *c;
} }
@@ -623,7 +669,6 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box<dyn std::error::Error>> {
if count == 3 { if count == 3 {
mode.colour4 = *c; mode.colour4 = *c;
} }
count += 1;
} }
do_update = true; do_update = true;
} }
@@ -668,7 +713,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
if let Some(cmdlist) = LedModeCommand::command_list() { if let Some(cmdlist) = LedModeCommand::command_list() {
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect(); let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
// TODO: multiple rgb check // TODO: multiple rgb check
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?; let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
let modes = aura.first().unwrap().supported_basic_modes()?; let modes = aura.first().unwrap().supported_basic_modes()?;
for command in commands.iter().filter(|command| { for command in commands.iter().filter(|command| {
for mode in &modes { for mode in &modes {
@@ -698,7 +743,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
println!("Please specify either next or previous"); println!("Please specify either next or previous");
return Ok(()); return Ok(());
} }
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?; let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
if mode.next_mode { if mode.next_mode {
for aura in aura { for aura in aura {
let mode = aura.led_mode()?; let mode = aura.led_mode()?;
@@ -735,7 +780,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
} }
fn handle_led_power1(power: &LedPowerCommand1) -> Result<(), Box<dyn std::error::Error>> { fn handle_led_power1(power: &LedPowerCommand1) -> Result<(), Box<dyn std::error::Error>> {
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?; let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
for aura in aura { for aura in aura {
let dev_type = aura.device_type()?; let dev_type = aura.device_type()?;
if !dev_type.is_old_laptop() && !dev_type.is_tuf_laptop() { if !dev_type.is_old_laptop() && !dev_type.is_tuf_laptop() {
@@ -795,7 +840,7 @@ fn handle_led_power_1_do_1866(
} }
fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error::Error>> { fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error::Error>> {
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?; let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
for aura in aura { for aura in aura {
let dev_type = aura.device_type()?; let dev_type = aura.device_type()?;
if !dev_type.is_new_laptop() { if !dev_type.is_new_laptop() {
@@ -881,17 +926,17 @@ fn handle_throttle_profile(
} }
let proxy = PlatformProxyBlocking::new(conn)?; let proxy = PlatformProxyBlocking::new(conn)?;
let current = proxy.throttle_thermal_policy()?; let current = proxy.platform_profile()?;
let choices = proxy.platform_profile_choices()?;
if cmd.next { if cmd.next {
proxy.set_throttle_thermal_policy(current.next())?; proxy.set_platform_profile(PlatformProfile::next(current, &choices))?;
} else if let Some(profile) = cmd.profile_set { } else if let Some(profile) = cmd.profile_set {
proxy.set_throttle_thermal_policy(profile)?; proxy.set_platform_profile(profile)?;
} }
if cmd.list { if cmd.list {
let res = ThrottlePolicy::list(); for p in &choices {
for p in &res {
println!("{:?}", p); println!("{:?}", p);
} }
} }
@@ -937,7 +982,7 @@ fn handle_fan_curve(
let plat_proxy = PlatformProxyBlocking::new(conn)?; let plat_proxy = PlatformProxyBlocking::new(conn)?;
if cmd.get_enabled { if cmd.get_enabled {
let profile = plat_proxy.throttle_thermal_policy()?; let profile = plat_proxy.platform_profile()?;
let curves = fan_proxy.fan_curve_data(profile)?; let curves = fan_proxy.fan_curve_data(profile)?;
for curve in curves.iter() { for curve in curves.iter() {
println!("{}", String::from(curve)); println!("{}", String::from(curve));
@@ -945,7 +990,7 @@ fn handle_fan_curve(
} }
if cmd.default { if cmd.default {
let active = plat_proxy.throttle_thermal_policy()?; let active = plat_proxy.platform_profile()?;
fan_proxy.set_curves_to_defaults(active)?; fan_proxy.set_curves_to_defaults(active)?;
} }
@@ -981,70 +1026,6 @@ fn handle_fan_curve(
Ok(()) Ok(())
} }
fn handle_platform_properties(
conn: &Connection,
supported: &[Properties],
cmd: &PlatformCommand,
) -> Result<(), Box<dyn std::error::Error>> {
{
if (cmd.gpu_mux_mode_set.is_none()
&& !cmd.gpu_mux_mode_get
&& cmd.post_sound_set.is_none()
&& !cmd.post_sound_get
&& cmd.panel_overdrive_set.is_none()
&& !cmd.panel_overdrive_get)
|| cmd.help
{
println!("Missing arg or command\n");
let usage: Vec<String> = PlatformCommand::usage()
.lines()
.map(|s| s.to_owned())
.collect();
for line in usage.iter().filter(|line| {
line.contains("sound") && supported.contains(&Properties::PostAnimationSound)
|| line.contains("GPU") && supported.contains(&Properties::GpuMuxMode)
|| line.contains("panel") && supported.contains(&Properties::PanelOd)
}) {
println!("{}", line);
}
}
let proxy = PlatformProxyBlocking::new(conn)?;
if let Some(opt) = cmd.post_sound_set {
proxy.set_boot_sound(opt)?;
}
if cmd.post_sound_get {
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");
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 = proxy.gpu_mux_mode()?;
println!("Bios GPU MUX: {:?}", res);
}
if let Some(opt) = cmd.panel_overdrive_set {
proxy.set_panel_od(opt)?;
}
if cmd.panel_overdrive_get {
let res = proxy.panel_od()?;
println!("Panel overdrive on: {}", res);
}
}
Ok(())
}
fn check_systemd_unit_active(name: &str) -> bool { fn check_systemd_unit_active(name: &str) -> bool {
if let Ok(out) = Command::new("systemctl") if let Ok(out) = Command::new("systemctl")
.arg("is-active") .arg("is-active")
@@ -1064,7 +1045,102 @@ fn check_systemd_unit_enabled(name: &str) -> bool {
.output() .output()
{ {
let buf = String::from_utf8_lossy(&out.stdout); let buf = String::from_utf8_lossy(&out.stdout);
return buf.contains("enabled"); return buf.contains("enabled") || buf.contains("linked");
} }
false false
} }
fn print_firmware_attr(attr: &AsusArmouryProxyBlocking) -> Result<(), Box<dyn std::error::Error>> {
let name = attr.name()?;
println!("{}:", <&str>::from(name));
let attrs = attr.available_attrs()?;
if attrs.contains(&"min_value".to_string())
&& attrs.contains(&"max_value".to_string())
&& attrs.contains(&"current_value".to_string())
{
let c = attr.current_value()?;
let min = attr.min_value()?;
let max = attr.max_value()?;
println!(" current: {min}..[{c}]..{max}");
if attrs.contains(&"default_value".to_string()) {
println!(" default: {}\n", attr.default_value()?);
} else {
println!();
}
} else if attrs.contains(&"possible_values".to_string())
&& attrs.contains(&"current_value".to_string())
{
let c = attr.current_value()?;
let v = attr.possible_values()?;
for p in v.iter().enumerate() {
if p.0 == 0 {
print!(" current: [");
}
if *p.1 == c {
print!("({c})");
} else {
print!("{}", p.1);
}
if p.0 < v.len() - 1 {
print!(",");
}
if p.0 == v.len() - 1 {
print!("]");
}
}
if attrs.contains(&"default_value".to_string()) {
println!(" default: {}\n", attr.default_value()?);
} else {
println!("\n");
}
} else if attrs.contains(&"current_value".to_string()) {
let c = attr.current_value()?;
println!(" current: {c}\n");
} else {
println!();
}
Ok(())
}
fn handle_armoury_command(cmd: &ArmouryCommand) -> Result<(), Box<dyn std::error::Error>> {
{
if cmd.free.is_empty() || cmd.free.len() % 2 != 0 || cmd.help {
const USAGE: &str = "Usage: asusctl platform panel_overdrive 1 nv_dynamic_boost 5";
if cmd.free.len() % 2 != 0 {
println!(
"Incorrect number of args, each attribute label must be paired with a setting:"
);
println!("{USAGE}");
return Ok(());
}
if let Ok(attr) = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury") {
println!("\n{USAGE}\n");
println!("Available firmware attributes: ");
for attr in attr.iter() {
print_firmware_attr(attr)?;
}
}
return Ok(());
}
if let Ok(attr) = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury") {
for cmd in cmd.free.chunks(2) {
for attr in attr.iter() {
let name = attr.name()?;
if <&str>::from(name) == cmd[0] {
let mut value: i32 = cmd[1].parse()?;
if value == -1 {
info!("Setting to default");
value = attr.default_value()?;
}
attr.set_current_value(value)?;
print_firmware_attr(attr)?;
}
}
}
}
}
Ok(())
}
+18 -3
View File
@@ -7,14 +7,29 @@ pub struct SlashCommand {
pub help: bool, pub help: bool,
#[options(help = "Enable the Slash Ledbar")] #[options(help = "Enable the Slash Ledbar")]
pub enable: bool, pub enable: bool,
#[options(help = "Ddisable the Slash Ledbar")] #[options(help = "Disable the Slash Ledbar")]
pub disable: bool, pub disable: bool,
#[options(meta = "", help = "Set brightness value <0-255>")] #[options(short = "l", meta = "", help = "Set brightness value <0-255>")]
pub brightness: Option<u8>, pub brightness: Option<u8>,
#[options(meta = "", help = "Set interval value <0-5>")] #[options(meta = "", help = "Set interval value <0-5>")]
pub interval: Option<u8>, pub interval: Option<u8>,
#[options(meta = "", help = "Set SlashMode (so 'list' for all options)")] #[options(meta = "", help = "Set SlashMode (so 'list' for all options)")]
pub slash_mode: Option<SlashMode>, pub mode: Option<SlashMode>,
#[options(help = "list available animations")] #[options(help = "list available animations")]
pub list: bool, pub list: bool,
#[options(short = "B", meta = "", help = "Show the animation on boot")]
pub show_on_boot: Option<bool>,
#[options(short = "S", meta = "", help = "Show the animation on shutdown")]
pub show_on_shutdown: Option<bool>,
#[options(short = "s", meta = "", help = "Show the animation on sleep")]
pub show_on_sleep: Option<bool>,
#[options(short = "b", meta = "", help = "Show the animation on battery")]
pub show_on_battery: Option<bool>,
#[options(
short = "w",
meta = "",
help = "Show the low-battery warning animation"
)]
pub show_battery_warning: Option<bool>,
} }
+2 -5
View File
@@ -151,10 +151,7 @@ impl CtrlAnime<'static> {
pub async fn add_to_server(self, server: &mut zbus::Connection) { pub async fn add_to_server(self, server: &mut zbus::Connection) {
server server
.object_server() .object_server()
.at( .at(&ObjectPath::from_str_unchecked("/xyz/ljones/Anime"), self)
&ObjectPath::from_str_unchecked("/org/asuslinux/Anime"),
self,
)
.await .await
.map_err(|err| { .map_err(|err| {
println!("CtrlAnime: add_to_server {}", err); println!("CtrlAnime: add_to_server {}", err);
@@ -170,7 +167,7 @@ impl CtrlAnime<'static> {
// - Do actions // - Do actions
// - Write config if required // - Write config if required
// - Unset inner_early_return // - Unset inner_early_return
#[interface(name = "org.asuslinux.Daemon")] #[interface(name = "xyz.ljones.Asusd")]
impl CtrlAnime<'static> { impl CtrlAnime<'static> {
pub fn insert_asus_gif( pub fn insert_asus_gif(
&mut self, &mut self,
+1 -1
View File
@@ -42,7 +42,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let early_return = Arc::new(AtomicBool::new(false)); let early_return = Arc::new(AtomicBool::new(false));
// Set up the anime data and run loop/thread // Set up the anime data and run loop/thread
if supported.contains(&"org.asuslinux.Anime".to_string()) { if supported.contains(&"xyz.ljones.Anime".to_string()) {
if let Some(cfg) = config.active_anime { if let Some(cfg) = config.active_anime {
let anime_type = get_anime_type(); let anime_type = get_anime_type();
let anime_config = ConfigAnime::new().set_name(cfg).load(); let anime_config = ConfigAnime::new().set_name(cfg).load();
+4 -7
View File
@@ -1,8 +1,8 @@
//! # `DBus` interface proxy for: `org.asuslinux.Daemon` //! # `DBus` interface proxy for: `xyz.ljones.Asusd`
//! //!
//! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection //! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection
//! data. Source: `Interface '/org/asuslinux/Anime' from service //! data. Source: `Interface '/xyz/ljones/Anime' from service
//! 'org.asuslinux.Daemon' on session bus`. //! 'xyz.ljones.Asusd' on session bus`.
//! //!
//! You may prefer to adapt it, instead of using it verbatim. //! You may prefer to adapt it, instead of using it verbatim.
//! //!
@@ -23,10 +23,7 @@
use zbus::proxy; use zbus::proxy;
#[proxy( #[proxy(interface = "xyz.ljones.Asusd", default_path = "/xyz/ljones/Anime")]
interface = "org.asuslinux.Daemon",
default_path = "/org/asuslinux/Anime"
)]
trait Daemon { trait Daemon {
/// InsertAsusGif method /// InsertAsusGif method
fn insert_asus_gif( fn insert_asus_gif(
+1
View File
@@ -34,6 +34,7 @@ tokio.workspace = true
log.workspace = true log.workspace = true
env_logger.workspace = true env_logger.workspace = true
futures-util.workspace = true
zbus.workspace = true zbus.workspace = true
logind-zbus.workspace = true logind-zbus.workspace = true
+425
View File
@@ -0,0 +1,425 @@
use std::sync::Arc;
use config_traits::StdConfig;
use futures_util::lock::Mutex;
use log::{debug, error, info};
use rog_platform::asus_armoury::{AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes};
use rog_platform::platform::{PlatformProfile, RogPlatform};
use rog_platform::power::AsusPower;
use serde::{Deserialize, Serialize};
use zbus::object_server::SignalEmitter;
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
use zbus::{fdo, interface, Connection};
use crate::config::Config;
use crate::error::RogError;
use crate::{Reloadable, ASUS_ZBUS_PATH};
const MOD_NAME: &str = "asus_armoury";
#[derive(Debug, Default, Clone, Deserialize, Serialize, Type, Value, OwnedValue)]
pub struct PossibleValues {
strings: Vec<String>,
nums: Vec<i32>,
}
fn dbus_path_for_attr(attr_name: &str) -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{attr_name}")).into()
}
#[derive(Clone)]
pub struct AsusArmouryAttribute {
attr: Attribute,
config: Arc<Mutex<Config>>,
/// platform control required here for access to PPD or Throttle profile
platform: RogPlatform,
power: AsusPower,
}
impl AsusArmouryAttribute {
pub fn new(
attr: Attribute,
platform: RogPlatform,
power: AsusPower,
config: Arc<Mutex<Config>>,
) -> Self {
Self {
attr,
config,
platform,
power,
}
}
pub async fn move_to_zbus(self, connection: &Connection) -> Result<(), RogError> {
let path = dbus_path_for_attr(self.attr.name());
connection
.object_server()
.at(path.clone(), self)
.await
.map_err(|e| error!("Couldn't add server at path: {path}, {e:?}"))
.ok();
Ok(())
}
async fn watch_and_notify(
&mut self,
signal_ctxt: SignalEmitter<'static>,
) -> Result<(), RogError> {
use futures_util::StreamExt;
let name = self.name();
macro_rules! watch_value_notify {
($attr_str:expr, $fn_prop_changed:ident) => {
match self.attr.get_watcher($attr_str) {
Ok(watch) => {
let name = <&str>::from(name);
let ctrl = self.clone();
let sig = signal_ctxt.clone();
tokio::spawn(async move {
let mut buffer = [0; 32];
watch
.into_event_stream(&mut buffer)
.unwrap()
.for_each(|_| async {
debug!("{} changed", name);
ctrl.$fn_prop_changed(&sig).await.ok();
})
.await;
});
}
Err(e) => info!(
"inotify watch failed: {}. You can ignore this if your device does not \
support the feature",
e
),
}
};
}
// "current_value", "default_value", "min_value", "max_value"
watch_value_notify!("current_value", current_value_changed);
watch_value_notify!("default_value", default_value_changed);
watch_value_notify!("min_value", min_value_changed);
watch_value_notify!("max_value", max_value_changed);
Ok(())
}
}
impl crate::Reloadable for AsusArmouryAttribute {
async fn reload(&mut self) -> Result<(), RogError> {
info!("Reloading {}", self.attr.name());
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let config = if power_plugged == 1 {
&self.config.lock().await.ac_profile_tunings
} else {
&self.config.lock().await.dc_profile_tunings
};
if let Some(tuning) = config.get(&profile) {
if tuning.enabled {
if let Some(tune) = tuning.group.get(&self.name()) {
self.attr
.set_current_value(&AttrValue::Integer(*tune))
.map_err(|e| {
error!("Could not set {} value: {e:?}", self.attr.name());
self.attr.base_path_exists();
e
})?;
info!("Set {} to {:?}", self.attr.name(), tune);
}
}
}
Ok(())
}
}
/// If return is `-1` on a property then there is avilable value for that
/// property
#[interface(name = "xyz.ljones.AsusArmoury")]
impl AsusArmouryAttribute {
#[zbus(property)]
fn name(&self) -> FirmwareAttribute {
self.attr.name().into()
}
#[zbus(property)]
async fn available_attrs(&self) -> Vec<String> {
let mut attrs = Vec::new();
if !matches!(self.attr.default_value(), AttrValue::None) {
attrs.push("default_value".to_string());
}
if !matches!(self.attr.min_value(), AttrValue::None) {
attrs.push("min_value".to_string());
}
if !matches!(self.attr.max_value(), AttrValue::None) {
attrs.push("max_value".to_string());
}
if !matches!(self.attr.scalar_increment(), AttrValue::None) {
attrs.push("scalar_increment".to_string());
}
if !matches!(self.attr.possible_values(), AttrValue::None) {
attrs.push("possible_values".to_string());
}
// TODO: Don't unwrap, use error
if let Ok(value) = self.attr.current_value().map_err(|e| {
error!("Failed to read: {e:?}");
e
}) {
if !matches!(value, AttrValue::None) {
attrs.push("current_value".to_string());
}
}
attrs
}
/// If return is `-1` then there is no default value
#[zbus(property)]
async fn default_value(&self) -> i32 {
match self.attr.default_value() {
AttrValue::Integer(i) => *i,
_ => -1,
}
}
async fn restore_default(&self) -> fdo::Result<()> {
self.attr.restore_default()?;
if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tuning.group.get_mut(&self.name()) {
if let AttrValue::Integer(i) = self.attr.default_value() {
*tune = *i;
}
}
if tuning.enabled {
self.attr
.set_current_value(self.attr.default_value())
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
}
config.write();
}
Ok(())
}
#[zbus(property)]
async fn min_value(&self) -> i32 {
match self.attr.min_value() {
AttrValue::Integer(i) => *i,
_ => -1,
}
}
#[zbus(property)]
async fn max_value(&self) -> i32 {
match self.attr.max_value() {
AttrValue::Integer(i) => *i,
_ => -1,
}
}
#[zbus(property)]
async fn scalar_increment(&self) -> i32 {
match self.attr.scalar_increment() {
AttrValue::Integer(i) => *i,
_ => -1,
}
}
#[zbus(property)]
async fn possible_values(&self) -> Vec<i32> {
match self.attr.possible_values() {
AttrValue::EnumInt(i) => i.clone(),
_ => Vec::default(),
}
}
#[zbus(property)]
async fn current_value(&self) -> fdo::Result<i32> {
if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tuning.group.get(&self.name()) {
return Ok(*tune);
} else if let AttrValue::Integer(i) = self.attr.default_value() {
return Ok(*i);
}
return Err(fdo::Error::Failed(
"Could not read current value".to_string(),
));
}
if let Ok(AttrValue::Integer(i)) = self.attr.current_value() {
return Ok(i);
}
Err(fdo::Error::Failed(
"Could not read current value".to_string(),
))
}
#[zbus(property)]
async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> {
if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tuning.group.get_mut(&self.name()) {
*tune = value;
} else {
tuning.group.insert(self.name(), value);
debug!("Store tuning config for {} = {:?}", self.attr.name(), value);
}
if tuning.enabled {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
}
} else {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
let has_attr = self
.config
.lock()
.await
.armoury_settings
.contains_key(&self.name());
if has_attr {
if let Some(setting) = self
.config
.lock()
.await
.armoury_settings
.get_mut(&self.name())
{
*setting = value
}
} else {
debug!("Adding config for {}", self.attr.name());
self.config
.lock()
.await
.armoury_settings
.insert(self.name(), value);
debug!("Set config for {} = {:?}", self.attr.name(), value);
}
}
self.config.lock().await.write();
Ok(())
}
}
pub async fn start_attributes_zbus(
conn: &Connection,
platform: RogPlatform,
power: AsusPower,
attributes: FirmwareAttributes,
config: Arc<Mutex<Config>>,
) -> Result<(), RogError> {
for attr in attributes.attributes() {
let mut attr = AsusArmouryAttribute::new(
attr.clone(),
platform.clone(),
power.clone(),
config.clone(),
);
attr.reload().await?;
let path = dbus_path_for_attr(attr.attr.name());
let sig = zbus::object_server::SignalEmitter::new(conn, path)?;
attr.watch_and_notify(sig).await?;
attr.move_to_zbus(conn).await?;
}
Ok(())
}
pub async fn set_config_or_default(
attrs: &FirmwareAttributes,
config: &mut Config,
power_plugged: bool,
profile: PlatformProfile,
) {
for attr in attrs.attributes().iter() {
let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() {
let tuning = config.select_tunings(power_plugged, profile);
if !tuning.enabled {
debug!("Tuning group is not enabled, skipping");
return;
}
if let Some(tune) = tuning.group.get(&name) {
attr.set_current_value(&AttrValue::Integer(*tune))
.map_err(|e| {
error!("Failed to set {}: {e}", <&str>::from(name));
})
.ok();
} else {
let default = attr.default_value();
attr.set_current_value(default)
.map_err(|e| {
error!("Failed to set {}: {e}", <&str>::from(name));
})
.ok();
if let AttrValue::Integer(i) = default {
tuning.group.insert(name, *i);
info!(
"Set default tuning config for {} = {:?}",
<&str>::from(name),
i
);
// config.write();
}
}
}
}
}
+38 -32
View File
@@ -138,38 +138,44 @@ impl AniMeConfig {
// create a default config here // create a default config here
AniMeConfig { AniMeConfig {
system: vec![], system: vec![],
boot: vec![ActionLoader::ImageAnimation { boot: vec![
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(), ActionLoader::ImageAnimation {
scale: 0.9, file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
angle: 0.65, scale: 0.9,
translation: Vec2::default(), angle: 0.65,
brightness: 1.0, translation: Vec2::default(),
time: AnimTime::Fade(Fade::new( brightness: 1.0,
Duration::from_secs(2), time: AnimTime::Fade(Fade::new(
Some(Duration::from_secs(2)), Duration::from_secs(2),
Duration::from_secs(2), Some(Duration::from_secs(2)),
)), Duration::from_secs(2),
}], )),
wake: vec![ActionLoader::ImageAnimation { },
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(), ],
scale: 0.9, wake: vec![
angle: 0.65, ActionLoader::ImageAnimation {
translation: Vec2::default(), file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
brightness: 1.0, scale: 0.9,
time: AnimTime::Fade(Fade::new( angle: 0.65,
Duration::from_secs(2), translation: Vec2::default(),
Some(Duration::from_secs(2)), brightness: 1.0,
Duration::from_secs(2), time: AnimTime::Fade(Fade::new(
)), Duration::from_secs(2),
}], Some(Duration::from_secs(2)),
shutdown: vec![ActionLoader::ImageAnimation { Duration::from_secs(2),
file: "/usr/share/asusd/anime/custom/sonic-wait.gif".into(), )),
scale: 0.9, },
angle: 0.0, ],
translation: Vec2::new(3.0, 2.0), shutdown: vec![
brightness: 1.0, ActionLoader::ImageAnimation {
time: AnimTime::Infinite, file: "/usr/share/asusd/anime/custom/sonic-wait.gif".into(),
}], scale: 0.9,
angle: 0.0,
translation: Vec2::new(3.0, 2.0),
brightness: 1.0,
time: AnimTime::Infinite,
},
],
..Default::default() ..Default::default()
} }
} }
+13 -12
View File
@@ -8,7 +8,8 @@ use std::sync::Arc;
use std::thread::sleep; use std::thread::sleep;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{error, info, warn}; use futures_util::lock::Mutex;
use log::{debug, error, info, warn};
use rog_anime::usb::{ use rog_anime::usb::{
pkt_flush, pkt_set_brightness, pkt_set_enable_display, pkt_set_enable_powersave_anim, pkt_flush, pkt_set_brightness, pkt_set_enable_display, pkt_set_enable_powersave_anim,
pkts_for_init, Brightness, pkts_for_init, Brightness,
@@ -16,7 +17,6 @@ use rog_anime::usb::{
use rog_anime::{ActionData, AnimeDataBuffer, AnimePacketType}; use rog_anime::{ActionData, AnimeDataBuffer, AnimePacketType};
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw; use rog_platform::usb_raw::USBRaw;
use tokio::sync::{Mutex, MutexGuard};
use self::config::{AniMeConfig, AniMeConfigCached}; use self::config::{AniMeConfig, AniMeConfigCached};
use crate::error::RogError; use crate::error::RogError;
@@ -51,7 +51,7 @@ impl AniMe {
/// Will fail if something is already holding the config lock /// Will fail if something is already holding the config lock
async fn do_init_cache(&mut self) { async fn do_init_cache(&mut self) {
if let Ok(mut config) = self.config.try_lock() { if let Some(mut config) = self.config.try_lock() {
if let Err(e) = self.cache.init_from_config(&config, config.anime_type) { if let Err(e) = self.cache.init_from_config(&config, config.anime_type) {
error!( error!(
"Trying to cache the Anime Config failed, will reset to default config: {e:?}" "Trying to cache the Anime Config failed, will reset to default config: {e:?}"
@@ -59,6 +59,8 @@ impl AniMe {
config.rename_file_old(); config.rename_file_old();
*config = AniMeConfig::new(); *config = AniMeConfig::new();
config.write(); config.write();
} else {
debug!("Initialised AniMe cache");
} }
} else { } else {
error!("AniMe Matrix could not init cache") error!("AniMe Matrix could not init cache")
@@ -70,11 +72,9 @@ impl AniMe {
self.do_init_cache().await; self.do_init_cache().await;
let pkts = pkts_for_init(); let pkts = pkts_for_init();
self.write_bytes(&pkts[0]).await?; self.write_bytes(&pkts[0]).await?;
self.write_bytes(&pkts[1]).await self.write_bytes(&pkts[1]).await?;
} debug!("Succesfully initialised AniMe matrix display");
Ok(())
pub async fn lock_config(&self) -> MutexGuard<AniMeConfig> {
self.config.lock().await
} }
pub async fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> { pub async fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> {
@@ -176,7 +176,7 @@ impl AniMe {
return Ok(true); // Do safe exit return Ok(true); // Do safe exit
} }
let inner = inner.clone(); let inner = inner.clone();
tokio::task::spawn_local(async move { tokio::task::spawn(async move {
inner inner
.write_data_buffer(frame) .write_data_buffer(frame)
.await .await
@@ -227,10 +227,11 @@ impl AniMe {
}) })
.ok(); .ok();
} }
// A write can block for many milliseconds so lets not hold the config lock for
// the same period
let enabled = inner.config.lock().await.builtin_anims_enabled;
inner inner
.write_bytes(&pkt_set_enable_powersave_anim( .write_bytes(&pkt_set_enable_powersave_anim(enabled))
inner.config.lock().await.builtin_anims_enabled,
))
.await .await
.map_err(|err| { .map_err(|err| {
warn!("rog_anime::run_animation:callback {}", err); warn!("rog_anime::run_animation:callback {}", err);
+61 -54
View File
@@ -1,7 +1,7 @@
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{error, warn}; use log::{debug, error, warn};
use logind_zbus::manager::ManagerProxy; use logind_zbus::manager::ManagerProxy;
use rog_anime::usb::{ use rog_anime::usb::{
pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display, pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display,
@@ -51,8 +51,11 @@ impl AniMeZbus {
.object_server() .object_server()
.at(path.clone(), self) .at(path.clone(), self)
.await .await
.map_err(|e| error!("Couldn't add server at path: {path}, {e:?}")) .map_err(|e| {
.ok(); error!("Couldn't add server at path: {path}, {e:?}");
e
})?;
debug!("start_tasks was successful");
Ok(()) Ok(())
} }
} }
@@ -60,7 +63,7 @@ impl AniMeZbus {
// None of these calls can be guarnateed to succeed unless we loop until okay // 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 // If the try_lock *does* succeed then any other thread trying to lock will not
// grab it until we finish. // grab it until we finish.
#[interface(name = "org.asuslinux.Anime")] #[interface(name = "xyz.ljones.Anime")]
impl AniMeZbus { impl AniMeZbus {
/// Writes a data stream of length. Will force system thread to exit until /// Writes a data stream of length. Will force system thread to exit until
/// it is restarted /// it is restarted
@@ -78,7 +81,7 @@ impl AniMeZbus {
/// Set base brightness level /// Set base brightness level
#[zbus(property)] #[zbus(property)]
async fn brightness(&self) -> Brightness { async fn brightness(&self) -> Brightness {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.display_brightness; return config.display_brightness;
} }
Brightness::Off Brightness::Off
@@ -110,7 +113,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn builtins_enabled(&self) -> bool { async fn builtins_enabled(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.builtin_anims_enabled; return config.builtin_anims_enabled;
} }
false false
@@ -155,7 +158,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn builtin_animations(&self) -> Animations { async fn builtin_animations(&self) -> Animations {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.builtin_anims; return config.builtin_anims;
} }
Animations::default() Animations::default()
@@ -166,10 +169,7 @@ impl AniMeZbus {
async fn set_builtin_animations(&self, settings: Animations) { async fn set_builtin_animations(&self, settings: Animations) {
self.0 self.0
.write_bytes(&pkt_set_builtin_animations( .write_bytes(&pkt_set_builtin_animations(
settings.boot, settings.boot, settings.awake, settings.sleep, settings.shutdown,
settings.awake,
settings.sleep,
settings.shutdown,
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -191,7 +191,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn enable_display(&self) -> bool { async fn enable_display(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.display_enabled; return config.display_enabled;
} }
false false
@@ -214,7 +214,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn off_when_unplugged(&self) -> bool { async fn off_when_unplugged(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.off_when_unplugged; return config.off_when_unplugged;
} }
false false
@@ -241,7 +241,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn off_when_suspended(&self) -> bool { async fn off_when_suspended(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.off_when_suspended; return config.off_when_suspended;
} }
false false
@@ -257,7 +257,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn off_when_lid_closed(&self) -> bool { async fn off_when_lid_closed(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.off_when_lid_closed; return config.off_when_lid_closed;
} }
false false
@@ -443,53 +443,60 @@ impl crate::CtrlTask for AniMeZbus {
impl crate::Reloadable for AniMeZbus { impl crate::Reloadable for AniMeZbus {
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
if let Ok(config) = self.0.config.try_lock() { let AniMeConfig {
let anim = &config.builtin_anims; builtin_anims_enabled,
// Set builtins builtin_anims,
if config.builtin_anims_enabled { display_enabled,
self.0 display_brightness,
.write_bytes(&pkt_set_builtin_animations( off_when_lid_closed,
anim.boot, off_when_unplugged,
anim.awake, ..
anim.sleep, } = *self.0.config.lock().await;
anim.shutdown,
)) // Set builtins
.await?; if builtin_anims_enabled {
}
// Builtins enabled or na?
self.0 self.0
.set_builtins_enabled(config.builtin_anims_enabled, config.display_brightness) .write_bytes(&pkt_set_builtin_animations(
builtin_anims.boot,
builtin_anims.awake,
builtin_anims.sleep,
builtin_anims.shutdown,
))
.await?; .await?;
}
// Builtins enabled or na?
self.0
.set_builtins_enabled(builtin_anims_enabled, display_brightness)
.await?;
let manager = get_logind_manager().await; let manager = get_logind_manager().await;
let lid_closed = manager.lid_closed().await.unwrap_or_default(); let lid_closed = manager.lid_closed().await.unwrap_or_default();
let power_plugged = manager.on_external_power().await.unwrap_or_default(); let power_plugged = manager.on_external_power().await.unwrap_or_default();
let turn_off = (lid_closed && config.off_when_lid_closed) let turn_off =
|| (!power_plugged && config.off_when_unplugged); (lid_closed && off_when_lid_closed) || (!power_plugged && off_when_unplugged);
self.0
.write_bytes(&pkt_set_enable_display(!turn_off))
.await
.map_err(|err| {
warn!("create_sys_event_tasks::reload {}", err);
})
.ok();
if turn_off || !display_enabled {
self.0.write_bytes(&pkt_set_enable_display(false)).await?;
// early return so we don't run animation thread
return Ok(());
}
if !builtin_anims_enabled && !self.0.cache.boot.is_empty() {
self.0 self.0
.write_bytes(&pkt_set_enable_display(!turn_off)) .write_bytes(&pkt_set_enable_powersave_anim(false))
.await .await
.map_err(|err| {
warn!("create_sys_event_tasks::reload {}", err);
})
.ok(); .ok();
if turn_off || !config.display_enabled { let action = self.0.cache.boot.clone();
self.0.write_bytes(&pkt_set_enable_display(false)).await?; self.0.run_thread(action, true).await;
// early return so we don't run animation thread
return Ok(());
}
if !config.builtin_anims_enabled && !self.0.cache.boot.is_empty() {
self.0
.write_bytes(&pkt_set_enable_powersave_anim(false))
.await
.ok();
let action = self.0.cache.boot.clone();
self.0.run_thread(action, true).await;
}
} }
Ok(()) Ok(())
} }
+50 -74
View File
@@ -294,38 +294,26 @@ mod tests {
let res = config.multizone.unwrap(); let res = config.multizone.unwrap();
let sta = res.get(&AuraModeNum::Static).unwrap(); let sta = res.get(&AuraModeNum::Static).unwrap();
assert_eq!(sta.len(), 4); assert_eq!(sta.len(), 4);
assert_eq!( assert_eq!(sta[0].colour1, Colour {
sta[0].colour1, r: 0xff,
Colour { g: 0x00,
r: 0xff, b: 0xff
g: 0x00, });
b: 0xff assert_eq!(sta[1].colour1, Colour {
} r: 0x00,
); g: 0xff,
assert_eq!( b: 0xff
sta[1].colour1, });
Colour { assert_eq!(sta[2].colour1, Colour {
r: 0x00, r: 0xff,
g: 0xff, g: 0xff,
b: 0xff b: 0x00
} });
); assert_eq!(sta[3].colour1, Colour {
assert_eq!( r: 0x00,
sta[2].colour1, g: 0xff,
Colour { b: 0x00
r: 0xff, });
g: 0xff,
b: 0x00
}
);
assert_eq!(
sta[3].colour1,
Colour {
r: 0x00,
g: 0xff,
b: 0x00
}
);
} }
#[test] #[test]
@@ -383,28 +371,22 @@ mod tests {
assert_eq!(config.brightness, LedBrightness::Med); assert_eq!(config.brightness, LedBrightness::Med);
assert_eq!(config.builtins.len(), 5); assert_eq!(config.builtins.len(), 5);
assert_eq!( assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
config.builtins.first_entry().unwrap().get(), mode: AuraModeNum::Static,
&AuraEffect { zone: AuraZone::None,
mode: AuraModeNum::Static, colour1: Colour { r: 166, g: 0, b: 0 },
zone: AuraZone::None, colour2: Colour { r: 0, g: 0, b: 0 },
colour1: Colour { r: 166, g: 0, b: 0 }, speed: Speed::Med,
colour2: Colour { r: 0, g: 0, b: 0 }, direction: Direction::Right
speed: Speed::Med, });
direction: Direction::Right
}
);
assert_eq!(config.enabled.states.len(), 1); assert_eq!(config.enabled.states.len(), 1);
assert_eq!( assert_eq!(config.enabled.states[0], AuraPowerState {
config.enabled.states[0], zone: PowerZones::KeyboardAndLightbar,
AuraPowerState { boot: true,
zone: PowerZones::KeyboardAndLightbar, awake: true,
boot: true, sleep: true,
awake: true, shutdown: true
sleep: true, });
shutdown: true
}
);
} }
#[test] #[test]
@@ -414,27 +396,21 @@ mod tests {
assert_eq!(config.brightness, LedBrightness::Med); assert_eq!(config.brightness, LedBrightness::Med);
assert_eq!(config.builtins.len(), 12); assert_eq!(config.builtins.len(), 12);
assert_eq!( assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
config.builtins.first_entry().unwrap().get(), mode: AuraModeNum::Static,
&AuraEffect { zone: AuraZone::None,
mode: AuraModeNum::Static, colour1: Colour { r: 166, g: 0, b: 0 },
zone: AuraZone::None, colour2: Colour { r: 0, g: 0, b: 0 },
colour1: Colour { r: 166, g: 0, b: 0 }, speed: Speed::Med,
colour2: Colour { r: 0, g: 0, b: 0 }, direction: Direction::Right
speed: Speed::Med, });
direction: Direction::Right
}
);
assert_eq!(config.enabled.states.len(), 4); assert_eq!(config.enabled.states.len(), 4);
assert_eq!( assert_eq!(config.enabled.states[0], AuraPowerState {
config.enabled.states[0], zone: PowerZones::Keyboard,
AuraPowerState { boot: true,
zone: PowerZones::Keyboard, awake: true,
boot: true, sleep: true,
awake: true, shutdown: true
sleep: true, });
shutdown: true
}
);
} }
} }
+20 -10
View File
@@ -2,13 +2,13 @@ use std::sync::Arc;
use config::AuraConfig; use config::AuraConfig;
use config_traits::StdConfig; use config_traits::StdConfig;
use futures_util::lock::{Mutex, MutexGuard};
use log::info; use log::info;
use rog_aura::keyboard::{AuraLaptopUsbPackets, LedUsbPackets}; use rog_aura::keyboard::{AuraLaptopUsbPackets, LedUsbPackets};
use rog_aura::usb::{AURA_LAPTOP_LED_APPLY, AURA_LAPTOP_LED_SET}; use rog_aura::usb::{AURA_LAPTOP_LED_APPLY, AURA_LAPTOP_LED_SET};
use rog_aura::{AuraDeviceType, AuraEffect, LedBrightness, PowerZones, AURA_LAPTOP_LED_MSG_LEN}; use rog_aura::{AuraDeviceType, AuraEffect, LedBrightness, PowerZones, AURA_LAPTOP_LED_MSG_LEN};
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::keyboard_led::KeyboardBacklight; use rog_platform::keyboard_led::KeyboardBacklight;
use tokio::sync::{Mutex, MutexGuard};
use crate::error::RogError; use crate::error::RogError;
@@ -96,11 +96,7 @@ impl Aura {
if matches!(dev_type, AuraDeviceType::LaptopKeyboardTuf) { if matches!(dev_type, AuraDeviceType::LaptopKeyboardTuf) {
if let Some(platform) = &self.backlight { if let Some(platform) = &self.backlight {
let buf = [ let buf = [
1, 1, mode.mode as u8, mode.colour1.r, mode.colour1.g, mode.colour1.b,
mode.mode as u8,
mode.colour1.r,
mode.colour1.g,
mode.colour1.b,
mode.speed as u8, mode.speed as u8,
]; ];
platform.lock().await.set_kbd_rgb_mode(&buf)?; platform.lock().await.set_kbd_rgb_mode(&buf)?;
@@ -142,14 +138,24 @@ impl Aura {
let hid_raw = hid_raw.lock().await; let hid_raw = hid_raw.lock().await;
if let Some(p) = config.enabled.states.first() { if let Some(p) = config.enabled.states.first() {
if p.zone == PowerZones::Ally { if p.zone == PowerZones::Ally {
let msg = [0x5d, 0xd1, 0x09, 0x01, p.new_to_byte() as u8, 0x0, 0x0]; let msg = [
0x5d,
0xd1,
0x09,
0x01,
p.new_to_byte() as u8,
0x0,
0x0,
];
hid_raw.write_bytes(&msg)?; hid_raw.write_bytes(&msg)?;
return Ok(()); return Ok(());
} }
} }
let bytes = config.enabled.to_bytes(config.led_type); let bytes = config.enabled.to_bytes(config.led_type);
let msg = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]]; let msg = [
0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3],
];
hid_raw.write_bytes(&msg)?; hid_raw.write_bytes(&msg)?;
} }
Ok(()) Ok(())
@@ -194,7 +200,9 @@ impl Aura {
let r = row[9]; let r = row[9];
let g = row[10]; let g = row[10];
let b = row[11]; let b = row[11];
tuf.lock().await.set_kbd_rgb_mode(&[0, 0, r, g, b, 0])?; tuf.lock().await.set_kbd_rgb_mode(&[
0, 0, r, g, b, 0,
])?;
} }
} }
} }
@@ -206,7 +214,9 @@ impl Aura {
if let Some(hid_raw) = &self.hid { if let Some(hid_raw) = &self.hid {
let mut config = self.config.lock().await; let mut config = self.config.lock().await;
if config.ally_fix.is_none() { if config.ally_fix.is_none() {
let msg = [0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff]; let msg = [
0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff,
];
hid_raw.lock().await.write_bytes(&msg)?; hid_raw.lock().await.write_bytes(&msg)?;
info!("Reset Ally power settings to base"); info!("Reset Ally power settings to base");
config.ally_fix = Some(true); config.ally_fix = Some(true);
+5 -5
View File
@@ -14,7 +14,7 @@ use crate::error::RogError;
use crate::{CtrlTask, Reloadable}; use crate::{CtrlTask, Reloadable};
pub const AURA_ZBUS_NAME: &str = "Aura"; pub const AURA_ZBUS_NAME: &str = "Aura";
pub const AURA_ZBUS_PATH: &str = "/org/asuslinux"; pub const AURA_ZBUS_PATH: &str = "/xyz/ljones";
#[derive(Clone)] #[derive(Clone)]
pub struct AuraZbus(Aura); pub struct AuraZbus(Aura);
@@ -50,7 +50,7 @@ impl AuraZbus {
/// The main interface for changing, reading, or notfying /// The main interface for changing, reading, or notfying
/// ///
/// LED commands are split between Brightness, Modes, Per-Key /// LED commands are split between Brightness, Modes, Per-Key
#[interface(name = "org.asuslinux.Aura")] #[interface(name = "xyz.ljones.Aura")]
impl AuraZbus { impl AuraZbus {
/// Return the device type for this Aura keyboard /// Return the device type for this Aura keyboard
#[zbus(property)] #[zbus(property)]
@@ -112,7 +112,7 @@ impl AuraZbus {
// entirely possible to deadlock here, so use try instead of lock() // entirely possible to deadlock here, so use try instead of lock()
// let ctrl = self.0.lock().await; // let ctrl = self.0.lock().await;
// Ok(config.current_mode) // Ok(config.current_mode)
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
Ok(config.current_mode) Ok(config.current_mode)
} else { } else {
Err(ZbErr::Failed("Aura control couldn't lock self".to_string())) Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
@@ -140,7 +140,7 @@ impl AuraZbus {
#[zbus(property)] #[zbus(property)]
async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> { async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> {
// entirely possible to deadlock here, so use try instead of lock() // entirely possible to deadlock here, so use try instead of lock()
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
let mode = config.current_mode; let mode = config.current_mode;
match config.builtins.get(&mode) { match config.builtins.get(&mode) {
Some(effect) => Ok(effect.clone()), Some(effect) => Ok(effect.clone()),
@@ -227,7 +227,7 @@ impl AuraZbus {
impl CtrlTask for AuraZbus { impl CtrlTask for AuraZbus {
fn zbus_path() -> &'static str { fn zbus_path() -> &'static str {
"/org/asuslinux" "/xyz/ljones"
} }
async fn create_tasks(&self, _: SignalEmitter<'static>) -> Result<(), RogError> { async fn create_tasks(&self, _: SignalEmitter<'static>) -> Result<(), RogError> {
+34 -35
View File
@@ -8,11 +8,11 @@ use std::sync::Arc;
use dmi_id::DMIID; use dmi_id::DMIID;
use futures_lite::future::block_on; use futures_lite::future::block_on;
use futures_util::lock::Mutex;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use mio::{Events, Interest, Poll, Token}; use mio::{Events, Interest, Poll, Token};
use rog_platform::error::PlatformError; use rog_platform::error::PlatformError;
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use tokio::sync::Mutex;
use udev::{Device, MonitorBuilder}; use udev::{Device, MonitorBuilder};
use zbus::zvariant::{ObjectPath, OwnedObjectPath}; use zbus::zvariant::{ObjectPath, OwnedObjectPath};
use zbus::Connection; use zbus::Connection;
@@ -23,8 +23,9 @@ use crate::aura_scsi::trait_impls::ScsiZbus;
use crate::aura_slash::trait_impls::SlashZbus; use crate::aura_slash::trait_impls::SlashZbus;
use crate::aura_types::DeviceHandle; use crate::aura_types::DeviceHandle;
use crate::error::RogError; use crate::error::RogError;
use crate::ASUS_ZBUS_PATH;
pub const ASUS_ZBUS_PATH: &str = "/org/asuslinux"; const MOD_NAME: &str = "aura";
/// Returns only the Device details concatenated in a form usable for /// Returns only the Device details concatenated in a form usable for
/// adding/appending to a filename /// adding/appending to a filename
@@ -54,26 +55,27 @@ pub fn filename_partial(parent: &Device) -> Option<OwnedObjectPath> {
fn dbus_path_for_dev(parent: &Device) -> Option<OwnedObjectPath> { fn dbus_path_for_dev(parent: &Device) -> Option<OwnedObjectPath> {
if let Some(filename) = filename_partial(parent) { if let Some(filename) = filename_partial(parent) {
return Some( return Some(
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{filename}")).into(), ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{filename}"))
.into(),
); );
} }
None None
} }
fn dbus_path_for_tuf() -> OwnedObjectPath { fn dbus_path_for_tuf() -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/tuf")).into() ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/tuf")).into()
} }
fn dbus_path_for_slash() -> OwnedObjectPath { fn dbus_path_for_slash() -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/slash")).into() ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/slash")).into()
} }
fn dbus_path_for_anime() -> OwnedObjectPath { fn dbus_path_for_anime() -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/anime")).into() ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/anime")).into()
} }
fn dbus_path_for_scsi(prod_id: &str) -> OwnedObjectPath { fn dbus_path_for_scsi(prod_id: &str) -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{prod_id}_scsi")).into() ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{prod_id}_scsi")).into()
} }
fn dev_prop_matches(dev: &Device, prop: &str, value: &str) -> bool { fn dev_prop_matches(dev: &Device, prop: &str, value: &str) -> bool {
@@ -83,15 +85,6 @@ fn dev_prop_matches(dev: &Device, prop: &str, value: &str) -> bool {
false false
} }
// TODO:
// - make this the HID manager (and universal)
// - *really* need to make most of this actual kernel drivers
// - LED class
// - RGB modes (how, attribute?)
// - power features (how, attribute?)
// - what about per-key stuff?
// - how would the AniMe be exposed? Just a series of LEDs?
/// A device. /// A device.
/// ///
/// Each controller within should track its dbus path so it can be removed if /// Each controller within should track its dbus path so it can be removed if
@@ -220,7 +213,7 @@ impl DeviceManager {
) -> Option<AsusDevice> { ) -> Option<AsusDevice> {
// "ID_MODEL_ID" "1932" // "ID_MODEL_ID" "1932"
// "ID_VENDOR_ID" "0b05" // "ID_VENDOR_ID" "0b05"
if dev_prop_matches(&device, "ID_VENDOR_ID", "0b05") { if dev_prop_matches(device, "ID_VENDOR_ID", "0b05") {
if let Some(dev_node) = device.devnode() { if let Some(dev_node) = device.devnode() {
let prod_id = device let prod_id = device
.property_value("ID_MODEL_ID") .property_value("ID_MODEL_ID")
@@ -275,7 +268,7 @@ impl DeviceManager {
found.push(path); found.push(path);
} }
} else { } else {
warn!("No serial for SCSI device"); debug!("No serial for SCSI device: {:?}", device.devpath());
} }
} }
@@ -326,11 +319,17 @@ impl DeviceManager {
if let DeviceHandle::AniMe(anime) = dev_type.clone() { if let DeviceHandle::AniMe(anime) = dev_type.clone() {
let path = dbus_path_for_anime(); let path = dbus_path_for_anime();
let ctrl = AniMeZbus::new(anime); let ctrl = AniMeZbus::new(anime);
ctrl.start_tasks(connection, path.clone()).await.unwrap(); if ctrl
devices.push(AsusDevice { .start_tasks(connection, path.clone())
device: dev_type, .await
dbus_path: path, .map_err(|e| error!("Failed to start tasks: {e:?}, not adding this device"))
}); .is_ok()
{
devices.push(AsusDevice {
device: dev_type,
dbus_path: path,
});
}
} }
} else { } else {
info!("Tested device was not AniMe Matrix"); info!("Tested device was not AniMe Matrix");
@@ -371,7 +370,9 @@ impl DeviceManager {
pub async fn new(connection: Connection) -> Result<Self, RogError> { pub async fn new(connection: Connection) -> Result<Self, RogError> {
let conn_copy = connection.clone(); let conn_copy = connection.clone();
let devices = Arc::new(Mutex::new(Self::find_all_devices(&conn_copy).await)); let devices = Self::find_all_devices(&conn_copy).await;
info!("Found {} valid devices on startup", devices.len());
let devices = Arc::new(Mutex::new(devices));
let manager = Self { let manager = Self {
_dbus_connection: connection, _dbus_connection: connection,
}; };
@@ -379,8 +380,6 @@ impl DeviceManager {
// TODO: The /sysfs/ LEDs don't cause events, so they need to be manually // TODO: The /sysfs/ LEDs don't cause events, so they need to be manually
// checked for and added // checked for and added
// detect all plugged in aura devices (eventually)
// only USB devices are detected for here
std::thread::spawn(move || { std::thread::spawn(move || {
let mut monitor = MonitorBuilder::new()?.listen()?; let mut monitor = MonitorBuilder::new()?.listen()?;
let mut poll = Poll::new()?; let mut poll = Poll::new()?;
@@ -427,20 +426,20 @@ impl DeviceManager {
{ {
index index
} else { } else {
warn!("No device for dbus path: {path:?}"); if dev_prop_matches(&event.device(), "ID_VENDOR_ID", "0b05")
{
warn!("No device for dbus path: {path:?}");
}
return Ok(()); return Ok(());
}; };
info!("removing: {path:?}"); info!("removing: {path:?}");
let dev = devices.lock().await.remove(index); let dev = devices.lock().await.remove(index);
let path = path.clone(); let path = path.clone();
match dev.device { if let DeviceHandle::Scsi(_) = dev.device {
DeviceHandle::Scsi(_) => { conn_copy
conn_copy .object_server()
.object_server() .remove::<ScsiZbus, _>(&path)
.remove::<ScsiZbus, _>(&path) .await?;
.await?;
}
_ => {}
} }
} }
} else if action == "add" { } else if action == "add" {
+1 -1
View File
@@ -1,8 +1,8 @@
use std::sync::Arc; use std::sync::Arc;
use config::ScsiConfig; use config::ScsiConfig;
use futures_util::lock::{Mutex, MutexGuard};
use rog_scsi::{AuraEffect, Device, Task}; use rog_scsi::{AuraEffect, Device, Task};
use tokio::sync::{Mutex, MutexGuard};
use crate::error::RogError; use crate::error::RogError;
+2 -2
View File
@@ -34,7 +34,7 @@ impl ScsiZbus {
} }
} }
#[interface(name = "org.asuslinux.ScsiAura")] #[interface(name = "xyz.ljones.ScsiAura")]
impl ScsiZbus { impl ScsiZbus {
/// Return the device type for this Aura keyboard /// Return the device type for this Aura keyboard
#[zbus(property)] #[zbus(property)]
@@ -83,7 +83,7 @@ impl ScsiZbus {
#[zbus(property)] #[zbus(property)]
async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> { async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> {
// entirely possible to deadlock here, so use try instead of lock() // entirely possible to deadlock here, so use try instead of lock()
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
let mode = config.current_mode; let mode = config.current_mode;
match config.modes.get(&mode) { match config.modes.get(&mode) {
Some(effect) => Ok(effect.clone()), Some(effect) => Ok(effect.clone()),
+22 -12
View File
@@ -9,20 +9,30 @@ const CONFIG_FILE: &str = "slash.ron";
pub struct SlashConfig { pub struct SlashConfig {
#[serde(skip)] #[serde(skip)]
pub slash_type: SlashType, pub slash_type: SlashType,
pub slash_enabled: bool, pub enabled: bool,
pub slash_brightness: u8, pub brightness: u8,
pub slash_interval: u8, pub display_interval: u8,
pub slash_mode: SlashMode, pub display_mode: SlashMode,
pub show_on_boot: bool,
pub show_on_shutdown: bool,
pub show_on_sleep: bool,
pub show_on_battery: bool,
pub show_battery_warning: bool,
} }
impl Default for SlashConfig { impl Default for SlashConfig {
fn default() -> Self { fn default() -> Self {
SlashConfig { SlashConfig {
slash_enabled: true, enabled: true,
slash_brightness: 255, brightness: 255,
slash_interval: 0, display_interval: 0,
slash_mode: SlashMode::Bounce, display_mode: SlashMode::Bounce,
slash_type: SlashType::Unsupported, slash_type: SlashType::Unsupported,
show_on_boot: true,
show_on_shutdown: true,
show_on_sleep: true,
show_on_battery: true,
show_battery_warning: true,
} }
} }
} }
@@ -45,10 +55,10 @@ impl StdConfigLoad for SlashConfig {}
impl From<&SlashConfig> for DeviceState { impl From<&SlashConfig> for DeviceState {
fn from(config: &SlashConfig) -> Self { fn from(config: &SlashConfig) -> Self {
DeviceState { DeviceState {
slash_enabled: config.slash_enabled, slash_enabled: config.enabled,
slash_brightness: config.slash_brightness, slash_brightness: config.brightness,
slash_interval: config.slash_interval, slash_interval: config.display_interval,
slash_mode: config.slash_mode, slash_mode: config.display_mode,
} }
} }
} }
+7 -7
View File
@@ -1,11 +1,11 @@
use std::sync::Arc; use std::sync::Arc;
use config::SlashConfig; use config::SlashConfig;
use futures_util::lock::{Mutex, MutexGuard};
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw; use rog_platform::usb_raw::USBRaw;
use rog_slash::usb::{pkt_set_mode, pkt_set_options, pkts_for_init}; use rog_slash::usb::{get_options_packet, pkt_set_mode, pkts_for_init};
use rog_slash::SlashType; use rog_slash::SlashType;
use tokio::sync::{Mutex, MutexGuard};
use crate::error::RogError; use crate::error::RogError;
@@ -53,15 +53,15 @@ impl Slash {
} }
// Apply config upon initialization // Apply config upon initialization
let option_packets = pkt_set_options( let option_packets = get_options_packet(
config.slash_type, config.slash_type,
config.slash_enabled, config.enabled,
config.slash_brightness, config.brightness,
config.slash_interval, config.display_interval,
); );
self.write_bytes(&option_packets).await?; self.write_bytes(&option_packets).await?;
let mode_packets = pkt_set_mode(config.slash_type, config.slash_mode); let mode_packets = pkt_set_mode(config.slash_type, config.display_mode);
// self.node.write_bytes(&mode_packets[0])?; // self.node.write_bytes(&mode_packets[0])?;
self.write_bytes(&mode_packets[1]).await?; self.write_bytes(&mode_packets[1]).await?;
+142 -45
View File
@@ -1,6 +1,9 @@
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{debug, error, warn}; use log::{debug, error, warn};
use rog_slash::usb::{pkt_save, pkt_set_mode, pkt_set_options}; use rog_slash::usb::{
get_battery_saver_packet, get_boot_packet, get_low_battery_packet, get_options_packet,
get_shutdown_packet, get_sleep_packet, pkt_save, pkt_set_mode,
};
use rog_slash::{DeviceState, SlashMode}; use rog_slash::{DeviceState, SlashMode};
use zbus::zvariant::OwnedObjectPath; use zbus::zvariant::OwnedObjectPath;
use zbus::{interface, Connection}; use zbus::{interface, Connection};
@@ -36,30 +39,30 @@ impl SlashZbus {
} }
} }
#[interface(name = "org.asuslinux.Slash")] #[interface(name = "xyz.ljones.Slash")]
impl SlashZbus { impl SlashZbus {
/// Get enabled or not /// Get enabled or not
#[zbus(property)] #[zbus(property)]
async fn enabled(&self) -> bool { async fn enabled(&self) -> bool {
let lock = self.0.lock_config().await; let lock = self.0.lock_config().await;
lock.slash_enabled lock.enabled
} }
/// Set enabled true or false /// Set enabled true or false
#[zbus(property)] #[zbus(property)]
async fn set_enabled(&self, enabled: bool) { async fn set_enabled(&self, enabled: bool) {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
let brightness = if enabled && config.slash_brightness == 0 { let brightness = if enabled && config.brightness == 0 {
0x88 0x88
} else { } else {
config.slash_brightness config.brightness
}; };
self.0 self.0
.write_bytes(&pkt_set_options( .write_bytes(&get_options_packet(
config.slash_type, config.slash_type,
enabled, enabled,
brightness, brightness,
config.slash_interval, config.display_interval,
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -67,8 +70,8 @@ impl SlashZbus {
}) })
.ok(); .ok();
config.slash_enabled = enabled; config.enabled = enabled;
config.slash_brightness = brightness; config.brightness = brightness;
config.write(); config.write();
} }
@@ -76,7 +79,7 @@ impl SlashZbus {
#[zbus(property)] #[zbus(property)]
async fn brightness(&self) -> u8 { async fn brightness(&self) -> u8 {
let config = self.0.lock_config().await; let config = self.0.lock_config().await;
config.slash_brightness config.brightness
} }
/// Set brightness level /// Set brightness level
@@ -85,11 +88,11 @@ impl SlashZbus {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
let enabled = brightness > 0; let enabled = brightness > 0;
self.0 self.0
.write_bytes(&pkt_set_options( .write_bytes(&get_options_packet(
config.slash_type, config.slash_type,
enabled, enabled,
brightness, brightness,
config.slash_interval, config.display_interval,
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -97,15 +100,15 @@ impl SlashZbus {
}) })
.ok(); .ok();
config.slash_enabled = enabled; config.enabled = enabled;
config.slash_brightness = brightness; config.brightness = brightness;
config.write(); config.write();
} }
#[zbus(property)] #[zbus(property)]
async fn interval(&self) -> u8 { async fn interval(&self) -> u8 {
let config = self.0.lock_config().await; let config = self.0.lock_config().await;
config.slash_interval config.display_interval
} }
/// Set interval between slash animations (0-255) /// Set interval between slash animations (0-255)
@@ -113,11 +116,8 @@ impl SlashZbus {
async fn set_interval(&self, interval: u8) { async fn set_interval(&self, interval: u8) {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
self.0 self.0
.write_bytes(&pkt_set_options( .write_bytes(&get_options_packet(
config.slash_type, config.slash_type, config.enabled, config.brightness, interval,
config.slash_enabled,
config.slash_brightness,
interval,
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -125,40 +125,29 @@ impl SlashZbus {
}) })
.ok(); .ok();
config.slash_interval = interval; config.display_interval = interval;
config.write(); config.write();
} }
#[zbus(property)] #[zbus(property)]
async fn slash_mode(&self) -> u8 { async fn mode(&self) -> zbus::fdo::Result<u8> {
let config = self.0.lock_config().await; let config = self.0.lock_config().await;
config.slash_interval Ok(config.display_interval)
} }
/// Set interval between slash animations (0-255) /// Set interval between slash animations (0-255)
#[zbus(property)] #[zbus(property)]
async fn set_slash_mode(&self, slash_mode: SlashMode) { async fn set_mode(&self, mode: SlashMode) -> zbus::Result<()> {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
let command_packets = pkt_set_mode(config.slash_type, slash_mode); let command_packets = pkt_set_mode(config.slash_type, mode);
// self.node.write_bytes(&command_packets[0])?; // self.node.write_bytes(&command_packets[0])?;
self.0 self.0.write_bytes(&command_packets[1]).await?;
.write_bytes(&command_packets[1]) self.0.write_bytes(&pkt_save(config.slash_type)).await?;
.await
.map_err(|err| {
warn!("ctrl_slash::set_options {}", err);
})
.ok();
self.0
.write_bytes(&pkt_save(config.slash_type))
.await
.map_err(|err| {
warn!("ctrl_slash::set_options {}", err);
})
.ok();
config.slash_mode = slash_mode; config.display_mode = mode;
config.write(); config.write();
Ok(())
} }
/// Get the device state as stored by asusd /// Get the device state as stored by asusd
@@ -167,6 +156,91 @@ impl SlashZbus {
let config = self.0.lock_config().await; let config = self.0.lock_config().await;
DeviceState::from(&*config) DeviceState::from(&*config)
} }
#[zbus(property)]
async fn show_on_boot(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_boot)
}
#[zbus(property)]
async fn set_show_on_boot(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_boot_packet(config.slash_type, enable))
.await?;
config.show_on_boot = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_on_sleep(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_sleep)
}
#[zbus(property)]
async fn set_show_on_sleep(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_sleep_packet(config.slash_type, enable))
.await?;
config.show_on_sleep = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_on_shutdown(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_shutdown)
}
#[zbus(property)]
async fn set_show_on_shutdown(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_shutdown_packet(config.slash_type, enable))
.await?;
config.show_on_shutdown = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_on_battery(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_battery)
}
#[zbus(property)]
async fn set_show_on_battery(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_battery_saver_packet(config.slash_type, enable))
.await?;
config.show_on_battery = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_battery_warning(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_battery_warning)
}
#[zbus(property)]
async fn set_show_battery_warning(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_low_battery_packet(config.slash_type, enable))
.await?;
config.show_battery_warning = enable;
config.write();
Ok(())
}
} }
impl Reloadable for SlashZbus { impl Reloadable for SlashZbus {
@@ -174,17 +248,40 @@ impl Reloadable for SlashZbus {
debug!("reloading slash settings"); debug!("reloading slash settings");
let config = self.0.lock_config().await; let config = self.0.lock_config().await;
self.0 self.0
.write_bytes(&pkt_set_options( .write_bytes(&get_options_packet(
config.slash_type, config.slash_type,
config.slash_enabled, config.enabled,
config.slash_brightness, config.brightness,
config.slash_interval, config.display_interval,
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
warn!("ctrl_slash::set_options {}", err); warn!("set_options {}", err);
}) })
.ok(); .ok();
macro_rules! write_bytes_with_warning {
($packet_fn:expr, $cfg:ident, $warn_msg:expr) => {
self.0
.write_bytes(&$packet_fn(config.slash_type, config.$cfg))
.await
.map_err(|err| {
warn!("{} {}", $warn_msg, err);
})
.ok();
};
}
write_bytes_with_warning!(get_boot_packet, show_on_boot, "show_on_boot");
write_bytes_with_warning!(get_sleep_packet, show_on_sleep, "show_on_sleep");
write_bytes_with_warning!(get_shutdown_packet, show_on_shutdown, "show_on_shutdown");
write_bytes_with_warning!(get_battery_saver_packet, show_on_battery, "show_on_battery");
write_bytes_with_warning!(
get_low_battery_packet,
show_battery_warning,
"show_battery_warning"
);
Ok(()) Ok(())
} }
} }
+21 -16
View File
@@ -1,6 +1,7 @@
use std::sync::Arc; use std::sync::Arc;
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use futures_util::lock::Mutex;
use log::{debug, error, info}; use log::{debug, error, info};
use rog_anime::error::AnimeError; use rog_anime::error::AnimeError;
use rog_anime::usb::get_anime_type; use rog_anime::usb::get_anime_type;
@@ -12,7 +13,6 @@ use rog_platform::usb_raw::USBRaw;
use rog_scsi::{open_device, ScsiType}; use rog_scsi::{open_device, ScsiType};
use rog_slash::error::SlashError; use rog_slash::error::SlashError;
use rog_slash::SlashType; use rog_slash::SlashType;
use tokio::sync::Mutex;
use crate::aura_anime::config::AniMeConfig; use crate::aura_anime::config::AniMeConfig;
use crate::aura_anime::AniMe; use crate::aura_anime::AniMe;
@@ -104,23 +104,28 @@ impl DeviceHandle {
/// Try AniMe Matrix HID. If one exists it is initialsed and returned. /// Try AniMe Matrix HID. If one exists it is initialsed and returned.
pub async fn maybe_anime_hid( pub async fn maybe_anime_hid(
device: Arc<Mutex<HidRaw>>, _device: Arc<Mutex<HidRaw>>,
prod_id: &str, _prod_id: &str,
) -> Result<Self, RogError> { ) -> Result<Self, RogError> {
debug!("Testing for HIDRAW AniMe"); // TODO: can't use HIDRAW for anime at the moment
let anime_type = AnimeType::from_dmi(); Err(RogError::NotFound(
dbg!(prod_id); "Can't use anime over hidraw yet. Skip.".to_string(),
if matches!(anime_type, AnimeType::Unsupported) || prod_id != "193b" { ))
log::info!("Unknown or invalid AniMe: {prod_id:?}, skipping");
return Err(RogError::NotFound("No anime-matrix device".to_string()));
}
info!("Found AniMe Matrix HIDRAW {anime_type:?}: {prod_id}");
let mut config = AniMeConfig::new().load(); // debug!("Testing for HIDRAW AniMe");
config.anime_type = anime_type; // let anime_type = AnimeType::from_dmi();
let mut anime = AniMe::new(Some(device), None, Arc::new(Mutex::new(config))); // dbg!(prod_id);
anime.do_initialization().await?; // if matches!(anime_type, AnimeType::Unsupported) || prod_id != "193b"
Ok(Self::AniMe(anime)) // { log::info!("Unknown or invalid AniMe: {prod_id:?},
// skipping"); return Err(RogError::NotFound("No
// anime-matrix device".to_string())); }
// info!("Found AniMe Matrix HIDRAW {anime_type:?}: {prod_id}");
// let mut config = AniMeConfig::new().load();
// config.anime_type = anime_type;
// let mut anime = AniMe::new(Some(device), None,
// Arc::new(Mutex::new(config))); anime.do_initialization().
// await?; Ok(Self::AniMe(anime))
} }
pub async fn maybe_anime_usb() -> Result<Self, RogError> { pub async fn maybe_anime_usb() -> Result<Self, RogError> {
+92 -89
View File
@@ -1,94 +1,87 @@
use std::collections::HashMap;
use config_traits::{StdConfig, StdConfigLoad1}; use config_traits::{StdConfig, StdConfigLoad1};
use rog_platform::asus_armoury::FirmwareAttribute;
use rog_platform::cpu::CPUEPP; use rog_platform::cpu::CPUEPP;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
const CONFIG_FILE: &str = "asusd.ron"; const CONFIG_FILE: &str = "asusd.ron";
#[derive(Deserialize, Serialize, Debug, PartialEq, PartialOrd)] #[derive(Default, Clone, Deserialize, Serialize, PartialEq)]
pub struct Tuning {
pub enabled: bool,
pub group: HashMap<FirmwareAttribute, i32>,
}
type Tunings = HashMap<PlatformProfile, Tuning>;
#[derive(Deserialize, Serialize, PartialEq)]
pub struct Config { pub struct Config {
// The current charge limit applied // The current charge limit applied
pub charge_control_end_threshold: u8, pub charge_control_end_threshold: u8,
/// Save charge limit for restoring /// Save charge limit for restoring
#[serde(skip)] #[serde(skip)]
pub base_charge_control_end_threshold: u8, pub base_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, pub disable_nvidia_powerd_on_battery: bool,
/// An optional command/script to run when power is changed to AC /// An optional command/script to run when power is changed to AC
pub ac_command: String, pub ac_command: String,
/// An optional command/script to run when power is changed to battery /// An optional command/script to run when power is changed to battery
pub bat_command: String, pub bat_command: String,
/// Set true if energy_performance_preference should be set if the /// Set true if energy_performance_preference should be set if the
/// throttle/platform profile is changed /// platform profile is changed
pub throttle_policy_linked_epp: bool, pub platform_profile_linked_epp: bool,
/// Which throttle/profile to use on battery power /// Which platform profile to use on battery power
pub throttle_policy_on_battery: ThrottlePolicy, pub platform_profile_on_battery: PlatformProfile,
/// Should the throttle policy be set on bat/ac change? /// Should the throttle policy be set on bat/ac change?
pub change_throttle_policy_on_battery: bool, pub change_platform_profile_on_battery: bool,
/// Which throttle/profile to use on AC power /// Which platform profile to use on AC power
pub throttle_policy_on_ac: ThrottlePolicy, pub platform_profile_on_ac: PlatformProfile,
/// Should the throttle policy be set on bat/ac change? /// Should the platform profile be set on bat/ac change?
pub change_throttle_policy_on_ac: bool, pub change_platform_profile_on_ac: bool,
/// The energy_performance_preference for this throttle/platform profile /// The energy_performance_preference for this platform profile
pub throttle_quiet_epp: CPUEPP, pub profile_quiet_epp: CPUEPP,
/// The energy_performance_preference for this throttle/platform profile /// The energy_performance_preference for this platform profile
pub throttle_balanced_epp: CPUEPP, pub profile_balanced_epp: CPUEPP,
/// The energy_performance_preference for this throttle/platform profile /// The energy_performance_preference for this platform profile
pub throttle_performance_epp: CPUEPP, pub profile_performance_epp: CPUEPP,
/// Defaults to `None` if not supported pub ac_profile_tunings: Tunings,
#[serde(skip_serializing_if = "Option::is_none", default)] pub dc_profile_tunings: Tunings,
pub ppt_pl1_spl: Option<u8>, pub armoury_settings: HashMap<FirmwareAttribute, i32>,
/// 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 /// Temporary state for AC/Batt
#[serde(skip)] #[serde(skip)]
pub last_power_plugged: u8, pub last_power_plugged: u8,
} }
impl Config {
pub fn select_tunings(&mut self, power_plugged: bool, profile: PlatformProfile) -> &mut Tuning {
let config = if power_plugged {
&mut self.ac_profile_tunings
} else {
&mut self.dc_profile_tunings
};
config.entry(profile).or_insert_with(Tuning::default)
}
}
impl Default for Config { impl Default for Config {
fn default() -> Self { fn default() -> Self {
Self { Self {
charge_control_end_threshold: 100, charge_control_end_threshold: 100,
base_charge_control_end_threshold: 100, base_charge_control_end_threshold: 100,
panel_od: false,
boot_sound: false,
mini_led_mode: false,
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
ac_command: Default::default(), ac_command: Default::default(),
bat_command: Default::default(), bat_command: Default::default(),
throttle_policy_linked_epp: true, platform_profile_linked_epp: true,
throttle_policy_on_battery: ThrottlePolicy::Quiet, platform_profile_on_battery: PlatformProfile::Quiet,
change_throttle_policy_on_battery: true, change_platform_profile_on_battery: true,
throttle_policy_on_ac: ThrottlePolicy::Performance, platform_profile_on_ac: PlatformProfile::Performance,
change_throttle_policy_on_ac: true, change_platform_profile_on_ac: true,
throttle_quiet_epp: CPUEPP::Power, profile_quiet_epp: CPUEPP::Power,
throttle_balanced_epp: CPUEPP::BalancePower, profile_balanced_epp: CPUEPP::BalancePower,
throttle_performance_epp: CPUEPP::Performance, profile_performance_epp: CPUEPP::Performance,
ppt_pl1_spl: Default::default(), ac_profile_tunings: HashMap::default(),
ppt_pl2_sppt: Default::default(), dc_profile_tunings: HashMap::default(),
ppt_fppt: Default::default(), armoury_settings: HashMap::default(),
ppt_apu_sppt: Default::default(),
ppt_platform_sppt: Default::default(),
nv_dynamic_boost: Default::default(),
nv_temp_target: Default::default(),
last_power_plugged: Default::default(), last_power_plugged: Default::default(),
} }
} }
@@ -99,8 +92,8 @@ impl StdConfig for Config {
Config { Config {
charge_control_end_threshold: 100, charge_control_end_threshold: 100,
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
throttle_policy_on_battery: ThrottlePolicy::Quiet, platform_profile_on_battery: PlatformProfile::Quiet,
throttle_policy_on_ac: ThrottlePolicy::Performance, platform_profile_on_ac: PlatformProfile::Performance,
ac_command: String::new(), ac_command: String::new(),
bat_command: String::new(), bat_command: String::new(),
..Default::default() ..Default::default()
@@ -116,58 +109,68 @@ impl StdConfig for Config {
} }
} }
impl StdConfigLoad1<Config507> for Config {} impl StdConfigLoad1<Config601> for Config {}
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
pub struct Config507 { pub struct Config601 {
// The current charge limit applied
pub charge_control_end_threshold: u8, pub charge_control_end_threshold: u8,
#[serde(skip)]
pub base_charge_control_end_threshold: u8,
pub panel_od: bool, pub panel_od: bool,
pub boot_sound: bool,
pub mini_led_mode: bool, pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool, pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String, pub ac_command: String,
pub bat_command: String, pub bat_command: String,
pub platform_policy_linked_epp: bool, pub platform_profile_linked_epp: bool,
pub platform_policy_on_battery: ThrottlePolicy, pub platform_profile_on_battery: PlatformProfile,
pub platform_policy_on_ac: ThrottlePolicy, pub change_platform_profile_on_battery: bool,
// pub platform_profile_on_ac: PlatformProfile,
pub change_platform_profile_on_ac: bool,
pub profile_quiet_epp: CPUEPP,
pub profile_balanced_epp: CPUEPP,
pub profile_performance_epp: CPUEPP,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl1_spl: Option<u8>, pub ppt_pl1_spl: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl2_sppt: Option<u8>, pub ppt_pl2_sppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl3_fppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_fppt: Option<u8>, pub ppt_fppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_apu_sppt: Option<u8>, pub ppt_apu_sppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_platform_sppt: Option<u8>, pub ppt_platform_sppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub nv_dynamic_boost: Option<u8>, pub nv_dynamic_boost: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub nv_temp_target: Option<u8>, pub nv_temp_target: Option<u8>,
#[serde(skip)]
pub last_power_plugged: u8,
} }
impl From<Config507> for Config { impl From<Config601> for Config {
fn from(c: Config507) -> Self { fn from(c: Config601) -> Self {
Self { Self {
// Restore the base charge limit // Restore the base charge limit
charge_control_end_threshold: c.charge_control_end_threshold, charge_control_end_threshold: c.charge_control_end_threshold,
base_charge_control_end_threshold: c.charge_control_end_threshold, base_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, disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
ac_command: c.ac_command, ac_command: c.ac_command,
bat_command: c.bat_command, bat_command: c.bat_command,
mini_led_mode: c.mini_led_mode, platform_profile_linked_epp: c.platform_profile_linked_epp,
throttle_policy_linked_epp: true, platform_profile_on_battery: c.platform_profile_on_battery,
throttle_policy_on_battery: c.platform_policy_on_battery, change_platform_profile_on_battery: c.change_platform_profile_on_battery,
change_throttle_policy_on_battery: true, platform_profile_on_ac: c.platform_profile_on_ac,
throttle_policy_on_ac: c.platform_policy_on_ac, change_platform_profile_on_ac: c.change_platform_profile_on_ac,
change_throttle_policy_on_ac: true, profile_quiet_epp: c.profile_quiet_epp,
throttle_quiet_epp: CPUEPP::Power, profile_balanced_epp: c.profile_balanced_epp,
throttle_balanced_epp: CPUEPP::BalancePower, profile_performance_epp: c.profile_performance_epp,
throttle_performance_epp: CPUEPP::Performance, last_power_plugged: c.last_power_plugged,
ppt_pl1_spl: c.ppt_pl1_spl, ac_profile_tunings: HashMap::default(),
ppt_pl2_sppt: c.ppt_pl2_sppt, dc_profile_tunings: HashMap::default(),
ppt_fppt: c.ppt_fppt, armoury_settings: HashMap::default(),
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,
} }
} }
} }
+39 -34
View File
@@ -3,13 +3,13 @@ use std::sync::Arc;
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use futures_lite::StreamExt; use futures_lite::StreamExt;
use futures_util::lock::Mutex;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::platform::{RogPlatform, ThrottlePolicy}; use rog_platform::platform::{PlatformProfile, RogPlatform};
use rog_profiles::error::ProfileError; use rog_profiles::error::ProfileError;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles}; use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::sync::Mutex;
use zbus::object_server::SignalEmitter; use zbus::object_server::SignalEmitter;
use zbus::{interface, Connection}; use zbus::{interface, Connection};
@@ -17,13 +17,13 @@ use crate::error::RogError;
use crate::{CtrlTask, CONFIG_PATH_BASE}; use crate::{CtrlTask, CONFIG_PATH_BASE};
pub const FAN_CURVE_ZBUS_NAME: &str = "FanCurves"; pub const FAN_CURVE_ZBUS_NAME: &str = "FanCurves";
pub const FAN_CURVE_ZBUS_PATH: &str = "/org/asuslinux"; pub const FAN_CURVE_ZBUS_PATH: &str = "/xyz/ljones";
#[derive(Deserialize, Serialize, Debug, Default)] #[derive(Deserialize, Serialize, Debug, Default)]
pub struct FanCurveConfig { pub struct FanCurveConfig {
pub profiles: FanCurveProfiles, pub profiles: FanCurveProfiles,
#[serde(skip)] #[serde(skip)]
pub current: u8, pub current: PlatformProfile,
} }
impl StdConfig for FanCurveConfig { impl StdConfig for FanCurveConfig {
@@ -54,7 +54,7 @@ pub struct CtrlFanCurveZbus {
impl CtrlFanCurveZbus { impl CtrlFanCurveZbus {
pub fn new() -> Result<Self, RogError> { pub fn new() -> Result<Self, RogError> {
let platform = RogPlatform::new()?; let platform = RogPlatform::new()?;
if platform.has_throttle_thermal_policy() { if platform.has_platform_profile() {
info!("Device has profile control available"); info!("Device has profile control available");
find_fan_curve_node()?; find_fan_curve_node()?;
info!("Device has fan curves available"); info!("Device has fan curves available");
@@ -65,16 +65,16 @@ impl CtrlFanCurveZbus {
if config.profiles.balanced.is_empty() || !config.file_path().exists() { if config.profiles.balanced.is_empty() || !config.file_path().exists() {
info!("Fetching default fan curves"); info!("Fetching default fan curves");
let current = platform.get_throttle_thermal_policy()?; let current = platform.get_platform_profile()?;
for this in [ for this in [
ThrottlePolicy::Balanced, PlatformProfile::Balanced,
ThrottlePolicy::Performance, PlatformProfile::Performance,
ThrottlePolicy::Quiet, PlatformProfile::Quiet,
] { ] {
// For each profile we need to switch to it before we // For each profile we need to switch to it before we
// can read the existing values from hardware. The ACPI method used // can read the existing values from hardware. The ACPI method used
// for this is what limits us. // for this is what limits us.
platform.set_throttle_thermal_policy(this.into())?; platform.set_platform_profile(this.into())?;
let mut dev = find_fan_curve_node()?; let mut dev = find_fan_curve_node()?;
fan_curves.set_active_curve_to_defaults(this, &mut dev)?; fan_curves.set_active_curve_to_defaults(this, &mut dev)?;
@@ -83,7 +83,7 @@ impl CtrlFanCurveZbus {
info!("{}", String::from(curve)); info!("{}", String::from(curve));
} }
} }
platform.set_throttle_thermal_policy(current)?; platform.set_platform_profile(current.as_str())?;
config.profiles = fan_curves; config.profiles = fan_curves;
config.write(); config.write();
} else { } else {
@@ -101,13 +101,13 @@ impl CtrlFanCurveZbus {
} }
} }
#[interface(name = "org.asuslinux.FanCurves")] #[interface(name = "xyz.ljones.FanCurves")]
impl CtrlFanCurveZbus { impl CtrlFanCurveZbus {
/// Set all fan curves for a profile to enabled status. Will also activate a /// Set all fan curves for a profile to enabled status. Will also activate a
/// fan curve if in the same profile mode /// fan curve if in the same profile mode
async fn set_fan_curves_enabled( async fn set_fan_curves_enabled(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
enabled: bool, enabled: bool,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.config self.config
@@ -128,7 +128,7 @@ impl CtrlFanCurveZbus {
/// activate a fan curve if in the same profile mode /// activate a fan curve if in the same profile mode
async fn set_profile_fan_curve_enabled( async fn set_profile_fan_curve_enabled(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool, enabled: bool,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
@@ -149,7 +149,7 @@ impl CtrlFanCurveZbus {
/// Get the fan-curve data for the currently active ThrottlePolicy /// Get the fan-curve data for the currently active ThrottlePolicy
async fn fan_curve_data( async fn fan_curve_data(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
) -> zbus::fdo::Result<Vec<CurveData>> { ) -> zbus::fdo::Result<Vec<CurveData>> {
let curve = self let curve = self
.config .config
@@ -165,7 +165,7 @@ impl CtrlFanCurveZbus {
/// Will also activate the fan curve if the user is in the same mode. /// Will also activate the fan curve if the user is in the same mode.
async fn set_fan_curve( async fn set_fan_curve(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
curve: CurveData, curve: CurveData,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.config self.config
@@ -173,7 +173,7 @@ impl CtrlFanCurveZbus {
.await .await
.profiles .profiles
.save_fan_curve(curve, profile)?; .save_fan_curve(curve, profile)?;
let active: ThrottlePolicy = self.platform.get_throttle_thermal_policy()?.into(); let active: PlatformProfile = self.platform.get_platform_profile()?.into();
if active == profile { if active == profile {
self.config self.config
.lock() .lock()
@@ -190,15 +190,15 @@ impl CtrlFanCurveZbus {
/// ///
/// Each platform_profile has a different default and the default can be /// Each platform_profile has a different default and the default can be
/// read only for the currently active profile. /// read only for the currently active profile.
async fn set_curves_to_defaults(&mut self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> { async fn set_curves_to_defaults(&mut self, profile: PlatformProfile) -> zbus::fdo::Result<()> {
let active = self.platform.get_throttle_thermal_policy()?; let active = self.platform.get_platform_profile()?;
self.platform.set_throttle_thermal_policy(profile.into())?; self.platform.set_platform_profile(profile.into())?;
self.config self.config
.lock() .lock()
.await .await
.profiles .profiles
.set_active_curve_to_defaults(profile, &mut find_fan_curve_node()?)?; .set_active_curve_to_defaults(profile, &mut find_fan_curve_node()?)?;
self.platform.set_throttle_thermal_policy(active)?; self.platform.set_platform_profile(active.as_str())?;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
@@ -208,16 +208,16 @@ impl CtrlFanCurveZbus {
/// ///
/// Each platform_profile has a different default and the defualt can be /// Each platform_profile has a different default and the defualt can be
/// read only for the currently active profile. /// read only for the currently active profile.
async fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> { async fn reset_profile_curves(&self, profile: PlatformProfile) -> zbus::fdo::Result<()> {
let active = self.platform.get_throttle_thermal_policy()?; let active = self.platform.get_platform_profile()?;
self.platform.set_throttle_thermal_policy(profile.into())?; self.platform.set_platform_profile(profile.into())?;
self.config self.config
.lock() .lock()
.await .await
.profiles .profiles
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?; .set_active_curve_to_defaults(active.as_str().into(), &mut find_fan_curve_node()?)?;
self.platform.set_throttle_thermal_policy(active)?; self.platform.set_platform_profile(active.as_str())?;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
@@ -236,26 +236,31 @@ impl CtrlTask for CtrlFanCurveZbus {
} }
async fn create_tasks(&self, _signal_ctxt: SignalEmitter<'static>) -> Result<(), RogError> { async fn create_tasks(&self, _signal_ctxt: SignalEmitter<'static>) -> Result<(), RogError> {
let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?; let watch_platform_profile = self.platform.monitor_platform_profile()?;
let platform = self.platform.clone(); let platform = self.platform.clone();
let config = self.config.clone(); let config = self.config.clone();
let fan_curves = self.config.clone(); let fan_curves = self.config.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut buffer = [0; 32]; let mut buffer = [0; 32];
if let Ok(mut stream) = watch_throttle_thermal_policy.into_event_stream(&mut buffer) { if let Ok(mut stream) = watch_platform_profile.into_event_stream(&mut buffer) {
while (stream.next().await).is_some() { while (stream.next().await).is_some() {
debug!("watch_throttle_thermal_policy changed"); debug!("watch_platform_profile changed");
if let Ok(profile) = platform.get_throttle_thermal_policy().map_err(|e| { if let Ok(profile) =
error!("get_throttle_thermal_policy error: {e}"); platform
}) { .get_platform_profile()
.map(|p| p.into())
.map_err(|e| {
error!("get_platform_profile error: {e}");
})
{
if profile != config.lock().await.current { if profile != config.lock().await.current {
fan_curves fan_curves
.lock() .lock()
.await .await
.profiles .profiles
.write_profile_curve_to_platform( .write_profile_curve_to_platform(
profile.into(), profile,
&mut find_fan_curve_node().unwrap(), &mut find_fan_curve_node().unwrap(),
) )
.map_err(|e| warn!("write_profile_curve_to_platform, {}", e)) .map_err(|e| warn!("write_profile_curve_to_platform, {}", e))
@@ -274,7 +279,7 @@ impl CtrlTask for CtrlFanCurveZbus {
impl crate::Reloadable for CtrlFanCurveZbus { impl crate::Reloadable for CtrlFanCurveZbus {
/// Fetch the active profile and use that to set all related components up /// Fetch the active profile and use that to set all related components up
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
let active = self.platform.get_throttle_thermal_policy()?.into(); let active = self.platform.get_platform_profile()?.into();
let mut config = self.config.lock().await; let mut config = self.config.lock().await;
if let Ok(mut device) = find_fan_curve_node() { if let Ok(mut device) = find_fan_curve_node() {
config config
+273 -487
View File
File diff suppressed because it is too large Load Diff
+30 -15
View File
@@ -2,15 +2,19 @@ use std::env;
use std::error::Error; use std::error::Error;
use std::sync::Arc; use std::sync::Arc;
use ::zbus::export::futures_util::lock::Mutex;
use ::zbus::Connection; use ::zbus::Connection;
use asusd::asus_armoury::start_attributes_zbus;
use asusd::aura_manager::DeviceManager; use asusd::aura_manager::DeviceManager;
use asusd::config::Config; use asusd::config::Config;
use asusd::ctrl_fancurves::CtrlFanCurveZbus; use asusd::ctrl_fancurves::CtrlFanCurveZbus;
use asusd::ctrl_platform::CtrlPlatform; use asusd::ctrl_platform::CtrlPlatform;
use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME}; use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME};
use config_traits::{StdConfig, StdConfigLoad1}; use config_traits::{StdConfig, StdConfigLoad1};
use futures_util::lock::Mutex;
use log::{error, info}; use log::{error, info};
use rog_platform::asus_armoury::FirmwareAttributes;
use rog_platform::platform::RogPlatform;
use rog_platform::power::AsusPower;
use zbus::fdo::ObjectManager; use zbus::fdo::ObjectManager;
#[tokio::main] #[tokio::main]
@@ -56,23 +60,30 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
// println!("{:?}", supported.supported_functions()); // println!("{:?}", supported.supported_functions());
// Start zbus server // Start zbus server
let mut connection = Connection::system().await?; let mut server = Connection::system().await?;
connection server.object_server().at("/", ObjectManager).await.unwrap();
.object_server()
.at("/", ObjectManager)
.await
.unwrap();
let config = Config::new().load(); let config = Config::new().load();
let cfg_path = config.file_path(); let cfg_path = config.file_path();
let config = Arc::new(Mutex::new(config)); let config = Arc::new(Mutex::new(config));
// supported.add_to_server(&mut connection).await; // supported.add_to_server(&mut connection).await;
let platform = RogPlatform::new()?; // TODO: maybe needs async mutex?
let power = AsusPower::new()?; // TODO: maybe needs async mutex?
let attributes = FirmwareAttributes::new();
start_attributes_zbus(
&server,
platform.clone(),
power.clone(),
attributes.clone(),
config.clone(),
)
.await?;
match CtrlFanCurveZbus::new() { match CtrlFanCurveZbus::new() {
Ok(ctrl) => { Ok(ctrl) => {
let sig_ctx = CtrlFanCurveZbus::signal_context(&connection)?; let sig_ctx = CtrlFanCurveZbus::signal_context(&server)?;
start_tasks(ctrl, &mut connection, sig_ctx).await?; start_tasks(ctrl, &mut server, sig_ctx).await?;
} }
Err(err) => { Err(err) => {
error!("FanCurves: {}", err); error!("FanCurves: {}", err);
@@ -80,26 +91,30 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
} }
match CtrlPlatform::new( match CtrlPlatform::new(
platform,
power,
attributes,
config.clone(), config.clone(),
&cfg_path, &cfg_path,
CtrlPlatform::signal_context(&connection)?, CtrlPlatform::signal_context(&server)?,
) { ) {
Ok(ctrl) => { Ok(ctrl) => {
let sig_ctx = CtrlPlatform::signal_context(&connection)?; let sig_ctx = CtrlPlatform::signal_context(&server)?;
start_tasks(ctrl, &mut connection, sig_ctx).await?; start_tasks(ctrl, &mut server, sig_ctx).await?;
} }
Err(err) => { Err(err) => {
error!("CtrlPlatform: {}", err); error!("CtrlPlatform: {}", err);
} }
} }
let _ = DeviceManager::new(connection.clone()).await?; let _ = DeviceManager::new(server.clone()).await?;
// Request dbus name after finishing initalizing all functions // Request dbus name after finishing initalizing all functions
connection.request_name(DBUS_NAME).await?; server.request_name(DBUS_NAME).await?;
info!("Startup success, begining dbus server loop");
loop { loop {
// This is just a blocker to idle and ensure the reator reacts // This is just a blocker to idle and ensure the reator reacts
connection.executor().tick().await; server.executor().tick().await;
} }
} }
+7
View File
@@ -142,3 +142,10 @@ impl From<RogError> for zbus::fdo::Error {
zbus::fdo::Error::Failed(format!("{}", err)) zbus::fdo::Error::Failed(format!("{}", err))
} }
} }
impl From<RogError> for zbus::Error {
#[inline]
fn from(err: RogError) -> Self {
zbus::Error::Failure(format!("{}", err))
}
}
+7 -4
View File
@@ -6,6 +6,7 @@ pub mod ctrl_fancurves;
/// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode /// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode
pub mod ctrl_platform; pub mod ctrl_platform;
pub mod asus_armoury;
pub mod aura_anime; pub mod aura_anime;
pub mod aura_laptop; pub mod aura_laptop;
pub mod aura_manager; pub mod aura_manager;
@@ -30,9 +31,11 @@ use zbus::Connection;
use crate::error::RogError; use crate::error::RogError;
const CONFIG_PATH_BASE: &str = "/etc/asusd/"; const CONFIG_PATH_BASE: &str = "/etc/asusd/";
pub static DBUS_NAME: &str = "org.asuslinux.Daemon"; pub const ASUS_ZBUS_PATH: &str = "/xyz/ljones";
pub static DBUS_PATH: &str = "/org/asuslinux/Daemon";
pub static DBUS_IFACE: &str = "org.asuslinux.Daemon"; pub static DBUS_NAME: &str = "xyz.ljones.Asusd";
pub static DBUS_PATH: &str = "/xyz/ljones/Daemon";
pub static DBUS_IFACE: &str = "xyz.ljones.Asusd";
/// This macro adds a function which spawns an `inotify` task on the passed in /// This macro adds a function which spawns an `inotify` task on the passed in
/// `Executor`. /// `Executor`.
@@ -64,7 +67,7 @@ macro_rules! task_watch_item {
&self, &self,
signal_ctxt: SignalEmitter<'static>, signal_ctxt: SignalEmitter<'static>,
) -> Result<(), RogError> { ) -> Result<(), RogError> {
use zbus::export::futures_util::StreamExt; use futures_util::StreamExt;
let ctrl = self.clone(); let ctrl = self.clone();
concat_idents::concat_idents!(watch_fn = monitor_, $name { concat_idents::concat_idents!(watch_fn = monitor_, $name {
+1 -1
View File
@@ -203,7 +203,7 @@ macro_rules! std_config_load {
/// new one created /// new one created
pub trait $trait_name<$($generic),*> pub trait $trait_name<$($generic),*>
where where
Self: $crate::StdConfig +std::fmt::Debug + DeserializeOwned + Serialize, Self: $crate::StdConfig + DeserializeOwned + Serialize,
$($generic: DeserializeOwned + Into<Self>),* $($generic: DeserializeOwned + Into<Self>),*
{ {
fn load(mut self) -> Self { fn load(mut self) -> Self {
-11
View File
@@ -1,11 +0,0 @@
[package]
name = "cpuctl"
license.workspace = true
version.workspace = true
readme.workspace = true
authors.workspace = true
repository.workspace = true
homepage.workspace = true
edition.workspace = true
[dependencies]
-14
View File
@@ -1,14 +0,0 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
+11 -11
View File
@@ -3,24 +3,24 @@
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig> <busconfig>
<policy group="adm"> <policy group="adm">
<allow send_destination="org.asuslinux.Daemon"/> <allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="org.asuslinux.Daemon"/> <allow receive_sender="xyz.ljones.Asusd"/>
</policy> </policy>
<policy group="sudo"> <policy group="sudo">
<allow send_destination="org.asuslinux.Daemon"/> <allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="org.asuslinux.Daemon"/> <allow receive_sender="xyz.ljones.Asusd"/>
</policy> </policy>
<policy group="users"> <policy group="users">
<allow send_destination="org.asuslinux.Daemon"/> <allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="org.asuslinux.Daemon"/> <allow receive_sender="xyz.ljones.Asusd"/>
</policy> </policy>
<policy group="wheel"> <policy group="wheel">
<allow send_destination="org.asuslinux.Daemon"/> <allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="org.asuslinux.Daemon"/> <allow receive_sender="xyz.ljones.Asusd"/>
</policy> </policy>
<policy user="root"> <policy user="root">
<allow own="org.asuslinux.Daemon"/> <allow own="xyz.ljones.Asusd"/>
<allow send_destination="org.asuslinux.Daemon"/> <allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="org.asuslinux.Daemon"/> <allow receive_sender="xyz.ljones.Asusd"/>
</policy> </policy>
</busconfig> </busconfig>
+3 -2
View File
@@ -6,13 +6,14 @@ After=nvidia-powerd.service systemd-udevd.service
[Service] [Service]
Environment=IS_SERVICE=1 Environment=IS_SERVICE=1
Environment=RUST_LOG="info" Environment=RUST_LOG="debug"
# required to prevent init issues with hid_asus and MCU # required to prevent init issues with hid_asus and MCU
ExecStartPre=/bin/sleep 1 ExecStartPre=/bin/sleep 1
ExecStart=/usr/bin/asusd ExecStart=/usr/bin/asusd
Restart=on-failure Restart=on-failure
RestartSec=1 RestartSec=1
Type=dbus Type=dbus
BusName=org.asuslinux.Daemon BusName=xyz.ljones.Asusd
SELinuxContext=system_u:system_r:unconfined_t:s0 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
TimeoutSec=10
+1 -1
View File
@@ -135,7 +135,7 @@ impl crate::ZbusAdd for CtrlAnimeZbus {
} }
} }
#[dbus_interface(name = "org.asuslinux.Daemon")] #[dbus_interface(name = "xyz.ljones.Asusd")]
impl CtrlAnimeZbus { impl CtrlAnimeZbus {
async fn <zbus method>() { async fn <zbus method>() {
let lock = self.inner.lock().await; let lock = self.inner.lock().await;
-1
View File
@@ -30,7 +30,6 @@ log.workspace = true
serde.workspace = true serde.workspace = true
glam.workspace = true glam.workspace = true
typeshare.workspace = true
zbus = { workspace = true, optional = true } zbus = { workspace = true, optional = true }
+9 -9
View File
@@ -6,7 +6,6 @@ use std::time::{Duration, Instant};
use dmi_id::DMIID; use dmi_id::DMIID;
use log::info; use log::info;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
@@ -23,15 +22,19 @@ const BLOCK_END: usize = 634;
const PANE_LEN: usize = BLOCK_END - BLOCK_START; const PANE_LEN: usize = BLOCK_END - BLOCK_START;
/// First packet is for GA401 + GA402 /// First packet is for GA401 + GA402
pub const USB_PREFIX1: [u8; 7] = [0x5e, 0xc0, 0x02, 0x01, 0x00, 0x73, 0x02]; pub const USB_PREFIX1: [u8; 7] = [
0x5e, 0xc0, 0x02, 0x01, 0x00, 0x73, 0x02,
];
/// Second packet is for GA401 + GA402 /// Second packet is for GA401 + GA402
pub const USB_PREFIX2: [u8; 7] = [0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02]; pub const USB_PREFIX2: [u8; 7] = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02,
];
/// Third packet is for GA402 matrix /// Third packet is for GA402 matrix
pub const USB_PREFIX3: [u8; 7] = [0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02]; pub const USB_PREFIX3: [u8; 7] = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02,
];
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[typeshare]
#[derive(Default, Deserialize, PartialEq, Eq, Clone, Copy, Serialize, Debug)] #[derive(Default, Deserialize, PartialEq, Eq, Clone, Copy, Serialize, Debug)]
pub struct Animations { pub struct Animations {
pub boot: AnimBooting, pub boot: AnimBooting,
@@ -41,9 +44,7 @@ pub struct Animations {
} }
// TODO: move this out // TODO: move this out
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))] #[cfg_attr(feature = "dbus", derive(Type))]
#[typeshare]
#[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub struct DeviceState { pub struct DeviceState {
pub display_enabled: bool, pub display_enabled: bool,
@@ -56,7 +57,6 @@ pub struct DeviceState {
pub brightness_on_battery: Brightness, pub brightness_on_battery: Brightness,
} }
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))] #[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize, Default)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize, Default)]
pub enum AnimeType { pub enum AnimeType {
+3 -1
View File
@@ -321,7 +321,9 @@ impl AnimeImage {
let pos = Vec3::new(led.x(), led.y(), 1.0); let pos = Vec3::new(led.x(), led.y(), 1.0);
let x0 = led_from_px.mul_vec3(pos + Vec3::new(0.0, -0.5, 0.0)); let x0 = led_from_px.mul_vec3(pos + Vec3::new(0.0, -0.5, 0.0));
const GROUP: [f32; 4] = [0.0, 0.5, 1.0, 1.5]; const GROUP: [f32; 4] = [
0.0, 0.5, 1.0, 1.5,
];
for u in &GROUP { for u in &GROUP {
for v in &GROUP { for v in &GROUP {
let sample = x0 + *u * du + *v * dv; let sample = x0 + *u * du + *v * dv;
+6 -35
View File
@@ -75,10 +75,7 @@ impl ActionData {
time, time,
brightness, brightness,
} => ActionData::Animation(AnimeGif::from_diagonal_gif( } => ActionData::Animation(AnimeGif::from_diagonal_gif(
file, file, *time, *brightness, anime_type,
*time,
*brightness,
anime_type,
)?), )?),
ActionLoader::AsusImage { ActionLoader::AsusImage {
file, file,
@@ -91,10 +88,7 @@ impl ActionData {
ActionData::Image(Box::new(data)) ActionData::Image(Box::new(data))
} }
_ => ActionData::Animation(AnimeGif::from_diagonal_png( _ => ActionData::Animation(AnimeGif::from_diagonal_png(
file, file, anime_type, *time, *brightness,
anime_type,
*time,
*brightness,
)?), )?),
}, },
ActionLoader::ImageAnimation { ActionLoader::ImageAnimation {
@@ -108,24 +102,12 @@ impl ActionData {
if let Some(ext) = file.extension() { if let Some(ext) = file.extension() {
if ext.to_string_lossy().to_lowercase() == "png" { if ext.to_string_lossy().to_lowercase() == "png" {
return Ok(ActionData::Animation(AnimeGif::from_png( return Ok(ActionData::Animation(AnimeGif::from_png(
file, file, *scale, *angle, *translation, *time, *brightness, anime_type,
*scale,
*angle,
*translation,
*time,
*brightness,
anime_type,
)?)); )?));
} }
} }
ActionData::Animation(AnimeGif::from_gif( ActionData::Animation(AnimeGif::from_gif(
file, file, *scale, *angle, *translation, *time, *brightness, anime_type,
*scale,
*angle,
*translation,
*time,
*brightness,
anime_type,
)?) )?)
} }
ActionLoader::Image { ActionLoader::Image {
@@ -140,24 +122,13 @@ impl ActionData {
AnimTime::Infinite => { AnimTime::Infinite => {
// If no time then create a plain static image // If no time then create a plain static image
let image = AnimeImage::from_png( let image = AnimeImage::from_png(
file, file, *scale, *angle, *translation, *brightness, anime_type,
*scale,
*angle,
*translation,
*brightness,
anime_type,
)?; )?;
let data = <AnimeDataBuffer>::try_from(&image)?; let data = <AnimeDataBuffer>::try_from(&image)?;
ActionData::Image(Box::new(data)) ActionData::Image(Box::new(data))
} }
_ => ActionData::Animation(AnimeGif::from_png( _ => ActionData::Animation(AnimeGif::from_png(
file, file, *scale, *angle, *translation, *time, *brightness, anime_type,
*scale,
*angle,
*translation,
*time,
*brightness,
anime_type,
)?), )?),
} }
} }
-6
View File
@@ -12,7 +12,6 @@ use std::str::FromStr;
use dmi_id::DMIID; use dmi_id::DMIID;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
@@ -29,7 +28,6 @@ pub const PROD_ID: u16 = 0x193b;
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "u") zvariant(signature = "u")
)] )]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
/// Base LED brightness of the display /// Base LED brightness of the display
pub enum Brightness { pub enum Brightness {
@@ -82,7 +80,6 @@ impl From<Brightness> for i32 {
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "s") zvariant(signature = "s")
)] )]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimBooting { pub enum AnimBooting {
#[default] #[default]
@@ -123,7 +120,6 @@ impl From<AnimBooting> for i32 {
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "s") zvariant(signature = "s")
)] )]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimAwake { pub enum AnimAwake {
#[default] #[default]
@@ -164,7 +160,6 @@ impl From<AnimAwake> for i32 {
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "s") zvariant(signature = "s")
)] )]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimSleeping { pub enum AnimSleeping {
#[default] #[default]
@@ -205,7 +200,6 @@ impl From<AnimSleeping> for i32 {
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "s") zvariant(signature = "s")
)] )]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimShutdown { pub enum AnimShutdown {
#[default] #[default]
-1
View File
@@ -23,6 +23,5 @@ dmi_id = { path = "../dmi-id" }
# cli and logging # cli and logging
log.workspace = true log.workspace = true
typeshare.workspace = true
ron = { version = "*", optional = true } ron = { version = "*", optional = true }
+38 -11
View File
@@ -35,6 +35,15 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "FA617NS",
product_id: "",
layout_name: "fa617ns",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
( (
device_name: "FX505", device_name: "FX505",
product_id: "", product_id: "",
@@ -80,6 +89,15 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "FX617X",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
( (
device_name: "FX705D", device_name: "FX705D",
product_id: "", product_id: "",
@@ -139,10 +157,19 @@
product_id: "", product_id: "",
layout_name: "g513i", layout_name: "g513i",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse], basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse],
basic_zones: [], basic_zones: [Key1, Key2, Key3, Key4],
advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]), advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]),
power_zones: [Keyboard, Lightbar], power_zones: [Keyboard, Lightbar],
), ),
(
device_name: "G513RW",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar],
),
( (
device_name: "G531G", device_name: "G531G",
product_id: "", product_id: "",
@@ -179,6 +206,15 @@
advanced_type: PerKey, advanced_type: PerKey,
power_zones: [Keyboard, Lightbar], power_zones: [Keyboard, Lightbar],
), ),
(
device_name: "G533QS",
product_id: "18c6",
layout_name: "g533q-per-key",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar],
),
( (
device_name: "G533Z", device_name: "G533Z",
product_id: "", product_id: "",
@@ -656,15 +692,6 @@
advanced_type: Zoned([SingleZone]), advanced_type: Zoned([SingleZone]),
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "GA605W",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse],
basic_zones: [],
advanced_type: Zoned([SingleZone]),
power_zones: [Keyboard],
),
( (
device_name: "GV301Q", device_name: "GV301Q",
product_id: "", product_id: "",
@@ -845,4 +872,4 @@
advanced_type: None, advanced_type: None,
power_zones: [Ally], power_zones: [Ally],
), ),
]) ])
+10 -5
View File
@@ -191,9 +191,16 @@ mod tests {
product_id: String::new(), product_id: String::new(),
layout_name: "ga401".to_owned(), layout_name: "ga401".to_owned(),
basic_modes: vec![AuraModeNum::Static], basic_modes: vec![AuraModeNum::Static],
basic_zones: vec![AuraZone::Key1, AuraZone::Logo, AuraZone::BarLeft], basic_zones: vec![
AuraZone::Key1,
AuraZone::Logo,
AuraZone::BarLeft,
],
advanced_type: AdvancedAuraType::Zoned(vec![LedCode::LightbarRight]), advanced_type: AdvancedAuraType::Zoned(vec![LedCode::LightbarRight]),
power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow], power_zones: vec![
PowerZones::Keyboard,
PowerZones::RearGlow,
],
}; };
assert!(ron::to_string(&led).is_ok()); assert!(ron::to_string(&led).is_ok());
@@ -214,9 +221,7 @@ mod tests {
tmp_sort.0.sort_by(|a, b| a.product_id.cmp(&b.product_id)); 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)); tmp_sort.0.sort_by(|a, b| a.device_name.cmp(&b.device_name));
for model in tmp_sort.0.iter_mut() { for model in tmp_sort.0.iter_mut() {
model model.basic_modes.sort_by_key(|a| *a as u8);
.basic_modes
.sort_by(|a, b| (*a as u8).cmp(&(*b as u8)));
} }
if tmp != tmp_sort { if tmp != tmp_sort {
let sorted = let sorted =
+8 -10
View File
@@ -2,14 +2,12 @@ use std::fmt::Display;
use std::str::FromStr; use std::str::FromStr;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
use crate::error::Error; use crate::error::Error;
use crate::AURA_LAPTOP_LED_MSG_LEN; use crate::AURA_LAPTOP_LED_MSG_LEN;
#[typeshare]
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)] #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
@@ -79,7 +77,6 @@ impl From<i32> for LedBrightness {
} }
} }
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Debug, Clone, PartialEq, Eq, Copy, Deserialize, Serialize)] #[derive(Debug, Clone, PartialEq, Eq, Copy, Deserialize, Serialize)]
pub struct Colour { pub struct Colour {
@@ -120,7 +117,11 @@ impl From<&[f32; 3]> for Colour {
impl From<Colour> for [f32; 3] { impl From<Colour> for [f32; 3] {
fn from(c: Colour) -> Self { fn from(c: Colour) -> Self {
[c.r as f32 / 255.0, c.g as f32 / 255.0, c.b as f32 / 255.0] [
c.r as f32 / 255.0,
c.g as f32 / 255.0,
c.b as f32 / 255.0,
]
} }
} }
@@ -136,11 +137,12 @@ impl From<&[u8; 3]> for Colour {
impl From<Colour> for [u8; 3] { impl From<Colour> for [u8; 3] {
fn from(c: Colour) -> Self { fn from(c: Colour) -> Self {
[c.r, c.g, c.b] [
c.r, c.g, c.b,
]
} }
} }
#[typeshare]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
@@ -200,7 +202,6 @@ impl From<Speed> for u8 {
/// Used for Rainbow mode. /// Used for Rainbow mode.
/// ///
/// Enum corresponds to the required integer value /// Enum corresponds to the required integer value
#[typeshare]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
@@ -248,7 +249,6 @@ impl From<Direction> for i32 {
} }
/// Enum of modes that convert to the actual number required by a USB HID packet /// Enum of modes that convert to the actual number required by a USB HID packet
#[typeshare]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
@@ -360,7 +360,6 @@ impl From<AuraEffect> for AuraModeNum {
} }
/// Base effects have no zoning, while multizone is 1-4 /// Base effects have no zoning, while multizone is 1-4
#[typeshare]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
@@ -432,7 +431,6 @@ impl From<AuraZone> for i32 {
/// ```rust /// ```rust
/// // let bytes: [u8; LED_MSG_LEN] = mode.into(); /// // let bytes: [u8; LED_MSG_LEN] = mode.into();
/// ``` /// ```
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct AuraEffect { pub struct AuraEffect {
+3 -5
View File
@@ -207,14 +207,12 @@ mod tests {
fn single_key_next_state_then_create() { fn single_key_next_state_then_create() {
let layout = KeyLayout::default_layout(); let layout = KeyLayout::default_layout();
let mut seq = AdvancedEffects::new(false); let mut seq = AdvancedEffects::new(false);
seq.effects.push(Effect::Static(Static::new( seq.effects
LedCode::F, .push(Effect::Static(Static::new(LedCode::F, Colour {
Colour {
r: 255, r: 255,
g: 127, g: 127,
b: 0, b: 0,
}, })));
)));
seq.next_state(&layout); seq.next_state(&layout);
let packets = seq.create_packets(); let packets = seq.create_packets();
-3
View File
@@ -1,6 +1,5 @@
use log::warn; use log::warn;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::Type; use zbus::zvariant::Type;
@@ -194,7 +193,6 @@ impl LedCode {
} }
/// Represents the per-key raw USB packets /// Represents the per-key raw USB packets
#[typeshare]
pub type AuraLaptopUsbPackets = Vec<Vec<u8>>; pub type AuraLaptopUsbPackets = Vec<Vec<u8>>;
/// A `UsbPackets` contains all data to change the full set of keyboard /// A `UsbPackets` contains all data to change the full set of keyboard
@@ -204,7 +202,6 @@ pub type AuraLaptopUsbPackets = Vec<Vec<u8>>;
/// to the keyboard EC. One row controls one group of keys, these keys are not /// 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 /// necessarily all on the same row of the keyboard, with some splitting between
/// two rows. /// two rows.
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))] #[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Debug, Clone, Deserialize, Serialize)] #[derive(Debug, Clone, Deserialize, Serialize)]
pub struct LedUsbPackets { pub struct LedUsbPackets {
+87 -111
View File
@@ -335,117 +335,93 @@ impl KeyLayout {
KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1), KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1),
)]), )]),
key_rows: vec![ key_rows: vec![
KeyRow::new( KeyRow::new(0.1, 0.1, vec![
0.1, (LedCode::Esc, "regular".to_owned()),
0.1, (LedCode::F1, "regular".to_owned()),
vec![ (LedCode::F2, "regular".to_owned()),
(LedCode::Esc, "regular".to_owned()), (LedCode::F3, "regular".to_owned()),
(LedCode::F1, "regular".to_owned()), (LedCode::F4, "regular".to_owned()),
(LedCode::F2, "regular".to_owned()), // not sure which key to put here
(LedCode::F3, "regular".to_owned()), (LedCode::F5, "regular".to_owned()),
(LedCode::F4, "regular".to_owned()), (LedCode::F6, "regular".to_owned()),
// not sure which key to put here (LedCode::F7, "regular".to_owned()),
(LedCode::F5, "regular".to_owned()), (LedCode::F8, "regular".to_owned()),
(LedCode::F6, "regular".to_owned()), (LedCode::F9, "regular".to_owned()),
(LedCode::F7, "regular".to_owned()), (LedCode::F10, "regular".to_owned()),
(LedCode::F8, "regular".to_owned()), (LedCode::F11, "regular".to_owned()),
(LedCode::F9, "regular".to_owned()), (LedCode::F12, "regular".to_owned()),
(LedCode::F10, "regular".to_owned()), ]),
(LedCode::F11, "regular".to_owned()), KeyRow::new(0.1, 0.1, vec![
(LedCode::F12, "regular".to_owned()), (LedCode::Tilde, "regular".to_owned()),
], (LedCode::N1, "regular".to_owned()),
), (LedCode::N2, "regular".to_owned()),
KeyRow::new( (LedCode::N3, "regular".to_owned()),
0.1, (LedCode::N4, "regular".to_owned()),
0.1, (LedCode::N5, "regular".to_owned()),
vec![ (LedCode::N6, "regular".to_owned()),
(LedCode::Tilde, "regular".to_owned()), (LedCode::N7, "regular".to_owned()),
(LedCode::N1, "regular".to_owned()), (LedCode::N8, "regular".to_owned()),
(LedCode::N2, "regular".to_owned()), (LedCode::N9, "regular".to_owned()),
(LedCode::N3, "regular".to_owned()), (LedCode::N0, "regular".to_owned()),
(LedCode::N4, "regular".to_owned()), (LedCode::Hyphen, "regular".to_owned()),
(LedCode::N5, "regular".to_owned()), (LedCode::Equals, "regular".to_owned()),
(LedCode::N6, "regular".to_owned()), (LedCode::Backspace, "regular".to_owned()),
(LedCode::N7, "regular".to_owned()), ]),
(LedCode::N8, "regular".to_owned()), KeyRow::new(0.1, 0.1, vec![
(LedCode::N9, "regular".to_owned()), (LedCode::Tab, "regular".to_owned()),
(LedCode::N0, "regular".to_owned()), (LedCode::Q, "regular".to_owned()),
(LedCode::Hyphen, "regular".to_owned()), (LedCode::W, "regular".to_owned()),
(LedCode::Equals, "regular".to_owned()), (LedCode::E, "regular".to_owned()),
(LedCode::Backspace, "regular".to_owned()), (LedCode::R, "regular".to_owned()),
], (LedCode::T, "regular".to_owned()),
), (LedCode::Y, "regular".to_owned()),
KeyRow::new( (LedCode::U, "regular".to_owned()),
0.1, (LedCode::I, "regular".to_owned()),
0.1, (LedCode::O, "regular".to_owned()),
vec![ (LedCode::P, "regular".to_owned()),
(LedCode::Tab, "regular".to_owned()), (LedCode::LBracket, "regular".to_owned()),
(LedCode::Q, "regular".to_owned()), (LedCode::RBracket, "regular".to_owned()),
(LedCode::W, "regular".to_owned()), (LedCode::BackSlash, "regular".to_owned()),
(LedCode::E, "regular".to_owned()), ]),
(LedCode::R, "regular".to_owned()), KeyRow::new(0.1, 0.1, vec![
(LedCode::T, "regular".to_owned()), (LedCode::Caps, "regular".to_owned()),
(LedCode::Y, "regular".to_owned()), (LedCode::A, "regular".to_owned()),
(LedCode::U, "regular".to_owned()), (LedCode::S, "regular".to_owned()),
(LedCode::I, "regular".to_owned()), (LedCode::D, "regular".to_owned()),
(LedCode::O, "regular".to_owned()), (LedCode::F, "regular".to_owned()),
(LedCode::P, "regular".to_owned()), (LedCode::G, "regular".to_owned()),
(LedCode::LBracket, "regular".to_owned()), (LedCode::H, "regular".to_owned()),
(LedCode::RBracket, "regular".to_owned()), (LedCode::J, "regular".to_owned()),
(LedCode::BackSlash, "regular".to_owned()), (LedCode::K, "regular".to_owned()),
], (LedCode::L, "regular".to_owned()),
), (LedCode::SemiColon, "regular".to_owned()),
KeyRow::new( (LedCode::Quote, "regular".to_owned()),
0.1, (LedCode::Return, "regular".to_owned()),
0.1, ]),
vec![ KeyRow::new(0.1, 0.1, vec![
(LedCode::Caps, "regular".to_owned()), (LedCode::LShift, "regular".to_owned()),
(LedCode::A, "regular".to_owned()), (LedCode::Z, "regular".to_owned()),
(LedCode::S, "regular".to_owned()), (LedCode::X, "regular".to_owned()),
(LedCode::D, "regular".to_owned()), (LedCode::C, "regular".to_owned()),
(LedCode::F, "regular".to_owned()), (LedCode::V, "regular".to_owned()),
(LedCode::G, "regular".to_owned()), (LedCode::B, "regular".to_owned()),
(LedCode::H, "regular".to_owned()), (LedCode::N, "regular".to_owned()),
(LedCode::J, "regular".to_owned()), (LedCode::M, "regular".to_owned()),
(LedCode::K, "regular".to_owned()), (LedCode::Comma, "regular".to_owned()),
(LedCode::L, "regular".to_owned()), (LedCode::Period, "regular".to_owned()),
(LedCode::SemiColon, "regular".to_owned()), (LedCode::FwdSlash, "regular".to_owned()),
(LedCode::Quote, "regular".to_owned()), (LedCode::Rshift, "regular".to_owned()),
(LedCode::Return, "regular".to_owned()), ]),
], KeyRow::new(0.1, 0.1, vec![
), (LedCode::LCtrl, "regular".to_owned()),
KeyRow::new( (LedCode::LFn, "regular".to_owned()),
0.1, (LedCode::Meta, "regular".to_owned()),
0.1, (LedCode::LAlt, "regular".to_owned()),
vec![ (LedCode::Spacebar, "regular".to_owned()),
(LedCode::LShift, "regular".to_owned()), (LedCode::RAlt, "regular".to_owned()),
(LedCode::Z, "regular".to_owned()), (LedCode::PrtSc, "regular".to_owned()),
(LedCode::X, "regular".to_owned()), (LedCode::RCtrl, "regular".to_owned()),
(LedCode::C, "regular".to_owned()), ]),
(LedCode::V, "regular".to_owned()),
(LedCode::B, "regular".to_owned()),
(LedCode::N, "regular".to_owned()),
(LedCode::M, "regular".to_owned()),
(LedCode::Comma, "regular".to_owned()),
(LedCode::Period, "regular".to_owned()),
(LedCode::FwdSlash, "regular".to_owned()),
(LedCode::Rshift, "regular".to_owned()),
],
),
KeyRow::new(
0.1,
0.1,
vec![
(LedCode::LCtrl, "regular".to_owned()),
(LedCode::LFn, "regular".to_owned()),
(LedCode::Meta, "regular".to_owned()),
(LedCode::LAlt, "regular".to_owned()),
(LedCode::Spacebar, "regular".to_owned()),
(LedCode::RAlt, "regular".to_owned()),
(LedCode::PrtSc, "regular".to_owned()),
(LedCode::RCtrl, "regular".to_owned()),
],
),
], ],
} }
} }
+230 -181
View File
@@ -5,7 +5,6 @@ use std::ops::{BitAnd, BitOr};
use log::warn; use log::warn;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
@@ -16,7 +15,6 @@ use crate::{AuraDeviceType, PowerZones};
/// - 2021+, the struct is a single zone with 4 states /// - 2021+, the struct is a single zone with 4 states
/// - pre-2021, the struct is 1 or 2 zones and 3 states /// - pre-2021, the struct is 1 or 2 zones and 3 states
/// - Tuf, the struct is 1 zone and 3 states /// - Tuf, the struct is 1 zone and 3 states
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct AuraPowerState { pub struct AuraPowerState {
@@ -54,7 +52,9 @@ impl AuraPowerState {
fn tuf_to_bytes(&self) -> Vec<u8> { fn tuf_to_bytes(&self) -> Vec<u8> {
// &cmd, &boot, &awake, &sleep, &keyboard // &cmd, &boot, &awake, &sleep, &keyboard
vec![1, self.boot as u8, self.awake as u8, self.sleep as u8, 1] vec![
1, self.boot as u8, self.awake as u8, self.sleep as u8, 1,
]
} }
/// # Bits for older 0x1866 keyboard model /// # Bits for older 0x1866 keyboard model
@@ -106,46 +106,45 @@ impl AuraPowerState {
match self.zone { match self.zone {
PowerZones::Logo => { PowerZones::Logo => {
self.boot as u32 self.boot as u32
| (self.awake as u32) << 2 | ((self.awake as u32) << 2)
| (self.sleep as u32) << 4 | ((self.sleep as u32) << 4)
| (self.shutdown as u32) << 6 | ((self.shutdown as u32) << 6)
} }
PowerZones::Ally => { PowerZones::Ally => {
(self.boot as u32) (self.boot as u32)
| (self.awake as u32) << 1 | ((self.awake as u32) << 1)
| (self.sleep as u32) << 2 | ((self.sleep as u32) << 2)
| (self.shutdown as u32) << 3 | ((self.shutdown as u32) << 3)
} }
PowerZones::Keyboard => { PowerZones::Keyboard => {
(self.boot as u32) << 1 ((self.boot as u32) << 1)
| (self.awake as u32) << 3 | ((self.awake as u32) << 3)
| (self.sleep as u32) << 5 | ((self.sleep as u32) << 5)
| (self.shutdown as u32) << 7 | ((self.shutdown as u32) << 7)
} }
PowerZones::Lightbar => { PowerZones::Lightbar => {
(self.boot as u32) << (7 + 2) ((self.boot as u32) << (7 + 2))
| (self.awake as u32) << (7 + 3) | ((self.awake as u32) << (7 + 3))
| (self.sleep as u32) << (7 + 4) | ((self.sleep as u32) << (7 + 4))
| (self.shutdown as u32) << (7 + 5) | ((self.shutdown as u32) << (7 + 5))
} }
PowerZones::Lid => { PowerZones::Lid => {
(self.boot as u32) << (15 + 1) ((self.boot as u32) << (15 + 1))
| (self.awake as u32) << (15 + 2) | ((self.awake as u32) << (15 + 2))
| (self.sleep as u32) << (15 + 3) | ((self.sleep as u32) << (15 + 3))
| (self.shutdown as u32) << (15 + 4) | ((self.shutdown as u32) << (15 + 4))
} }
PowerZones::RearGlow => { PowerZones::RearGlow => {
(self.boot as u32) << (23 + 1) ((self.boot as u32) << (23 + 1))
| (self.awake as u32) << (23 + 2) | ((self.awake as u32) << (23 + 2))
| (self.sleep as u32) << (23 + 3) | ((self.sleep as u32) << (23 + 3))
| (self.shutdown as u32) << (23 + 4) | ((self.shutdown as u32) << (23 + 4))
} }
PowerZones::None | PowerZones::KeyboardAndLightbar => 0, PowerZones::None | PowerZones::KeyboardAndLightbar => 0,
} }
} }
} }
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct LaptopAuraPower { pub struct LaptopAuraPower {
@@ -226,7 +225,13 @@ impl LaptopAuraPower {
pub fn to_bytes(&self, aura_type: AuraDeviceType) -> Vec<u8> { pub fn to_bytes(&self, aura_type: AuraDeviceType) -> Vec<u8> {
if let Some(stuff) = self.states.first() { if let Some(stuff) = self.states.first() {
if stuff.zone == PowerZones::Ally { if stuff.zone == PowerZones::Ally {
return vec![0x5d, 0xd1, 0x09, 0x01, stuff.new_to_byte() as u8]; return vec![
0x5d,
0xd1,
0x09,
0x01,
stuff.new_to_byte() as u8,
];
} }
} }
match aura_type { match aura_type {
@@ -321,26 +326,30 @@ mod test {
#[test] #[test]
fn check_0x1866_control_bytes() { fn check_0x1866_control_bytes() {
let power = LaptopAuraPower { let power = LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Keyboard, AuraPowerState {
boot: false, zone: PowerZones::Keyboard,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}; };
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]); assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]);
let power = LaptopAuraPower { let power = LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lightbar, AuraPowerState {
boot: false, zone: PowerZones::Lightbar,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}; };
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
@@ -379,184 +388,224 @@ mod test {
#[test] #[test]
fn check_0x19b6_control_bytes_binary_rep() { fn check_0x19b6_control_bytes_binary_rep() {
let boot_logo_ = to_binary_string_post2021(&LaptopAuraPower { let boot_logo_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Logo, AuraPowerState {
boot: true, zone: PowerZones::Logo,
awake: false, boot: true,
sleep: false, awake: false,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}); });
let boot_keyb_ = to_binary_string_post2021(&LaptopAuraPower { let boot_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Keyboard, AuraPowerState {
boot: true, zone: PowerZones::Keyboard,
awake: false, boot: true,
sleep: false, awake: false,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}); });
let sleep_logo = to_binary_string_post2021(&LaptopAuraPower { let sleep_logo = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Logo, AuraPowerState {
boot: false, zone: PowerZones::Logo,
awake: false, boot: false,
sleep: true, awake: false,
shutdown: false, sleep: true,
}], shutdown: false,
},
],
}); });
let sleep_keyb = to_binary_string_post2021(&LaptopAuraPower { let sleep_keyb = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Keyboard, AuraPowerState {
boot: false, zone: PowerZones::Keyboard,
awake: false, boot: false,
sleep: true, awake: false,
shutdown: false, sleep: true,
}], shutdown: false,
},
],
}); });
let awake_logo = to_binary_string_post2021(&LaptopAuraPower { let awake_logo = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Logo, AuraPowerState {
boot: false, zone: PowerZones::Logo,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}); });
let awake_keyb = to_binary_string_post2021(&LaptopAuraPower { let awake_keyb = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Keyboard, AuraPowerState {
boot: false, zone: PowerZones::Keyboard,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}); });
let shut_logo_ = to_binary_string_post2021(&LaptopAuraPower { let shut_logo_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Logo, AuraPowerState {
boot: false, zone: PowerZones::Logo,
awake: false, boot: false,
sleep: false, awake: false,
shutdown: true, sleep: false,
}], shutdown: true,
},
],
}); });
let shut_keyb_ = to_binary_string_post2021(&LaptopAuraPower { let shut_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Keyboard, AuraPowerState {
boot: false, zone: PowerZones::Keyboard,
awake: false, boot: false,
sleep: false, awake: false,
shutdown: true, sleep: false,
}], shutdown: true,
},
],
}); });
let boot_bar__ = to_binary_string_post2021(&LaptopAuraPower { let boot_bar__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lightbar, AuraPowerState {
boot: true, zone: PowerZones::Lightbar,
awake: false, boot: true,
sleep: false, awake: false,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}); });
let awake_bar_ = to_binary_string_post2021(&LaptopAuraPower { let awake_bar_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lightbar, AuraPowerState {
boot: false, zone: PowerZones::Lightbar,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}); });
let sleep_bar_ = to_binary_string_post2021(&LaptopAuraPower { let sleep_bar_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lightbar, AuraPowerState {
boot: false, zone: PowerZones::Lightbar,
awake: false, boot: false,
sleep: true, awake: false,
shutdown: false, sleep: true,
}], shutdown: false,
},
],
}); });
let shut_bar__ = to_binary_string_post2021(&LaptopAuraPower { let shut_bar__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lightbar, AuraPowerState {
boot: false, zone: PowerZones::Lightbar,
awake: false, boot: false,
sleep: false, awake: false,
shutdown: true, sleep: false,
}], shutdown: true,
},
],
}); });
let boot_lid__ = to_binary_string_post2021(&LaptopAuraPower { let boot_lid__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lid, AuraPowerState {
boot: true, zone: PowerZones::Lid,
awake: false, boot: true,
sleep: false, awake: false,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}); });
let awake_lid_ = to_binary_string_post2021(&LaptopAuraPower { let awake_lid_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lid, AuraPowerState {
boot: false, zone: PowerZones::Lid,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}); });
let sleep_lid_ = to_binary_string_post2021(&LaptopAuraPower { let sleep_lid_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lid, AuraPowerState {
boot: false, zone: PowerZones::Lid,
awake: false, boot: false,
sleep: true, awake: false,
shutdown: false, sleep: true,
}], shutdown: false,
},
],
}); });
let shut_lid__ = to_binary_string_post2021(&LaptopAuraPower { let shut_lid__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lid, AuraPowerState {
boot: false, zone: PowerZones::Lid,
awake: false, boot: false,
sleep: false, awake: false,
shutdown: true, sleep: false,
}], shutdown: true,
},
],
}); });
let boot_rear_ = to_binary_string_post2021(&LaptopAuraPower { let boot_rear_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::RearGlow, AuraPowerState {
boot: true, zone: PowerZones::RearGlow,
awake: false, boot: true,
sleep: false, awake: false,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}); });
let awake_rear = to_binary_string_post2021(&LaptopAuraPower { let awake_rear = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::RearGlow, AuraPowerState {
boot: false, zone: PowerZones::RearGlow,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false,
},
],
}); });
let sleep_rear = to_binary_string_post2021(&LaptopAuraPower { let sleep_rear = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::RearGlow, AuraPowerState {
boot: false, zone: PowerZones::RearGlow,
awake: false, boot: false,
sleep: true, awake: false,
shutdown: false, sleep: true,
}], shutdown: false,
},
],
}); });
let shut_rear_ = to_binary_string_post2021(&LaptopAuraPower { let shut_rear_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::RearGlow, AuraPowerState {
boot: false, zone: PowerZones::RearGlow,
awake: false, boot: false,
sleep: false, awake: false,
shutdown: true, sleep: false,
}], shutdown: true,
},
],
}); });
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000"); assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
+3 -4
View File
@@ -6,7 +6,6 @@
use std::fmt::Debug; use std::fmt::Debug;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
@@ -62,9 +61,10 @@ pub const ORANGE: Colour = Colour {
g: 0xa4, g: 0xa4,
b: 0x00, b: 0x00,
}; };
pub const GRADIENT: [Colour; 7] = [RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE]; pub const GRADIENT: [Colour; 7] = [
RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE,
];
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AuraDeviceType { pub enum AuraDeviceType {
@@ -116,7 +116,6 @@ impl From<&str> for AuraDeviceType {
} }
/// The powerr zones this laptop supports /// The powerr zones this laptop supports
#[typeshare]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
+6 -3
View File
@@ -1,4 +1,7 @@
// Only these two packets must be 17 bytes // Only these two packets must be 17 bytes
pub const AURA_LAPTOP_LED_APPLY: [u8; 17] = pub const AURA_LAPTOP_LED_APPLY: [u8; 17] = [
[0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; 0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
pub const AURA_LAPTOP_LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; ];
pub const AURA_LAPTOP_LED_SET: [u8; 17] = [
0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];
+1
View File
@@ -41,6 +41,7 @@ zbus.workspace = true
dirs.workspace = true dirs.workspace = true
notify-rust.workspace = true notify-rust.workspace = true
concat-idents.workspace = true concat-idents.workspace = true
futures-util.workspace = true
versions.workspace = true versions.workspace = true
+1 -3
View File
@@ -5,7 +5,6 @@ use slint_build::CompilerConfiguration;
fn main() { fn main() {
// write_locales(); // write_locales();
let root = env!("CARGO_MANIFEST_DIR"); let root = env!("CARGO_MANIFEST_DIR");
let mut main = PathBuf::from_str(root).unwrap(); let mut main = PathBuf::from_str(root).unwrap();
main.push("ui/main_window.slint"); main.push("ui/main_window.slint");
@@ -14,13 +13,12 @@ fn main() {
include.push("ui"); include.push("ui");
slint_build::print_rustc_flags().unwrap(); slint_build::print_rustc_flags().unwrap();
// slint_build::compile("ui/main_window.slint").unwrap();
slint_build::compile_with_config( slint_build::compile_with_config(
main, main,
CompilerConfiguration::new() CompilerConfiguration::new()
// .embed_resources(EmbedResourcesKind::EmbedFiles) // .embed_resources(EmbedResourcesKind::EmbedFiles)
.with_include_paths(vec![include]) .with_include_paths(vec![include])
.with_style("fluent-dark".into()), .with_style("fluent".into()),
) )
.unwrap(); .unwrap();
} }
@@ -1,7 +1,6 @@
[Desktop Entry] [Desktop Entry]
Version=1.0 Version=1.0
Type=Application Type=Application
Name=ROG Control Center Name=ROG Control Center
Comment=Make your ASUS ROG Laptop go Brrrrr! Comment=Make your ASUS ROG Laptop go Brrrrr!
Categories=Settings Categories=Settings
+1 -1
View File
@@ -15,7 +15,7 @@ pub mod notify;
pub mod tray; pub mod tray;
pub mod types; pub mod types;
pub mod ui; pub mod ui;
pub mod zbus; pub mod zbus_proxies;
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png"; pub const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png";
+52 -70
View File
@@ -1,5 +1,4 @@
use std::borrow::BorrowMut; use std::env::{self, args};
use std::env::args;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::exit; use std::process::exit;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
@@ -17,7 +16,7 @@ use rog_control_center::notify::start_notifications;
use rog_control_center::slint::ComponentHandle; use rog_control_center::slint::ComponentHandle;
use rog_control_center::tray::init_tray; use rog_control_center::tray::init_tray;
use rog_control_center::ui::setup_window; use rog_control_center::ui::setup_window;
use rog_control_center::zbus::{ use rog_control_center::zbus_proxies::{
AppState, ROGCCZbus, ROGCCZbusProxyBlocking, ZBUS_IFACE, ZBUS_PATH, AppState, ROGCCZbus, ROGCCZbusProxyBlocking, ZBUS_IFACE, ZBUS_PATH,
}; };
use rog_control_center::{print_versions, MainWindow}; use rog_control_center::{print_versions, MainWindow};
@@ -33,6 +32,14 @@ async fn main() -> Result<()> {
.format_timestamp(None) .format_timestamp(None)
.init(); .init();
// If we're running under gamescope we have to set WAYLAND_DISPLAY for winit to
// use
if let Ok(gamescope) = env::var("GAMESCOPE_WAYLAND_DISPLAY") {
if !gamescope.is_empty() {
env::set_var("WAYLAND_DISPLAY", gamescope);
}
}
// Try to open a proxy and check for app state first // Try to open a proxy and check for app state first
{ {
let user_con = zbus::blocking::Connection::session()?; let user_con = zbus::blocking::Connection::session()?;
@@ -50,7 +57,12 @@ async fn main() -> Result<()> {
let self_version = env!("CARGO_PKG_VERSION"); let self_version = env!("CARGO_PKG_VERSION");
let zbus_con = zbus::blocking::Connection::system()?; let zbus_con = zbus::blocking::Connection::system()?;
let platform_proxy = rog_dbus::zbus_platform::PlatformProxyBlocking::new(&zbus_con)?; let platform_proxy = rog_dbus::zbus_platform::PlatformProxyBlocking::new(&zbus_con)?;
let asusd_version = platform_proxy.version().unwrap(); let asusd_version = platform_proxy
.version()
.map_err(|e| {
println!("Could not get asusd version: {e:?}\nIs asusd.service running?");
})
.unwrap();
if asusd_version != self_version { if asusd_version != self_version {
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}"); println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
return Ok(()); return Ok(());
@@ -80,7 +92,7 @@ async fn main() -> Result<()> {
let board_name = dmi.board_name; let board_name = dmi.board_name;
let prod_family = dmi.product_family; let prod_family = dmi.product_family;
info!("Running on {board_name}, product: {prod_family}"); info!("Running on {board_name}, product: {prod_family}");
let is_rog_ally = prod_family == "RC71L"; let is_rog_ally = prod_family == "RC71L" || prod_family == "RC72L";
let args: Vec<String> = args().skip(1).collect(); let args: Vec<String> = args().skip(1).collect();
@@ -116,10 +128,7 @@ async fn main() -> Result<()> {
config.enable_tray_icon = false; config.enable_tray_icon = false;
config.run_in_background = false; config.run_in_background = false;
config.startup_in_background = false; config.startup_in_background = false;
} config.start_fullscreen = true;
if config.startup_in_background {
config.run_in_background = true;
} }
config.write(); config.write();
@@ -137,8 +146,8 @@ async fn main() -> Result<()> {
// i_slint_backend_selector::with_platform(|_| Ok(())).unwrap(); // i_slint_backend_selector::with_platform(|_| Ok(())).unwrap();
if !startup_in_background { if !startup_in_background {
if let Ok(mut lock) = app_state.lock() { if let Ok(mut app_state) = app_state.lock() {
*lock = AppState::MainWindowShouldOpen; *app_state = AppState::MainWindowShouldOpen;
} }
} }
@@ -155,15 +164,16 @@ async fn main() -> Result<()> {
let mut state = AppState::StartingUp; let mut state = AppState::StartingUp;
loop { loop {
// save as a var, don't hold the lock the entire time or deadlocks happen // save as a var, don't hold the lock the entire time or deadlocks happen
if let Ok(lock) = app_state.lock() { if let Ok(app_state) = app_state.lock() {
state = *lock; state = *app_state;
} }
// This sleep is required to give the event loop time to react
sleep(Duration::from_millis(300));
if state == AppState::MainWindowShouldOpen { if state == AppState::MainWindowShouldOpen {
if let Ok(mut lock) = app_state.lock() { if let Ok(mut app_state) = app_state.lock() {
*lock = AppState::MainWindowOpen; *app_state = AppState::MainWindowOpen;
} }
sleep(Duration::from_millis(50));
let config_copy = config.clone(); let config_copy = config.clone();
let app_state_copy = app_state.clone(); let app_state_copy = app_state.clone();
@@ -174,20 +184,39 @@ async fn main() -> Result<()> {
if let Some(ui) = ui.as_mut() { if let Some(ui) = ui.as_mut() {
ui.window().show().unwrap(); ui.window().show().unwrap();
ui.window().on_close_requested(move || { ui.window().on_close_requested(move || {
if let Ok(mut lock) = app_state_copy.lock() { if let Ok(mut app_state) = app_state_copy.lock() {
*lock = AppState::MainWindowClosed; *app_state = AppState::MainWindowClosed;
} }
slint::CloseRequestResponse::HideWindow slint::CloseRequestResponse::HideWindow
}); });
} else { } else {
let config_copy_2 = config_copy.clone();
let newui = setup_window(config_copy); let newui = setup_window(config_copy);
newui.window().show().unwrap();
newui.window().on_close_requested(move || { newui.window().on_close_requested(move || {
if let Ok(mut lock) = app_state_copy.lock() { if let Ok(mut app_state) = app_state_copy.lock() {
*lock = AppState::MainWindowClosed; *app_state = AppState::MainWindowClosed;
} }
slint::CloseRequestResponse::HideWindow slint::CloseRequestResponse::HideWindow
}); });
let ui_copy = newui.as_weak();
newui
.window()
.set_rendering_notifier(move |s, _| {
if let slint::RenderingState::RenderingSetup = s {
let config = config_copy_2.clone();
ui_copy
.upgrade_in_event_loop(move |w| {
let fullscreen =
config.lock().is_ok_and(|c| c.start_fullscreen);
if fullscreen && !w.window().is_fullscreen() {
w.window().set_fullscreen(fullscreen);
}
})
.ok();
}
})
.ok();
ui.replace(newui); ui.replace(newui);
} }
}); });
@@ -197,24 +226,13 @@ async fn main() -> Result<()> {
slint::quit_event_loop().unwrap(); slint::quit_event_loop().unwrap();
exit(0); exit(0);
} else if state != AppState::MainWindowOpen { } else if state != AppState::MainWindowOpen {
if let Ok(lock) = config.lock() { if let Ok(config) = config.lock() {
if !lock.run_in_background { if !config.run_in_background {
slint::quit_event_loop().unwrap(); slint::quit_event_loop().unwrap();
exit(0); exit(0);
} }
} }
slint::invoke_from_event_loop(move || {
UI.with(|ui| {
let mut ui = ui.take();
if let Some(ui) = ui.borrow_mut() {
ui.window().hide().unwrap();
}
});
})
.unwrap();
} }
sleep(Duration::from_millis(300));
} }
}); });
@@ -223,42 +241,6 @@ async fn main() -> Result<()> {
Ok(()) Ok(())
} }
// /// Bah.. the icon dosn't work on wayland anyway, but we'll leave it in for
// now. fn load_icon() -> IconData {
// let path = PathBuf::from(APP_ICON_PATH);
// let mut rgba = Vec::new();
// let mut height = 512;
// let mut width = 512;
// if path.exists() {
// if let Ok(data) = std::fs::read(path)
// .map_err(|e| error!("Error reading app icon: {e:?}"))
// .map_err(|e| error!("Error opening app icon: {e:?}"))
// {
// let data = std::io::Cursor::new(data);
// let decoder = png_pong::Decoder::new(data).unwrap().into_steps();
// let png_pong::Step { raster, delay: _ } =
// decoder.last().unwrap().unwrap();
// if let png_pong::PngRaster::Rgba8(ras) = raster {
// rgba = ras.as_u8_slice().to_vec();
// width = ras.width();
// height = ras.height();
// info!("Loaded app icon. Not actually supported in Wayland
// yet"); }
// }
// } else {
// error!("Missing {APP_ICON_PATH}");
// }
// IconData {
// height,
// width,
// rgba
//
//
// / }
// }
fn do_cli_help(parsed: &CliStart) -> bool { fn do_cli_help(parsed: &CliStart) -> bool {
if parsed.help { if parsed.help {
println!("{}", CliStart::usage()); println!("{}", CliStart::usage());
+12 -4
View File
@@ -125,10 +125,18 @@ impl Profile {
pub fn fan_curve_data(&self, _p: rog_profiles::Profile) -> Result<FanCurveSet> { pub fn fan_curve_data(&self, _p: rog_profiles::Profile) -> Result<FanCurveSet> {
let mut curve = FanCurveSet::default(); let mut curve = FanCurveSet::default();
curve.cpu.pwm = [30, 40, 60, 100, 140, 180, 200, 250]; curve.cpu.pwm = [
curve.cpu.temp = [20, 30, 40, 50, 70, 80, 90, 100]; 30, 40, 60, 100, 140, 180, 200, 250,
curve.gpu.pwm = [40, 80, 100, 140, 170, 200, 230, 250]; ];
curve.gpu.temp = [20, 30, 40, 50, 70, 80, 90, 100]; curve.cpu.temp = [
20, 30, 40, 50, 70, 80, 90, 100,
];
curve.gpu.pwm = [
40, 80, 100, 140, 170, 200, 230, 250,
];
curve.gpu.temp = [
20, 30, 40, 50, 70, 80, 90, 100,
];
Ok(curve) Ok(curve)
} }
+39 -34
View File
@@ -11,7 +11,6 @@ use std::time::Duration;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use notify_rust::{Hint, Notification, Timeout, Urgency}; use notify_rust::{Hint, Notification, Timeout, Urgency};
use rog_dbus::zbus_platform::PlatformProxy;
use rog_platform::platform::GpuMode; use rog_platform::platform::GpuMode;
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -154,39 +153,41 @@ pub fn start_notifications(
}; };
// GPU MUX Mode notif // GPU MUX Mode notif
let enabled_notifications_copy = config.clone(); // TODO: need to get armoury attrs and iter to find
tokio::spawn(async move { // let enabled_notifications_copy = config.clone();
let conn = zbus::Connection::system().await.map_err(|e| { // tokio::spawn(async move {
error!("zbus signal: receive_notify_gpu_mux_mode: {e}"); // let conn = zbus::Connection::system().await.map_err(|e| {
e // error!("zbus signal: receive_notify_gpu_mux_mode: {e}");
})?; // e
let proxy = PlatformProxy::new(&conn).await.map_err(|e| { // })?;
error!("zbus signal: receive_notify_gpu_mux_mode: {e}"); // let proxy = PlatformProxy::new(&conn).await.map_err(|e| {
e // error!("zbus signal: receive_notify_gpu_mux_mode: {e}");
})?; // e
// })?;
let mut actual_mux_mode = GpuMode::Error; // let mut actual_mux_mode = GpuMode::Error;
if let Ok(mode) = proxy.gpu_mux_mode().await { // if let Ok(mode) = proxy.gpu_mux_mode().await {
actual_mux_mode = GpuMode::from(mode); // actual_mux_mode = GpuMode::from(mode);
} // }
info!("Started zbus signal thread: receive_notify_gpu_mux_mode"); // info!("Started zbus signal thread: receive_notify_gpu_mux_mode");
while let Some(e) = proxy.receive_gpu_mux_mode_changed().await.next().await { // while let Some(e) =
if let Ok(config) = enabled_notifications_copy.lock() { // proxy.receive_gpu_mux_mode_changed().await.next().await { if let
if !config.notifications.enabled || !config.notifications.receive_notify_gfx { // Ok(config) = enabled_notifications_copy.lock() { if
continue; // !config.notifications.enabled || !config.notifications.receive_notify_gfx {
} // continue;
} // }
if let Ok(out) = e.get().await { // }
let mode = GpuMode::from(out); // if let Ok(out) = e.get().await {
if mode == actual_mux_mode { // let mode = GpuMode::from(out);
continue; // if mode == actual_mux_mode {
} // continue;
do_mux_notification("Reboot required. BIOS GPU MUX mode set to", &mode).ok(); // }
} // do_mux_notification("Reboot required. BIOS GPU MUX mode set to",
} // &mode).ok(); }
Ok::<(), zbus::Error>(()) // }
}); // Ok::<(), zbus::Error>(())
// });
let enabled_notifications_copy = config.clone(); let enabled_notifications_copy = config.clone();
// GPU Mode change/action notif // GPU Mode change/action notif
@@ -329,7 +330,9 @@ fn do_gfx_action_notif(message: &str, action: GfxUserAction, mode: GpuMode) -> R
handle.wait_for_action(|id| { handle.wait_for_action(|id| {
if id == "gfx-mode-session-action" { if id == "gfx-mode-session-action" {
let mut cmd = Command::new("qdbus"); let mut cmd = Command::new("qdbus");
cmd.args(["org.kde.ksmserver", "/KSMServer", "logout", "1", "0", "0"]); cmd.args([
"org.kde.ksmserver", "/KSMServer", "logout", "1", "0", "0",
]);
cmd.spawn().ok(); cmd.spawn().ok();
} else if id == "__closed" { } else if id == "__closed" {
// TODO: cancel the switching // TODO: cancel the switching
@@ -371,7 +374,9 @@ fn do_mux_notification(message: &str, m: &GpuMode) -> Result<()> {
handle.wait_for_action(|id| { handle.wait_for_action(|id| {
if id == "gfx-mode-session-action" { if id == "gfx-mode-session-action" {
let mut cmd = Command::new("qdbus"); let mut cmd = Command::new("qdbus");
cmd.args(["org.kde.ksmserver", "/KSMServer", "logout", "1", "1", "0"]); cmd.args([
"org.kde.ksmserver", "/KSMServer", "logout", "1", "1", "0",
]);
cmd.spawn().ok(); cmd.spawn().ok();
} else if id == "__closed" { } else if id == "__closed" {
// TODO: cancel the switching // TODO: cancel the switching
+24 -12
View File
@@ -14,7 +14,7 @@ use supergfxctl::zbus_proxy::DaemonProxy as GfxProxy;
use versions::Versioning; use versions::Versioning;
use crate::config::Config; use crate::config::Config;
use crate::zbus::{AppState, ROGCCZbusProxyBlocking}; use crate::zbus_proxies::{AppState, ROGCCZbusProxyBlocking};
const TRAY_LABEL: &str = "ROG Control Center"; const TRAY_LABEL: &str = "ROG Control Center";
const TRAY_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/"; const TRAY_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/";
@@ -32,7 +32,10 @@ static ICONS: OnceLock<Icons> = OnceLock::new();
fn read_icon(file: &Path) -> Icon { fn read_icon(file: &Path) -> Icon {
let mut path = PathBuf::from(TRAY_ICON_PATH); let mut path = PathBuf::from(TRAY_ICON_PATH);
path.push(file); path.push(file);
let mut file = OpenOptions::new().read(true).open(path).unwrap(); let mut file = OpenOptions::new()
.read(true)
.open(&path)
.unwrap_or_else(|_| panic!("Missing icon: {:?}", path));
let mut bytes = Vec::new(); let mut bytes = Vec::new();
file.read_to_end(&mut bytes).unwrap(); file.read_to_end(&mut bytes).unwrap();
@@ -127,7 +130,6 @@ async fn set_tray_icon_and_tip(
}; };
tray.update(|tray: &mut AsusTray| { tray.update(|tray: &mut AsusTray| {
dbg!(power);
tray.current_icon = icon; tray.current_icon = icon;
tray.current_title = format!( tray.current_title = format!(
"ROG: gpu mode = {mode:?}, gpu power = "ROG: gpu mode = {mode:?}, gpu power =
@@ -160,21 +162,23 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
let rog_red = read_icon(&PathBuf::from("asus_notif_red.png")); let rog_red = read_icon(&PathBuf::from("asus_notif_red.png"));
let tray = AsusTray { let tray_init = AsusTray {
current_title: TRAY_LABEL.to_string(), current_title: TRAY_LABEL.to_string(),
current_icon: rog_red.clone(), current_icon: rog_red.clone(),
proxy, proxy,
}; };
let mut tray = tray // TODO: return an error to the UI
.spawn_without_dbus_name() let mut tray;
.await match tray_init.spawn_without_dbus_name().await {
.map_err(|e| { Ok(t) => tray = t,
Err(e) => {
log::error!( log::error!(
"Tray unable to be initialised: {e:?}. Do you have a system tray enabled?" "Tray unable to be initialised: {e:?}. Do you have a system tray enabled?"
) );
}) return;
.unwrap(); }
}
info!("Tray started"); info!("Tray started");
let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png")); let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png"));
@@ -207,7 +211,15 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
} }
} }
} }
Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}"), Err(e) => match e {
zbus::Error::MethodError(_, _, message) => {
warn!(
"Couldn't get mode from supergfxd: {message:?}, the supergfxd service \
may not be running or installed"
)
}
_ => warn!("Couldn't get mode from supergfxd: {e:?}"),
},
} }
info!("Started ROGTray"); info!("Started ROGTray");
+12 -10
View File
@@ -1,24 +1,26 @@
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
use crate::{FanType, Profile}; use crate::{FanType, Profile};
impl From<Profile> for ThrottlePolicy { impl From<Profile> for PlatformProfile {
fn from(value: Profile) -> Self { fn from(value: Profile) -> Self {
match value { match value {
Profile::Balanced => ThrottlePolicy::Balanced, Profile::Balanced => PlatformProfile::Balanced,
Profile::Performance => ThrottlePolicy::Performance, Profile::Performance => PlatformProfile::Performance,
Profile::Quiet => ThrottlePolicy::Quiet, Profile::Quiet => PlatformProfile::Quiet,
Profile::LowPower => PlatformProfile::LowPower,
} }
} }
} }
impl From<ThrottlePolicy> for Profile { impl From<PlatformProfile> for Profile {
fn from(value: ThrottlePolicy) -> Self { fn from(value: PlatformProfile) -> Self {
match value { match value {
ThrottlePolicy::Balanced => Profile::Balanced, PlatformProfile::Balanced => Profile::Balanced,
ThrottlePolicy::Performance => Profile::Performance, PlatformProfile::Performance => Profile::Performance,
ThrottlePolicy::Quiet => Profile::Quiet, PlatformProfile::Quiet => Profile::Quiet,
PlatformProfile::LowPower => Profile::LowPower,
} }
} }
} }
+16 -34
View File
@@ -6,8 +6,9 @@ pub mod setup_system;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use config_traits::StdConfig; use config_traits::StdConfig;
use log::warn;
use rog_dbus::list_iface_blocking; use rog_dbus::list_iface_blocking;
use slint::{ComponentHandle, PhysicalSize, SharedString, Weak}; use slint::{ComponentHandle, SharedString, Weak};
use crate::config::Config; use crate::config::Config;
use crate::ui::setup_anime::setup_anime_page; use crate::ui::setup_anime::setup_anime_page;
@@ -16,21 +17,6 @@ use crate::ui::setup_fans::setup_fan_curve_page;
use crate::ui::setup_system::{setup_system_page, setup_system_page_callbacks}; use crate::ui::setup_system::{setup_system_page, setup_system_page_callbacks};
use crate::{AppSettingsPageData, MainWindow}; use crate::{AppSettingsPageData, MainWindow};
// This macro expects are consistent naming between proxy calls and slint
// globals
#[macro_export]
macro_rules! set_ui_props_async {
($ui:ident, $proxy:ident, $global:ident, $proxy_fn:ident) => {
if let Ok(value) = $proxy.$proxy_fn().await {
$ui.upgrade_in_event_loop(move |handle| {
concat_idents::concat_idents!(set = set_, $proxy_fn {
handle.global::<$global>().set(value.into());
});
}).ok();
}
};
}
// this macro sets up: // this macro sets up:
// - a link from UI callback -> dbus proxy property // - a link from UI callback -> dbus proxy property
// - a link from dbus property signal -> UI state // - a link from dbus property signal -> UI state
@@ -41,7 +27,7 @@ macro_rules! set_ui_callbacks {
let handle_copy = $handle.as_weak(); let handle_copy = $handle.as_weak();
let proxy_copy = $proxy.clone(); let proxy_copy = $proxy.clone();
let data = $handle.global::<$data>(); let data = $handle.global::<$data>();
concat_idents::concat_idents!(on_set = on_set_, $proxy_fn { concat_idents::concat_idents!(on_set = on_cb_, $proxy_fn {
data.on_set(move |value| { data.on_set(move |value| {
let proxy_copy = proxy_copy.clone(); let proxy_copy = proxy_copy.clone();
let handle_copy = handle_copy.clone(); let handle_copy = handle_copy.clone();
@@ -97,25 +83,20 @@ pub fn show_toast(
} }
pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow { pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
slint::set_xdg_app_id("rog-control-center")
.map_err(|e| warn!("Couldn't set application ID: {e:?}"))
.ok();
let ui = MainWindow::new().unwrap(); let ui = MainWindow::new().unwrap();
if let Ok(lock) = config.try_lock() { ui.window().show().unwrap();
let fullscreen = lock.start_fullscreen;
let width = lock.fullscreen_width;
let height = lock.fullscreen_height;
if fullscreen {
ui.window().set_fullscreen(fullscreen);
ui.window().set_size(PhysicalSize { width, height });
}
};
let available = list_iface_blocking().unwrap_or_default(); let available = list_iface_blocking().unwrap_or_default();
ui.set_sidebar_items_avilable( ui.set_sidebar_items_avilable(
[ [
// Needs to match the order of slint sidebar items // Needs to match the order of slint sidebar items
available.contains(&"org.asuslinux.Platform".to_string()), available.contains(&"xyz.ljones.Platform".to_string()),
available.contains(&"org.asuslinux.Aura".to_string()), available.contains(&"xyz.ljones.Aura".to_string()),
available.contains(&"org.asuslinux.Anime".to_string()), available.contains(&"xyz.ljones.Anime".to_string()),
available.contains(&"org.asuslinux.FanCurves".to_string()), available.contains(&"xyz.ljones.FanCurves".to_string()),
true, true,
true, true,
] ]
@@ -127,19 +108,20 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
}); });
setup_app_settings_page(&ui, config.clone()); setup_app_settings_page(&ui, config.clone());
if available.contains(&"org.asuslinux.Platform".to_string()) { if available.contains(&"xyz.ljones.Platform".to_string()) {
setup_system_page(&ui, config.clone()); setup_system_page(&ui, config.clone());
setup_system_page_callbacks(&ui, config.clone()); setup_system_page_callbacks(&ui, config.clone());
} }
if available.contains(&"org.asuslinux.Aura".to_string()) { if available.contains(&"xyz.ljones.Aura".to_string()) {
setup_aura_page(&ui, config.clone()); setup_aura_page(&ui, config.clone());
} }
if available.contains(&"org.asuslinux.Anime".to_string()) { if available.contains(&"xyz.ljones.Anime".to_string()) {
setup_anime_page(&ui, config.clone()); setup_anime_page(&ui, config.clone());
} }
if available.contains(&"org.asuslinux.FanCurves".to_string()) { if available.contains(&"xyz.ljones.FanCurves".to_string()) {
setup_fan_curve_page(&ui, config); setup_fan_curve_page(&ui, config);
} }
ui ui
} }
+111 -111
View File
@@ -1,7 +1,8 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use log::{error, info, warn}; use log::{error, info};
use rog_anime::Animations; use rog_anime::Animations;
use rog_dbus::find_iface_async;
use rog_dbus::zbus_anime::AnimeProxy; use rog_dbus::zbus_anime::AnimeProxy;
use slint::ComponentHandle; use slint::ComponentHandle;
@@ -12,124 +13,123 @@ use crate::{set_ui_callbacks, set_ui_props_async, AnimePageData, MainWindow};
pub fn setup_anime_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) { pub fn setup_anime_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
let handle = ui.as_weak(); let handle = ui.as_weak();
tokio::spawn(async move { tokio::spawn(async move {
let Ok(conn) = zbus::Connection::system().await.map_err(|e| warn!("{e:}")) else { let Ok(animes) = find_iface_async::<AnimeProxy>("xyz.ljones.Anime").await else {
return; info!("This device appears to have no aura interfaces");
};
let Ok(anime) = AnimeProxy::new(&conn).await.map_err(|e| warn!("{e:}")) else {
info!("This device may not have an AniMe. If not then the error can be ignored");
return; return;
}; };
set_ui_props_async!(handle, anime, AnimePageData, brightness); for anime in animes {
set_ui_props_async!(handle, anime, AnimePageData, builtins_enabled); set_ui_props_async!(handle, anime, AnimePageData, brightness);
set_ui_props_async!(handle, anime, AnimePageData, enable_display); set_ui_props_async!(handle, anime, AnimePageData, builtins_enabled);
set_ui_props_async!(handle, anime, AnimePageData, off_when_lid_closed); set_ui_props_async!(handle, anime, AnimePageData, enable_display);
set_ui_props_async!(handle, anime, AnimePageData, off_when_suspended); set_ui_props_async!(handle, anime, AnimePageData, off_when_lid_closed);
set_ui_props_async!(handle, anime, AnimePageData, off_when_unplugged); set_ui_props_async!(handle, anime, AnimePageData, off_when_suspended);
set_ui_props_async!(handle, anime, AnimePageData, off_when_unplugged);
let builtins = anime.builtin_animations().await.unwrap_or_default(); let builtins = anime.builtin_animations().await.unwrap_or_default();
handle handle
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
{ {
let global = handle.global::<AnimePageData>(); let global = handle.global::<AnimePageData>();
global.set_boot_anim(builtins.boot as i32); global.set_boot_anim(builtins.boot as i32);
global.set_awake_anim(builtins.awake as i32); global.set_awake_anim(builtins.awake as i32);
global.set_sleep_anim(builtins.sleep as i32); global.set_sleep_anim(builtins.sleep as i32);
global.set_shutdown_anim(builtins.shutdown as i32); global.set_shutdown_anim(builtins.shutdown as i32);
let handle_copy = handle.as_weak(); let handle_copy = handle.as_weak();
let anime_copy = anime.clone(); let anime_copy = anime.clone();
global.on_set_builtin_animations(move |boot, awake, sleep, shutdown| { global.on_cb_builtin_animations(move |boot, awake, sleep, shutdown| {
let handle_copy = handle_copy.clone(); let handle_copy = handle_copy.clone();
let anime_copy = anime_copy.clone(); let anime_copy = anime_copy.clone();
tokio::spawn(async move { tokio::spawn(async move {
show_toast( show_toast(
"Anime builtin animations changed".into(), "Anime builtin animations changed".into(),
"Failed to set Anime builtin animations".into(), "Failed to set Anime builtin animations".into(),
handle_copy, handle_copy,
anime_copy anime_copy
.set_builtin_animations(Animations { .set_builtin_animations(Animations {
boot: boot.into(), boot: boot.into(),
awake: awake.into(), awake: awake.into(),
sleep: sleep.into(), sleep: sleep.into(),
shutdown: shutdown.into(), shutdown: shutdown.into(),
}) })
.await, .await,
); );
});
}); });
});
let handle_copy = handle.as_weak(); let handle_copy = handle.as_weak();
let anime_copy = anime.clone(); let anime_copy = anime.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut x = anime_copy.receive_builtin_animations_changed().await; let mut x = anime_copy.receive_builtin_animations_changed().await;
use zbus::export::futures_util::StreamExt; use zbus::export::futures_util::StreamExt;
while let Some(e) = x.next().await { while let Some(e) = x.next().await {
if let Ok(out) = e.get().await { if let Ok(out) = e.get().await {
handle_copy handle_copy
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
handle handle
.global::<AnimePageData>() .global::<AnimePageData>()
.set_boot_anim(out.boot.into()); .set_boot_anim(out.boot.into());
handle handle
.global::<AnimePageData>() .global::<AnimePageData>()
.set_awake_anim(out.awake.into()); .set_awake_anim(out.awake.into());
handle handle
.global::<AnimePageData>() .global::<AnimePageData>()
.set_sleep_anim(out.sleep.into()); .set_sleep_anim(out.sleep.into());
handle handle
.global::<AnimePageData>() .global::<AnimePageData>()
.set_shutdown_anim(out.shutdown.into()); .set_shutdown_anim(out.shutdown.into());
}) })
.ok(); .ok();
}
} }
} });
}); }
}
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
AnimePageData(.into()), AnimePageData(.into()),
anime.brightness(.into()), anime.brightness(.into()),
"Anime LED brightness successfully set to {}", "Anime LED brightness successfully set to {}",
"Setting Anime LED brightness failed" "Setting Anime LED brightness failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
AnimePageData(), AnimePageData(),
anime.builtins_enabled(), anime.builtins_enabled(),
"Keyboard LED mode successfully set to {}", "Keyboard LED mode successfully set to {}",
"Setting keyboard LEDmode failed" "Setting keyboard LEDmode failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
AnimePageData(), AnimePageData(),
anime.enable_display(), anime.enable_display(),
"Anime display successfully set to {}", "Anime display successfully set to {}",
"Setting Anime display failed" "Setting Anime display failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
AnimePageData(), AnimePageData(),
anime.off_when_lid_closed(), anime.off_when_lid_closed(),
"Anime off_when_lid_closed successfully set to {}", "Anime off_when_lid_closed successfully set to {}",
"Setting Anime off_when_lid_closed failed" "Setting Anime off_when_lid_closed failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
AnimePageData(), AnimePageData(),
anime.off_when_suspended(), anime.off_when_suspended(),
"Anime off_when_suspended successfully set to {}", "Anime off_when_suspended successfully set to {}",
"Setting Anime off_when_suspended failed" "Setting Anime off_when_suspended failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
AnimePageData(), AnimePageData(),
anime.off_when_unplugged(), anime.off_when_unplugged(),
"Anime off_when_unplugged successfully set to {}", "Anime off_when_unplugged successfully set to {}",
"Setting Anime off_when_unplugged failed" "Setting Anime off_when_unplugged failed"
); );
}) })
.map_err(|e| error!("setup_anime_page: upgrade_in_event_loop: {e:?}")) .map_err(|e| error!("setup_anime_page: upgrade_in_event_loop: {e:?}"))
.ok(); .ok();
}
}); });
} }
+6 -6
View File
@@ -38,12 +38,12 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
// TODO: return all // TODO: return all
async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Error>> { async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Error>> {
let conn = zbus::Connection::system().await?; let conn = zbus::Connection::system().await?;
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").await?; let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").await?;
let interfaces = f.get_managed_objects().await?; let interfaces = f.get_managed_objects().await?;
let mut aura_paths = Vec::new(); let mut aura_paths = Vec::new();
for v in interfaces.iter() { for v in interfaces.iter() {
for k in v.1.keys() { for k in v.1.keys() {
if k.as_str() == "org.asuslinux.Aura" { if k.as_str() == "xyz.ljones.Aura" {
println!("Found aura device at {}, {}", v.0, k); println!("Found aura device at {}, {}", v.0, k);
aura_paths.push(v.0.clone()); aura_paths.push(v.0.clone());
} }
@@ -56,7 +56,7 @@ async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Err
if let Some(path) = aura_paths.first() { if let Some(path) = aura_paths.first() {
return Ok(AuraProxy::builder(&conn) return Ok(AuraProxy::builder(&conn)
.path(path.clone())? .path(path.clone())?
.destination("org.asuslinux.Daemon")? .destination("xyz.ljones.Asusd")?
.build() .build()
.await?); .await?);
} }
@@ -65,12 +65,12 @@ async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Err
} }
pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) { pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
ui.global::<AuraPageData>().on_set_hex_from_colour(|c| { ui.global::<AuraPageData>().on_cb_hex_from_colour(|c| {
format!("#{:02X}{:02X}{:02X}", c.red(), c.green(), c.blue()).into() format!("#{:02X}{:02X}{:02X}", c.red(), c.green(), c.blue()).into()
}); });
ui.global::<AuraPageData>() ui.global::<AuraPageData>()
.on_set_hex_to_colour(|s| decode_hex(s.as_str()).into()); .on_cb_hex_to_colour(|s| decode_hex(s.as_str()).into());
let handle = ui.as_weak(); let handle = ui.as_weak();
tokio::spawn(async move { tokio::spawn(async move {
@@ -189,7 +189,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
.upgrade_in_event_loop(|handle| { .upgrade_in_event_loop(|handle| {
handle handle
.global::<AuraPageData>() .global::<AuraPageData>()
.on_set_led_power(move |power| { .on_cb_led_power(move |power| {
let handle_copy = handle_copy.clone(); let handle_copy = handle_copy.clone();
let proxy_copy = aura.clone(); let proxy_copy = aura.clone();
let power: LaptopAuraPower = power.into(); let power: LaptopAuraPower = power.into();
+7 -7
View File
@@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex};
use log::{error, info}; use log::{error, info};
use rog_dbus::zbus_fan_curves::FanCurvesProxy; use rog_dbus::zbus_fan_curves::FanCurvesProxy;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use slint::{ComponentHandle, Model, Weak}; use slint::{ComponentHandle, Model, Weak};
@@ -109,21 +109,21 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
let handle_copy = handle.clone(); let handle_copy = handle.clone();
// Do initial setup // Do initial setup
let Ok(balanced) = fans let Ok(balanced) = fans
.fan_curve_data(ThrottlePolicy::Balanced) .fan_curve_data(PlatformProfile::Balanced)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
return; return;
}; };
let Ok(perf) = fans let Ok(perf) = fans
.fan_curve_data(ThrottlePolicy::Performance) .fan_curve_data(PlatformProfile::Performance)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
return; return;
}; };
let Ok(quiet) = fans let Ok(quiet) = fans
.fan_curve_data(ThrottlePolicy::Quiet) .fan_curve_data(PlatformProfile::Quiet)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
@@ -144,21 +144,21 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
return; return;
} }
let Ok(balanced) = fans let Ok(balanced) = fans
.fan_curve_data(ThrottlePolicy::Balanced) .fan_curve_data(PlatformProfile::Balanced)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
return; return;
}; };
let Ok(perf) = fans let Ok(perf) = fans
.fan_curve_data(ThrottlePolicy::Performance) .fan_curve_data(PlatformProfile::Performance)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
return; return;
}; };
let Ok(quiet) = fans let Ok(quiet) = fans
.fan_curve_data(ThrottlePolicy::Quiet) .fan_curve_data(PlatformProfile::Quiet)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
+417 -140
View File
@@ -1,40 +1,261 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use concat_idents::concat_idents;
use log::{debug, error};
use rog_dbus::asus_armoury::AsusArmouryProxy;
use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking}; use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking};
use rog_platform::asus_armoury::FirmwareAttribute;
use rog_platform::platform::Properties; use rog_platform::platform::Properties;
use slint::ComponentHandle; use slint::ComponentHandle;
use super::show_toast; use super::show_toast;
use crate::config::Config; use crate::config::Config;
use crate::{ use crate::zbus_proxies::find_iface_async;
set_ui_callbacks, set_ui_props_async, AvailableSystemProperties, MainWindow, SystemPageData, use crate::{set_ui_callbacks, set_ui_props_async, AttrMinMax, MainWindow, SystemPageData};
const MINMAX: AttrMinMax = AttrMinMax {
min: 0,
max: 0,
current: -1.0,
}; };
pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) { pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
let conn = zbus::blocking::Connection::system().unwrap(); let conn = zbus::blocking::Connection::system().unwrap();
let platform = PlatformProxyBlocking::new(&conn).unwrap(); let platform = PlatformProxyBlocking::builder(&conn).build().unwrap();
// let armoury_attrs =
// find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury").unwrap();
// Null everything before the setup step
ui.global::<SystemPageData>()
.set_charge_control_end_threshold(-1.0);
ui.global::<SystemPageData>()
.set_charge_control_enabled(false);
ui.global::<SystemPageData>().set_platform_profile(-1);
ui.global::<SystemPageData>().set_panel_overdrive(-1);
ui.global::<SystemPageData>().set_boot_sound(-1);
ui.global::<SystemPageData>().set_mini_led_mode(-1);
ui.global::<SystemPageData>().set_ppt_pl1_spl(MINMAX);
ui.global::<SystemPageData>().set_ppt_pl2_sppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_pl3_fppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_fppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_apu_sppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_platform_sppt(MINMAX);
ui.global::<SystemPageData>().set_nv_dynamic_boost(MINMAX);
ui.global::<SystemPageData>().set_nv_temp_target(MINMAX);
ui.global::<SystemPageData>().set_ppt_enabled(false);
ui.global::<SystemPageData>()
.set_ppt_enabled_available(false);
let sys_props = platform.supported_properties().unwrap(); let sys_props = platform.supported_properties().unwrap();
log::debug!("Available system properties: {sys_props:?}"); log::debug!("Available system properties: {:?}", &sys_props);
let props = AvailableSystemProperties { if sys_props.contains(&Properties::ChargeControlEndThreshold) {
ac_command: true, ui.global::<SystemPageData>()
bat_command: true, .set_charge_control_end_threshold(60.0);
charge_control_end_threshold: sys_props.contains(&Properties::ChargeControlEndThreshold), ui.global::<SystemPageData>()
disable_nvidia_powerd_on_battery: true, .set_charge_control_enabled(true);
mini_led_mode: sys_props.contains(&Properties::MiniLedMode), }
nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost), }
nv_temp_target: sys_props.contains(&Properties::NvTempTarget),
panel_od: sys_props.contains(&Properties::PanelOd),
boot_sound: sys_props.contains(&Properties::PostAnimationSound),
ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt),
ppt_fppt: sys_props.contains(&Properties::PptFppt),
ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl),
ppt_pl2_sppt: sys_props.contains(&Properties::PptPl2Sppt),
ppt_platform_sppt: sys_props.contains(&Properties::PptPlatformSppt),
throttle_thermal_policy: sys_props.contains(&Properties::ThrottlePolicy),
};
ui.global::<SystemPageData>().set_available(props); macro_rules! convert_value {
(bool, $value:expr) => {
$value == 1
};
(i32, $value:expr) => {
$value as i32
};
(f32, $value:expr) => {
$value as f32
};
}
macro_rules! convert_to_dbus {
(bool, $value:expr) => {
if $value {
1
} else {
0
}
};
(i32, $value:expr) => {
$value as i32
};
(f32, $value:expr) => {
$value as i32
};
}
macro_rules! init_property {
($property:ident, $handle:expr, $value:expr, $type:tt) => {{
concat_idents!(setter = set_, $property {
$handle.global::<SystemPageData>().setter(convert_value!($type, $value));
});
}};
}
// For initial setup of min/max/val values
macro_rules! init_minmax_property {
($property:ident, $handle:expr, $attr:expr) => {
let proxy_copy = $attr.clone();
let handle_copy = $handle.as_weak();
tokio::spawn(async move {
let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap();
let current = proxy_copy.current_value().await.unwrap() as f32;
handle_copy
.upgrade_in_event_loop(move |handle| {
concat_idents!(setter = set_, $property {
handle
.global::<SystemPageData>()
.setter(AttrMinMax { min, max, current });
});
})
.ok();
});
};
}
// For handling callbacks from UI value changes
macro_rules! setup_callback {
($property:ident, $handle:expr, $attr:expr, $type:tt) => {
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
concat_idents!(on_callback = on_cb_, $property {
$handle
.global::<SystemPageData>()
.on_callback(move |v| {
let handle_copy = handle_copy.clone();
let proxy_copy = proxy_copy.clone();
tokio::spawn(async move {
show_toast(
format!("{} successfully set to {}", stringify!($property), v).into(),
format!("Setting {} failed", stringify!($property)).into(),
handle_copy,
proxy_copy.set_current_value(convert_to_dbus!($type, v)).await,
);
});
});
});
};
}
// For handling callbacks from UI value changes
macro_rules! setup_callback_restore_default {
($property:ident, $handle:expr, $attr:expr) => {
let proxy_copy = $attr.clone();
concat_idents!(on_callback = on_cb_default_, $property {
$handle
.global::<SystemPageData>()
.on_callback(move || {
let proxy_copy = proxy_copy.clone();
tokio::spawn(async move {
proxy_copy.restore_default().await.ok();
});
});
});
};
}
macro_rules! setup_external {
($property:ident, $type:tt, $handle:expr, $attr:expr, $value:expr) => {{
// EXTERNAL CHANGES
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
concat_idents!(setter = set_, $property {
tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await;
use futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
handle_copy
.upgrade_in_event_loop(move |handle| {
handle
.global::<SystemPageData>()
.setter(convert_value!($type, out));
})
.ok();
}
}
});
});
}};
}
// For handling external value changes
macro_rules! setup_value_watch {
($property:ident, $handle:expr, $proxy:expr, $value_type:ident $($conv: tt)*) => {
let handle_copy = $handle.as_weak();
let proxy_copy = $proxy.clone();
tokio::spawn(async move {
let mut x = concat_idents!(recv = receive_, $value_type, _value_changed {
proxy_copy.recv().await
});
use futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
concat_idents!(getter = get_, $property {
handle_copy
.upgrade_in_event_loop(move |handle| {
let mut tmp: AttrMinMax =
handle.global::<SystemPageData>().getter();
tmp.$value_type = out $($conv)*;
concat_idents!(setter = set_, $property {
handle.global::<SystemPageData>().setter(tmp);
});
})
.ok();
});
}
}
});
};
}
macro_rules! setup_minmax_external {
($property:ident, $handle:expr, $attr:expr, $platform:expr) => {
setup_value_watch!($property, $handle, $attr, current as f32);
setup_value_watch!($property, $handle, $attr, min);
setup_value_watch!($property, $handle, $attr, max);
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
let platform_proxy_copy = $platform.clone();
tokio::spawn(async move {
let mut x = platform_proxy_copy.receive_platform_profile_changed().await;
use futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(_) = e.get().await {
debug!("receive_platform_profile_changed, getting new {}", stringify!(attr));
let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap();
let current = proxy_copy.current_value().await.unwrap() as f32;
handle_copy
.upgrade_in_event_loop(move |handle| {
concat_idents!(setter = set_, $property {
handle
.global::<SystemPageData>()
.setter(AttrMinMax { min, max, current });
});
})
.ok();
}
}
});
};
}
// This macro expects are consistent naming between proxy calls and slint
// globals
#[macro_export]
macro_rules! set_ui_props_async {
($ui:ident, $proxy:ident, $global:ident, $proxy_fn:ident) => {
if let Ok(value) = $proxy.$proxy_fn().await {
$ui.upgrade_in_event_loop(move |handle| {
concat_idents::concat_idents!(set = set_, $proxy_fn {
handle.global::<$global>().set(value.into());
});
}).ok();
}
};
} }
pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>) { pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
@@ -45,7 +266,7 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
tokio::spawn(async move { tokio::spawn(async move {
// Create the connections/proxies here to prevent future delays in process // Create the connections/proxies here to prevent future delays in process
let conn = zbus::Connection::system().await.unwrap(); let conn = zbus::Connection::system().await.unwrap();
let platform = PlatformProxy::new(&conn).await.unwrap(); let platform = PlatformProxy::builder(&conn).build().await.unwrap();
set_ui_props_async!( set_ui_props_async!(
handle, handle,
@@ -53,190 +274,246 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
SystemPageData, SystemPageData,
charge_control_end_threshold charge_control_end_threshold
); );
set_ui_props_async!(handle, platform, SystemPageData, throttle_thermal_policy);
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_linked_epp); set_ui_props_async!(handle, platform, SystemPageData, platform_profile);
set_ui_props_async!(handle, platform, SystemPageData, throttle_balanced_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_performance_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_quiet_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_battery);
set_ui_props_async!( set_ui_props_async!(
handle, handle,
platform, platform,
SystemPageData, SystemPageData,
change_throttle_policy_on_battery platform_profile_linked_epp
); );
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_ac); set_ui_props_async!(handle, platform, SystemPageData, profile_balanced_epp);
set_ui_props_async!(handle, platform, SystemPageData, profile_performance_epp);
set_ui_props_async!(handle, platform, SystemPageData, profile_quiet_epp);
set_ui_props_async!( set_ui_props_async!(
handle, handle,
platform, platform,
SystemPageData, SystemPageData,
change_throttle_policy_on_ac platform_profile_on_battery
);
set_ui_props_async!(
handle,
platform,
SystemPageData,
change_platform_profile_on_battery
);
set_ui_props_async!(handle, platform, SystemPageData, platform_profile_on_ac);
set_ui_props_async!(
handle,
platform,
SystemPageData,
change_platform_profile_on_ac
); );
set_ui_props_async!(handle, platform, SystemPageData, panel_od); set_ui_props_async!(handle, platform, SystemPageData, enable_ppt_group);
set_ui_props_async!(handle, platform, SystemPageData, boot_sound);
set_ui_props_async!(handle, platform, SystemPageData, mini_led_mode);
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl1_spl);
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl2_sppt);
set_ui_props_async!(handle, platform, SystemPageData, ppt_fppt);
set_ui_props_async!(handle, platform, SystemPageData, ppt_apu_sppt);
set_ui_props_async!(handle, platform, SystemPageData, ppt_platform_sppt);
set_ui_props_async!(handle, platform, SystemPageData, nv_dynamic_boost);
set_ui_props_async!(handle, platform, SystemPageData, nv_temp_target);
let sys_props = platform.supported_properties().await.unwrap(); let platform_copy = platform.clone();
log::debug!("Available system properties: {sys_props:?}");
let props = AvailableSystemProperties {
ac_command: true,
bat_command: true,
charge_control_end_threshold: sys_props
.contains(&Properties::ChargeControlEndThreshold),
disable_nvidia_powerd_on_battery: true,
mini_led_mode: sys_props.contains(&Properties::MiniLedMode),
nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost),
nv_temp_target: sys_props.contains(&Properties::NvTempTarget),
panel_od: sys_props.contains(&Properties::PanelOd),
boot_sound: sys_props.contains(&Properties::PostAnimationSound),
ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt),
ppt_fppt: sys_props.contains(&Properties::PptFppt),
ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl),
ppt_pl2_sppt: sys_props.contains(&Properties::PptPl2Sppt),
ppt_platform_sppt: sys_props.contains(&Properties::PptPlatformSppt),
throttle_thermal_policy: sys_props.contains(&Properties::ThrottlePolicy),
};
// TODO: move the fail/sucess messages to slint
handle handle
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
handle.global::<SystemPageData>().set_available(props); set_ui_callbacks!(handle,
SystemPageData(as bool),
platform_copy.enable_ppt_group(as bool),
"Applied PPT group settings {}",
"Setting PPT group settings failed"
);
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as f32), SystemPageData(as f32),
platform.charge_control_end_threshold(as u8), platform_copy.charge_control_end_threshold(as u8),
"Charge limit successfully set to {}", "Charge limit successfully set to {}",
"Setting Charge limit failed" "Setting Charge limit failed"
); );
set_ui_callbacks!(
handle,
SystemPageData(),
platform.panel_od(),
"Panel OverDrive successfully set to {}",
"Setting Panel OverDrive failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform.boot_sound(),
"POST Animation sound successfully set to {}",
"Setting POST Animation sound failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform.mini_led_mode(),
"MiniLED mode successfully set to {}",
"Setting MiniLED mode failed"
);
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform.throttle_thermal_policy(.into()), platform_copy.platform_profile(.into()),
"Throttle policy set to {}", "Throttle policy set to {}",
"Setting Throttle policy failed" "Setting Throttle policy failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform.throttle_balanced_epp(.into()), platform_copy.profile_balanced_epp(.into()),
"Throttle policy EPP set to {}", "Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed" "Setting Throttle policy EPP failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform.throttle_performance_epp(.into()), platform_copy.profile_performance_epp(.into()),
"Throttle policy EPP set to {}", "Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed" "Setting Throttle policy EPP failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform.throttle_quiet_epp(.into()), platform_copy.profile_quiet_epp(.into()),
"Throttle policy EPP set to {}", "Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed" "Setting Throttle policy EPP failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
SystemPageData(), SystemPageData(),
platform.throttle_policy_linked_epp(), platform_copy.platform_profile_linked_epp(),
"Throttle policy linked to EPP: {}", "Throttle policy linked to EPP: {}",
"Setting Throttle policy linked to EPP failed" "Setting Throttle policy linked to EPP failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform.throttle_policy_on_ac(.into()), platform_copy.platform_profile_on_ac(.into()),
"Throttle policy on AC set to {}", "Throttle policy on AC set to {}",
"Setting Throttle policy on AC failed" "Setting Throttle policy on AC failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as bool), SystemPageData(as bool),
platform.change_throttle_policy_on_ac(.into()), platform_copy.change_platform_profile_on_ac(.into()),
"Throttle policy on AC enabled: {}", "Throttle policy on AC enabled: {}",
"Setting Throttle policy on AC failed" "Setting Throttle policy on AC failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform.throttle_policy_on_battery(.into()), platform_copy.platform_profile_on_battery(.into()),
"Throttle policy on abttery set to {}", "Throttle policy on abttery set to {}",
"Setting Throttle policy on battery failed" "Setting Throttle policy on battery failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as bool), SystemPageData(as bool),
platform.change_throttle_policy_on_battery(.into()), platform_copy.change_platform_profile_on_battery(.into()),
"Throttle policy on battery enabled: {}", "Throttle policy on battery enabled: {}",
"Setting Throttle policy on AC failed" "Setting Throttle policy on AC failed"
); );
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_pl1_spl(as u8),
"ppt_pl1_spl successfully set to {}",
"Setting ppt_pl1_spl failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_pl2_sppt(as u8),
"ppt_pl2_sppt successfully set to {}",
"Setting ppt_pl2_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_fppt(as u8),
"ppt_fppt successfully set to {}",
"Setting ppt_fppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_apu_sppt(as u8),
"ppt_apu_sppt successfully set to {}",
"Setting ppt_apu_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_platform_sppt(as u8),
"ppt_platform_sppt successfully set to {}",
"Setting ppt_platform_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.nv_temp_target(as u8),
"nv_temp_target successfully set to {}",
"Setting nv_temp_target failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.nv_dynamic_boost(as u8),
"nv_dynamic_boost successfully set to {}",
"Setting nv_dynamic_boost failed"
);
}) })
.unwrap(); .ok();
let armoury_attrs;
if let Ok(attrs) = find_iface_async::<AsusArmouryProxy>("xyz.ljones.AsusArmoury").await {
armoury_attrs = attrs;
handle
.upgrade_in_event_loop(|ui| {
ui.global::<SystemPageData>().set_asus_armoury_loaded(true)
})
.ok();
} else {
error!(
"The kernel module asus-armoury is required, if you do not have this you will \
need to either build or install a kernel which includes the patchwork. This \
driver is in process of being upstreamed"
);
return;
}
for attr in armoury_attrs {
if let Ok(value) = attr.current_value().await {
let name = attr.name().await.unwrap();
let platform = platform.clone();
handle
.upgrade_in_event_loop(move |handle| match name {
FirmwareAttribute::ApuMem => {}
FirmwareAttribute::CoresPerformance => {}
FirmwareAttribute::CoresEfficiency => {}
FirmwareAttribute::PptEnabled => {
init_property!(ppt_enabled, handle, value, bool);
setup_callback!(ppt_enabled, handle, attr, bool);
let handle_copy = handle.as_weak();
let proxy_copy = attr.clone();
tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await;
use futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
handle_copy
.upgrade_in_event_loop(move |handle| {
handle
.global::<SystemPageData>()
.set_enable_ppt_group(out == 1);
handle
.global::<SystemPageData>()
.set_ppt_enabled(out == 1);
})
.ok();
}
}
});
handle
.global::<SystemPageData>()
.set_ppt_enabled_available(true);
handle
.global::<SystemPageData>()
.set_enable_ppt_group(value == 1);
}
FirmwareAttribute::PptPl1Spl => {
init_minmax_property!(ppt_pl1_spl, handle, attr);
setup_callback!(ppt_pl1_spl, handle, attr, i32);
setup_callback_restore_default!(ppt_pl1_spl, handle, attr);
setup_minmax_external!(ppt_pl1_spl, handle, attr, platform);
}
FirmwareAttribute::PptPl2Sppt => {
init_minmax_property!(ppt_pl2_sppt, handle, attr);
setup_callback!(ppt_pl2_sppt, handle, attr, i32);
setup_callback_restore_default!(ppt_pl2_sppt, handle, attr);
setup_minmax_external!(ppt_pl2_sppt, handle, attr, platform);
}
FirmwareAttribute::PptPl3Fppt => {
init_minmax_property!(ppt_pl3_fppt, handle, attr);
setup_callback!(ppt_pl3_fppt, handle, attr, i32);
setup_callback_restore_default!(ppt_pl3_fppt, handle, attr);
setup_minmax_external!(ppt_pl3_fppt, handle, attr, platform);
}
FirmwareAttribute::PptFppt => {
init_minmax_property!(ppt_fppt, handle, attr);
setup_callback!(ppt_fppt, handle, attr, i32);
setup_callback_restore_default!(ppt_fppt, handle, attr);
setup_minmax_external!(ppt_fppt, handle, attr, platform);
}
FirmwareAttribute::PptApuSppt => {
init_minmax_property!(ppt_apu_sppt, handle, attr);
setup_callback!(ppt_apu_sppt, handle, attr, i32);
setup_callback_restore_default!(ppt_apu_sppt, handle, attr);
setup_minmax_external!(ppt_apu_sppt, handle, attr, platform);
}
FirmwareAttribute::PptPlatformSppt => {
init_minmax_property!(ppt_platform_sppt, handle, attr);
setup_callback!(ppt_platform_sppt, handle, attr, i32);
setup_callback_restore_default!(ppt_platform_sppt, handle, attr);
setup_minmax_external!(ppt_platform_sppt, handle, attr, platform);
}
FirmwareAttribute::NvDynamicBoost => {
init_minmax_property!(nv_dynamic_boost, handle, attr);
setup_callback!(nv_dynamic_boost, handle, attr, i32);
setup_callback_restore_default!(nv_dynamic_boost, handle, attr);
setup_minmax_external!(nv_dynamic_boost, handle, attr, platform);
}
FirmwareAttribute::NvTempTarget => {
init_minmax_property!(nv_temp_target, handle, attr);
setup_callback!(nv_temp_target, handle, attr, i32);
setup_callback_restore_default!(nv_temp_target, handle, attr);
setup_minmax_external!(nv_temp_target, handle, attr, platform);
}
FirmwareAttribute::DgpuBaseTgp => {}
FirmwareAttribute::DgpuTgp => {}
FirmwareAttribute::ChargeMode => {}
FirmwareAttribute::BootSound => {
init_property!(boot_sound, handle, value, i32);
setup_callback!(boot_sound, handle, attr, i32);
setup_external!(boot_sound, i32, handle, attr, value)
}
FirmwareAttribute::McuPowersave => {}
FirmwareAttribute::PanelOverdrive => {
init_property!(panel_overdrive, handle, value, i32);
setup_callback!(panel_overdrive, handle, attr, i32);
setup_external!(panel_overdrive, i32, handle, attr, value)
}
FirmwareAttribute::PanelHdMode => {}
FirmwareAttribute::EgpuConnected => {}
FirmwareAttribute::EgpuEnable => {}
FirmwareAttribute::DgpuDisable => {}
FirmwareAttribute::GpuMuxMode => {}
FirmwareAttribute::MiniLedMode => {
init_property!(mini_led_mode, handle, value, i32);
setup_callback!(mini_led_mode, handle, attr, i32);
setup_external!(mini_led_mode, i32, handle, attr, value);
}
FirmwareAttribute::PendingReboot => {}
FirmwareAttribute::None => {}
})
.ok();
}
}
}); });
} }
-68
View File
@@ -1,68 +0,0 @@
use std::sync::{Arc, Mutex};
use zbus::zvariant::{OwnedValue, Type, Value};
use zbus::{interface, proxy};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Type, Value, OwnedValue)]
#[zvariant(signature = "u")]
pub enum AppState {
MainWindowOpen = 0,
/// If the app is running, open the main window
MainWindowShouldOpen = 1,
MainWindowClosed = 2,
StartingUp = 3,
QuitApp = 4,
LockFailed = 5,
}
pub struct ROGCCZbus {
state: Arc<Mutex<AppState>>,
}
impl ROGCCZbus {
pub fn new() -> Self {
Self {
state: Arc::new(Mutex::new(AppState::StartingUp)),
}
}
pub fn clone_state(&self) -> Arc<Mutex<AppState>> {
self.state.clone()
}
}
pub const ZBUS_PATH: &str = "/xyz/ljones/rogcc";
pub const ZBUS_IFACE: &str = "xyz.ljones.rogcc";
#[interface(name = "xyz.ljones.rogcc")]
impl ROGCCZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
async fn state(&self) -> AppState {
if let Ok(lock) = self.state.try_lock() {
return *lock;
}
AppState::LockFailed
}
#[zbus(property)]
async fn set_state(&self, state: AppState) {
if let Ok(mut lock) = self.state.try_lock() {
*lock = state;
}
}
}
#[proxy(
interface = "xyz.ljones.rogcc",
default_service = "xyz.ljones.rogcc",
default_path = "/xyz/ljones/rogcc"
)]
pub trait ROGCCZbus {
/// EnableDisplay property
#[zbus(property)]
fn state(&self) -> zbus::Result<AppState>;
#[zbus(property)]
fn set_state(&self, state: AppState) -> zbus::Result<()>;
}
+150
View File
@@ -0,0 +1,150 @@
use std::sync::{Arc, Mutex};
use zbus::blocking::proxy::ProxyImpl;
use zbus::blocking::{fdo, Connection};
use zbus::zvariant::{OwnedValue, Type, Value};
use zbus::{interface, proxy};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Type, Value, OwnedValue)]
#[zvariant(signature = "u")]
pub enum AppState {
MainWindowOpen = 0,
/// If the app is running, open the main window
MainWindowShouldOpen = 1,
MainWindowClosed = 2,
StartingUp = 3,
QuitApp = 4,
LockFailed = 5,
}
pub struct ROGCCZbus {
state: Arc<Mutex<AppState>>,
}
impl ROGCCZbus {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self {
state: Arc::new(Mutex::new(AppState::StartingUp)),
}
}
pub fn clone_state(&self) -> Arc<Mutex<AppState>> {
self.state.clone()
}
}
pub const ZBUS_PATH: &str = "/xyz/ljones/rogcc";
pub const ZBUS_IFACE: &str = "xyz.ljones.rogcc";
#[interface(name = "xyz.ljones.rogcc")]
impl ROGCCZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
async fn state(&self) -> AppState {
if let Ok(lock) = self.state.try_lock() {
return *lock;
}
AppState::LockFailed
}
#[zbus(property)]
async fn set_state(&self, state: AppState) {
if let Ok(mut lock) = self.state.try_lock() {
*lock = state;
}
}
}
#[proxy(
interface = "xyz.ljones.rogcc",
default_service = "xyz.ljones.rogcc",
default_path = "/xyz/ljones/rogcc"
)]
pub trait ROGCCZbus {
/// EnableDisplay property
#[zbus(property)]
fn state(&self) -> zbus::Result<AppState>;
#[zbus(property)]
fn set_state(&self, state: AppState) -> zbus::Result<()>;
}
pub fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>,
{
let conn = Connection::system().unwrap();
let f = fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
let interfaces = f.get_managed_objects().unwrap();
let mut 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() == iface_name {
// println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone());
}
}
}
if paths.len() > 1 {
println!("Multiple asusd interfaces devices found");
}
if !paths.is_empty() {
let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(b));
for path in paths {
ctrl.push(
T::builder(&conn)
.path(path.clone())?
.destination("xyz.ljones.Asusd")?
.build()?,
);
}
return Ok(ctrl);
}
Err("No Aura interface".into())
}
pub async fn find_iface_async<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where
T: zbus::proxy::ProxyImpl<'static> + From<zbus::Proxy<'static>>,
{
let conn = zbus::Connection::system().await.unwrap();
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/")
.await
.unwrap();
let interfaces = f.get_managed_objects().await.unwrap();
let mut 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() == iface_name {
// println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone());
}
}
}
if paths.len() > 1 {
println!("Multiple asusd interfaces devices found");
}
if !paths.is_empty() {
let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(b));
for path in paths {
ctrl.push(
T::builder(&conn)
.path(path.clone())?
.destination("xyz.ljones.Asusd")?
.build()
.await?,
);
}
return Ok(ctrl);
}
Err("No interface".into())
}
@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-12-24 22:29+0000\n" "POT-Creation-Date: 2025-02-14 09:21+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -12,157 +12,238 @@ msgstr ""
"Language: \n" "Language: \n"
"Plural-Forms: nplurals=1; plural=0;\n" "Plural-Forms: nplurals=1; plural=0;\n"
#: rog-control-center/ui/pages/system.slint:26 #: rog-control-center/ui/pages/system.slint:20
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Balanced" msgid "Balanced"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:26 rog-control-center/ui/pages/system.slint:30 #: rog-control-center/ui/pages/system.slint:20 rog-control-center/ui/pages/system.slint:24
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Performance" msgid "Performance"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:26 #: rog-control-center/ui/pages/system.slint:20
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Quiet" msgid "Quiet"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:29 #: rog-control-center/ui/pages/system.slint:23
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Default" msgid "Default"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:31 #: rog-control-center/ui/pages/system.slint:25
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "BalancePerformance" msgid "BalancePerformance"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:32 #: rog-control-center/ui/pages/system.slint:26
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "BalancePower" msgid "BalancePower"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:33 #: rog-control-center/ui/pages/system.slint:27
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Power" msgid "Power"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:110 #: rog-control-center/ui/pages/system.slint:147
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Base system settings" msgid "Power settings"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:115 #: rog-control-center/ui/pages/system.slint:152
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Charge limit" msgid "Charge limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:127 #: rog-control-center/ui/pages/system.slint:167
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy" msgid "Platform Profile"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:137 #: rog-control-center/ui/pages/system.slint:177
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Advanced" msgid "Advanced"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:149 #: rog-control-center/ui/pages/system.slint:195
msgctxt "PageSystem"
msgid "Armoury settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:205
msgctxt "no_asus_armoury_driver_1"
msgid "The asus-armoury driver is not loaded"
msgstr ""
#: rog-control-center/ui/pages/system.slint:211
msgctxt "no_asus_armoury_driver_2"
msgid "For advanced features you will require a kernel with this driver added."
msgstr ""
#: rog-control-center/ui/pages/system.slint:222
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Panel Overdrive" msgid "Panel Overdrive"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:157 #: rog-control-center/ui/pages/system.slint:230
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "MiniLED Mode" msgid "MiniLED Mode"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:165 #: rog-control-center/ui/pages/system.slint:238
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "POST boot sound" msgid "POST boot sound"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:183 #: rog-control-center/ui/pages/system.slint:254
msgctxt "PageSystem" msgctxt "ppt_warning"
msgid "System performance settings" msgid "The following settings are not applied until the toggle is enabled."
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:188 #: rog-control-center/ui/pages/system.slint:259 rog-control-center/ui/pages/system.slint:266
msgctxt "ppt_group_enabled"
msgid "Enable Tuning"
msgstr ""
#: rog-control-center/ui/pages/system.slint:277 rog-control-center/ui/pages/system.slint:278
msgctxt "ppt_pl1_spl" msgctxt "ppt_pl1_spl"
msgid "PL1, sustained power limit" msgid "CPU Sustained Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:198 #: rog-control-center/ui/pages/system.slint:279
msgctxt "ppt_pl1_spl_help"
msgid ""
"Long-term CPU power limit that affects sustained workload performance. "
"Higher values may increase heat and power consumption."
msgstr ""
#: rog-control-center/ui/pages/system.slint:295 rog-control-center/ui/pages/system.slint:296
msgctxt "ppt_pl2_sppt" msgctxt "ppt_pl2_sppt"
msgid "PL2, turbo power limit" msgid "CPU Turbo Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:208 #: rog-control-center/ui/pages/system.slint:297
msgctxt "ppt_pl2_sppt_help"
msgid ""
"Short-term CPU power limit for boost periods. Controls maximum power during "
"brief high-performance bursts."
msgstr ""
#: rog-control-center/ui/pages/system.slint:313 rog-control-center/ui/pages/system.slint:314
msgctxt "ppt_pl3_fppt"
msgid "CPU Fast Burst Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:315
msgctxt "ppt_pl3_fppt_help"
msgid ""
"Ultra-short duration power limit for instantaneous CPU bursts. Affects "
"responsiveness during sudden workload spikes."
msgstr ""
#: rog-control-center/ui/pages/system.slint:330 rog-control-center/ui/pages/system.slint:331
msgctxt "ppt_fppt" msgctxt "ppt_fppt"
msgid "FPPT, Fast Power Limit" msgid "Fast Package Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:218 #: rog-control-center/ui/pages/system.slint:332
msgctxt "ppt_fppt_help"
msgid ""
"Ultra-short duration power limit for system package. Controls maximum power "
"during millisecond-scale load spikes."
msgstr ""
#: rog-control-center/ui/pages/system.slint:348 rog-control-center/ui/pages/system.slint:349
msgctxt "ppt_apu_sppt" msgctxt "ppt_apu_sppt"
msgid "SPPT, APU slow power limit" msgid "APU Sustained Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:228 #: rog-control-center/ui/pages/system.slint:350
msgctxt "ppt_apu_sppt_help"
msgid ""
"Long-term power limit for integrated graphics and CPU combined. Affects "
"sustained performance of APU-based workloads."
msgstr ""
#: rog-control-center/ui/pages/system.slint:366 rog-control-center/ui/pages/system.slint:367
msgctxt "ppt_platform_sppt" msgctxt "ppt_platform_sppt"
msgid "Slow package power tracking limit" msgid "Platform Sustained Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:238 #: rog-control-center/ui/pages/system.slint:368
msgctxt "ppt_platform_sppt_help"
msgid ""
"Overall system power limit for sustained operations. Controls total platform "
"power consumption over extended periods."
msgstr ""
#: rog-control-center/ui/pages/system.slint:384 rog-control-center/ui/pages/system.slint:385
msgctxt "nv_dynamic_boost" msgctxt "nv_dynamic_boost"
msgid "dGPU boost overclock" msgid "GPU Power Boost"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:248 #: rog-control-center/ui/pages/system.slint:386
msgctxt "nv_dynamic_boost_help"
msgid ""
"Additional power allocation for GPU dynamic boost. Higher values increase "
"GPU performance but generate more heat."
msgstr ""
#: rog-control-center/ui/pages/system.slint:402 rog-control-center/ui/pages/system.slint:403
msgctxt "nv_temp_target" msgctxt "nv_temp_target"
msgid "dGPU temperature max" msgid "GPU Temperature Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:294 #: rog-control-center/ui/pages/system.slint:404
msgctxt "nv_temp_target_help"
msgid ""
"Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain "
"temperature below this limit."
msgstr ""
#: rog-control-center/ui/pages/system.slint:456
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Energy Performance Preference linked to Throttle Policy" msgid "Energy Performance Preference linked to Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:298 #: rog-control-center/ui/pages/system.slint:460
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Change EPP based on Throttle Policy" msgid "Change EPP based on Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:306 #: rog-control-center/ui/pages/system.slint:468
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Balanced Policy" msgid "EPP for Balanced Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:316 #: rog-control-center/ui/pages/system.slint:478
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Performance Policy" msgid "EPP for Performance Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:326 #: rog-control-center/ui/pages/system.slint:488
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Quiet Policy" msgid "EPP for Quiet Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:344 #: rog-control-center/ui/pages/system.slint:506
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy for power state" msgid "Throttle Policy for power state"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:350 #: rog-control-center/ui/pages/system.slint:512
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy on Battery" msgid "Throttle Policy on Battery"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:360 rog-control-center/ui/pages/system.slint:381 #: rog-control-center/ui/pages/system.slint:522 rog-control-center/ui/pages/system.slint:543
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Enabled" msgid "Enabled"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:371 #: rog-control-center/ui/pages/system.slint:533
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy on AC" msgid "Throttle Policy on AC"
msgstr "" msgstr ""
@@ -647,42 +728,47 @@ msgctxt "AuraPowerGroupOld"
msgid "Sleep" msgid "Sleep"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:51 #: rog-control-center/ui/widgets/common.slint:136
msgctxt "confirm_reset"
msgid "Are you sure you want to reset this?"
msgstr ""
#: rog-control-center/ui/main_window.slint:55
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "ROG" msgid "ROG"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:53 #: rog-control-center/ui/main_window.slint:57
msgctxt "Menu1" msgctxt "Menu1"
msgid "System Control" msgid "System Control"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:54 #: rog-control-center/ui/main_window.slint:58
msgctxt "Menu2" msgctxt "Menu2"
msgid "Keyboard Aura" msgid "Keyboard Aura"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:55 #: rog-control-center/ui/main_window.slint:59
msgctxt "Menu3" msgctxt "Menu3"
msgid "AniMe Matrix" msgid "AniMe Matrix"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:56 #: rog-control-center/ui/main_window.slint:60
msgctxt "Menu4" msgctxt "Menu4"
msgid "Fan Curves" msgid "Fan Curves"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:57 #: rog-control-center/ui/main_window.slint:61
msgctxt "Menu5" msgctxt "Menu5"
msgid "App Settings" msgid "App Settings"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:58 #: rog-control-center/ui/main_window.slint:62
msgctxt "Menu6" msgctxt "Menu6"
msgid "About" msgid "About"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:70 #: rog-control-center/ui/main_window.slint:74
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "Quit App" msgid "Quit App"
msgstr "" msgstr ""
+21 -16
View File
@@ -1,6 +1,6 @@
import { Palette, Button, VerticalBox } from "std-widgets.slint"; import { Palette, Button, VerticalBox } from "std-widgets.slint";
import { AppSize } from "globals.slint"; import { AppSize } from "globals.slint";
import { PageSystem, AvailableSystemProperties, SystemPageData } from "pages/system.slint"; import { PageSystem, SystemPageData, AttrMinMax } from "pages/system.slint";
import { SideBar } from "widgets/sidebar.slint"; import { SideBar } from "widgets/sidebar.slint";
import { PageAbout } from "pages/about.slint"; import { PageAbout } from "pages/about.slint";
import { PageFans } from "pages/fans.slint"; import { PageFans } from "pages/fans.slint";
@@ -15,14 +15,18 @@ import { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones,
export { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect } export { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect }
import { PageAppSettings, AppSettingsPageData } from "pages/app_settings.slint"; import { PageAppSettings, AppSettingsPageData } from "pages/app_settings.slint";
export { AppSize, AvailableSystemProperties, SystemPageData, AnimePageData, AppSettingsPageData } export { AppSize, AttrMinMax, SystemPageData, AnimePageData, AppSettingsPageData }
export component MainWindow inherits Window { export component MainWindow inherits Window {
title: "ROG Control"; title: "ROG Control";
default-font-family: "DejaVu Sans"; always-on-top: true;
default-font-family: "Noto Sans";
default-font-size: 14px;
default-font-weight: 400;
icon: @image-url("../data/rog-control-center.png");
in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true]; in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true];
private property <bool> show-notif; private property <bool> show_notif;
private property <bool> fade-cover; private property <bool> fade_cover;
private property <bool> toast: false; private property <bool> toast: false;
private property <string> toast_text: "I show when something is waiting"; private property <string> toast_text: "I show when something is waiting";
callback show_toast(string); callback show_toast(string);
@@ -31,10 +35,10 @@ export component MainWindow inherits Window {
toast_text = text; toast_text = text;
} }
callback exit-app(); callback exit-app();
callback show-notification(bool); callback show_notification(bool);
show-notification(yes) => { show_notification(yes) => {
show-notif = yes; show_notif = yes;
fade-cover = yes; fade_cover = yes;
} }
callback external_colour_change(); callback external_colour_change();
external_colour_change() => { external_colour_change() => {
@@ -109,7 +113,7 @@ export component MainWindow inherits Window {
} }
} }
if fade-cover: Rectangle { if fade_cover: Rectangle {
x: 0px; x: 0px;
y: 0px; y: 0px;
width: root.width; width: root.width;
@@ -121,10 +125,10 @@ export component MainWindow inherits Window {
width: 100%; width: 100%;
clicked => { clicked => {
// toolbar-dropdown.close(); // toolbar-dropdown.close();
if (show-notif) { if (show_notif) {
show-notif = false; show_notif = false;
} }
fade-cover = false; fade_cover = false;
} }
} }
} }
@@ -134,7 +138,8 @@ export component MainWindow inherits Window {
y: 0px; y: 0px;
width: root.width; width: root.width;
height: 32px; height: 32px;
opacity: 0.8; opacity: 1.0;
background: Colors.grey;
TouchArea { TouchArea {
height: 100%; height: 100%;
width: 100%; width: 100%;
@@ -155,7 +160,7 @@ export component MainWindow inherits Window {
} }
// // TODO: or use Dialogue // // TODO: or use Dialogue
if show-notif: Rectangle { if show_notif: Rectangle {
x: root.width / 8; x: root.width / 8;
y: root.height / 8; y: root.height / 8;
height: (root.height / 8) * 6; height: (root.height / 8) * 6;
@@ -164,7 +169,7 @@ export component MainWindow inherits Window {
height: 100%; height: 100%;
width: 100%; width: 100%;
clicked => { clicked => {
show-notif = false; show_notif = false;
exit-app(); exit-app();
} }
} }
+8 -16
View File
@@ -17,7 +17,7 @@ export component PageAbout inherits VerticalLayout {
Text { Text {
wrap: TextWrap.word-wrap; wrap: TextWrap.word-wrap;
text: "You will require these patches: https://lore.kernel.org/platform-driver-x86/20240404001652.86207-1-luke@ljones.dev/, they have been merged upstream for kernel 6.10. The main thing is that the PPT settings will apply without them, but the read/back will fail"; text: "You will require a kernel built with my work from here: https://github.com/flukejones/linux";
} }
Text { Text {
@@ -28,19 +28,7 @@ export component PageAbout inherits VerticalLayout {
} }
Text { Text {
text: "- [x] Theme the widgets"; text: "- [ ] Theme the widgets";
}
Text {
text: "- [x] Add a fullscreen mode (cli arg)";
}
Text {
text: "- [x] Disable aura items depending if mode supports or not";
}
Text {
text: "- [x] Add fan curve graph controls";
} }
Text { Text {
@@ -48,11 +36,15 @@ export component PageAbout inherits VerticalLayout {
} }
Text { Text {
text: "- [ ] Supergfx control"; text: "- [ ] Include fan speeds, temps in a bottom bar";
} }
Text { Text {
text: "- [ ] Include fan speeds, temps in a bottom bar"; text: "- [ ] Slash control";
}
Text {
text: "- [ ] Supergfx control";
} }
Text { Text {
+17 -17
View File
@@ -9,17 +9,17 @@ export global AnimePageData {
@tr("Anime Brightness" => "High"), @tr("Anime Brightness" => "High"),
]; ];
in-out property <int> brightness; in-out property <int> brightness;
callback set_brightness(int); callback cb_brightness(int);
in-out property <bool> builtins_enabled; in-out property <bool> builtins_enabled;
callback set_builtins_enabled(bool); callback cb_builtins_enabled(bool);
in-out property <bool> enable_display; in-out property <bool> enable_display;
callback set_enable_display(bool); callback cb_enable_display(bool);
in-out property <bool> off_when_lid_closed; in-out property <bool> off_when_lid_closed;
callback set_off_when_lid_closed(bool); callback cb_off_when_lid_closed(bool);
in-out property <bool> off_when_suspended; in-out property <bool> off_when_suspended;
callback set_off_when_suspended(bool); callback cb_off_when_suspended(bool);
in-out property <bool> off_when_unplugged; in-out property <bool> off_when_unplugged;
callback set_off_when_unplugged(bool); callback cb_off_when_unplugged(bool);
in-out property <[string]> boot_anim_choices: [@tr("Glitch Construction"), @tr("Static Emergence")]; in-out property <[string]> boot_anim_choices: [@tr("Glitch Construction"), @tr("Static Emergence")];
in property <int> boot_anim: 0; in property <int> boot_anim: 0;
in-out property <[string]> awake_anim_choices: [@tr("Binary Banner Scroll"), @tr("Rog Logo Glitch")]; in-out property <[string]> awake_anim_choices: [@tr("Binary Banner Scroll"), @tr("Rog Logo Glitch")];
@@ -28,7 +28,7 @@ export global AnimePageData {
in property <int> sleep_anim: 0; in property <int> sleep_anim: 0;
in-out property <[string]> shutdown_anim_choices: [@tr("Glitch Out"), @tr("See Ya")]; in-out property <[string]> shutdown_anim_choices: [@tr("Glitch Out"), @tr("See Ya")];
in property <int> shutdown_anim: 0; in property <int> shutdown_anim: 0;
callback set_builtin_animations(int, int, int, int); callback cb_builtin_animations(int, int, int, int);
} }
export component PageAnime inherits Rectangle { export component PageAnime inherits Rectangle {
@@ -53,7 +53,7 @@ export component PageAnime inherits Rectangle {
model <=> AnimePageData.brightness_names; model <=> AnimePageData.brightness_names;
selected => { selected => {
self.current_value = AnimePageData.brightness_names[AnimePageData.brightness]; self.current_value = AnimePageData.brightness_names[AnimePageData.brightness];
AnimePageData.set_brightness(AnimePageData.brightness) AnimePageData.cb_brightness(AnimePageData.brightness)
} }
} }
} }
@@ -66,7 +66,7 @@ export component PageAnime inherits Rectangle {
text: @tr("Enable display"); text: @tr("Enable display");
checked <=> AnimePageData.enable_display; checked <=> AnimePageData.enable_display;
toggled => { toggled => {
AnimePageData.set_enable_display(AnimePageData.enable_display) AnimePageData.cb_enable_display(AnimePageData.enable_display)
} }
} }
@@ -89,7 +89,7 @@ export component PageAnime inherits Rectangle {
text: @tr("Use built-in animations"); text: @tr("Use built-in animations");
checked <=> AnimePageData.builtins_enabled; checked <=> AnimePageData.builtins_enabled;
toggled => { toggled => {
AnimePageData.set_builtins_enabled(AnimePageData.builtins_enabled) AnimePageData.cb_builtins_enabled(AnimePageData.builtins_enabled)
} }
} }
@@ -152,7 +152,7 @@ export component PageAnime inherits Rectangle {
current_value: AnimePageData.boot_anim_choices[AnimePageData.boot_anim]; current_value: AnimePageData.boot_anim_choices[AnimePageData.boot_anim];
model <=> AnimePageData.boot_anim_choices; model <=> AnimePageData.boot_anim_choices;
selected => { selected => {
AnimePageData.set_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim) AnimePageData.cb_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim)
} }
} }
@@ -162,7 +162,7 @@ export component PageAnime inherits Rectangle {
current_value: AnimePageData.awake_anim_choices[AnimePageData.awake_anim]; current_value: AnimePageData.awake_anim_choices[AnimePageData.awake_anim];
model <=> AnimePageData.awake_anim_choices; model <=> AnimePageData.awake_anim_choices;
selected => { selected => {
AnimePageData.set_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim) AnimePageData.cb_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim)
} }
} }
@@ -172,7 +172,7 @@ export component PageAnime inherits Rectangle {
current_value: AnimePageData.sleep_anim_choices[AnimePageData.sleep_anim]; current_value: AnimePageData.sleep_anim_choices[AnimePageData.sleep_anim];
model <=> AnimePageData.sleep_anim_choices; model <=> AnimePageData.sleep_anim_choices;
selected => { selected => {
AnimePageData.set_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim) AnimePageData.cb_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim)
} }
} }
@@ -182,7 +182,7 @@ export component PageAnime inherits Rectangle {
current_value: AnimePageData.shutdown_anim_choices[AnimePageData.shutdown_anim]; current_value: AnimePageData.shutdown_anim_choices[AnimePageData.shutdown_anim];
model <=> AnimePageData.shutdown_anim_choices; model <=> AnimePageData.shutdown_anim_choices;
selected => { selected => {
AnimePageData.set_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim) AnimePageData.cb_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim)
} }
} }
} }
@@ -225,7 +225,7 @@ export component PageAnime inherits Rectangle {
text: @tr("Off when lid closed"); text: @tr("Off when lid closed");
checked <=> AnimePageData.off_when_lid_closed; checked <=> AnimePageData.off_when_lid_closed;
toggled => { toggled => {
AnimePageData.set_off_when_lid_closed(AnimePageData.off_when_lid_closed) AnimePageData.cb_off_when_lid_closed(AnimePageData.off_when_lid_closed)
} }
} }
@@ -234,7 +234,7 @@ export component PageAnime inherits Rectangle {
text: @tr("Off when suspended"); text: @tr("Off when suspended");
checked <=> AnimePageData.off_when_suspended; checked <=> AnimePageData.off_when_suspended;
toggled => { toggled => {
AnimePageData.set_off_when_suspended(AnimePageData.off_when_suspended) AnimePageData.cb_off_when_suspended(AnimePageData.off_when_suspended)
} }
} }
@@ -243,7 +243,7 @@ export component PageAnime inherits Rectangle {
text: @tr("Off when on battery"); text: @tr("Off when on battery");
checked <=> AnimePageData.off_when_unplugged; checked <=> AnimePageData.off_when_unplugged;
toggled => { toggled => {
AnimePageData.set_off_when_unplugged(AnimePageData.off_when_unplugged) AnimePageData.cb_off_when_unplugged(AnimePageData.off_when_unplugged)
} }
} }
} }
+19 -19
View File
@@ -30,7 +30,7 @@ export component PageAura inherits Rectangle {
current_value: AuraPageData.brightness_names[self.current-index]; current_value: AuraPageData.brightness_names[self.current-index];
model <=> AuraPageData.brightness_names; model <=> AuraPageData.brightness_names;
selected => { selected => {
AuraPageData.set_brightness(AuraPageData.brightness) AuraPageData.cb_brightness(AuraPageData.brightness)
} }
} }
@@ -44,7 +44,7 @@ export component PageAura inherits Rectangle {
AuraPageData.led_mode_data.mode = AuraPageData.led_mode; AuraPageData.led_mode_data.mode = AuraPageData.led_mode;
AuraPageData.led_mode_data.mode = AuraPageData.current_available_mode; AuraPageData.led_mode_data.mode = AuraPageData.current_available_mode;
self.current_value = AuraPageData.available_mode_names[self.current-index]; self.current_value = AuraPageData.available_mode_names[self.current-index];
AuraPageData.set_led_mode(AuraPageData.current_available_mode); AuraPageData.cb_led_mode(AuraPageData.current_available_mode);
} }
} }
} }
@@ -67,14 +67,14 @@ export component PageAura inherits Rectangle {
final_colour <=> AuraPageData.color1; final_colour <=> AuraPageData.color1;
colourbox <=> AuraPageData.colorbox1; colourbox <=> AuraPageData.colorbox1;
set_hex_from_colour(c1) => { set_hex_from_colour(c1) => {
return AuraPageData.set_hex_from_colour(c1); return AuraPageData.cb_hex_from_colour(c1);
} }
hex_to_colour(s) => { hex_to_colour(s) => {
return AuraPageData.set_hex_to_colour(s); return AuraPageData.cb_hex_to_colour(s);
} }
released => { released => {
AuraPageData.led_mode_data.colour1 = AuraPageData.color1; AuraPageData.led_mode_data.colour1 = AuraPageData.color1;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data); AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -93,14 +93,14 @@ export component PageAura inherits Rectangle {
final_colour <=> AuraPageData.color2; final_colour <=> AuraPageData.color2;
colourbox <=> AuraPageData.colorbox2; colourbox <=> AuraPageData.colorbox2;
set_hex_from_colour(c1) => { set_hex_from_colour(c1) => {
return AuraPageData.set_hex_from_colour(c1); return AuraPageData.cb_hex_from_colour(c1);
} }
hex_to_colour(s) => { hex_to_colour(s) => {
return AuraPageData.set_hex_to_colour(s); return AuraPageData.cb_hex_to_colour(s);
} }
released => { released => {
AuraPageData.led_mode_data.colour2 = AuraPageData.color2; AuraPageData.led_mode_data.colour2 = AuraPageData.color2;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data); AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -129,7 +129,7 @@ export component PageAura inherits Rectangle {
model <=> AuraPageData.zone_names; model <=> AuraPageData.zone_names;
selected => { selected => {
AuraPageData.led_mode_data.zone = self.current-index; AuraPageData.led_mode_data.zone = self.current-index;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data); AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -151,7 +151,7 @@ export component PageAura inherits Rectangle {
model <=> AuraPageData.direction_names; model <=> AuraPageData.direction_names;
selected => { selected => {
AuraPageData.led_mode_data.direction = self.current-index; AuraPageData.led_mode_data.direction = self.current-index;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data); AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -173,7 +173,7 @@ export component PageAura inherits Rectangle {
model <=> AuraPageData.speed_names; model <=> AuraPageData.speed_names;
selected => { selected => {
AuraPageData.led_mode_data.speed = self.current-index; AuraPageData.led_mode_data.speed = self.current-index;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data); AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -218,22 +218,22 @@ export component PageAura inherits Rectangle {
boot_checked: state.boot; boot_checked: state.boot;
boot_toggled => { boot_toggled => {
AuraPageData.led_power.states[idx].boot = zone.boot_checked; AuraPageData.led_power.states[idx].boot = zone.boot_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
awake_checked: state.awake; awake_checked: state.awake;
awake_toggled => { awake_toggled => {
AuraPageData.led_power.states[idx].awake = zone.awake_checked; AuraPageData.led_power.states[idx].awake = zone.awake_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
sleep_checked: state.sleep; sleep_checked: state.sleep;
sleep_toggled => { sleep_toggled => {
AuraPageData.led_power.states[idx].sleep = zone.sleep_checked; AuraPageData.led_power.states[idx].sleep = zone.sleep_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
shutdown_checked: state.shutdown; shutdown_checked: state.shutdown;
shutdown_toggled => { shutdown_toggled => {
AuraPageData.led_power.states[idx].shutdown = zone.shutdown_checked; AuraPageData.led_power.states[idx].shutdown = zone.shutdown_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
} }
} }
@@ -271,22 +271,22 @@ export component PageAura inherits Rectangle {
zone_strings <=> AuraPageData.power_zone_names_old; zone_strings <=> AuraPageData.power_zone_names_old;
selected_zone => { selected_zone => {
AuraPageData.led_power.states[idx].zone = AuraPageData.supported_power_zones[old_zone.current_zone]; AuraPageData.led_power.states[idx].zone = AuraPageData.supported_power_zones[old_zone.current_zone];
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
boot_checked: state.boot; boot_checked: state.boot;
boot_toggled => { boot_toggled => {
AuraPageData.led_power.states[idx].boot = old_zone.boot_checked; AuraPageData.led_power.states[idx].boot = old_zone.boot_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
awake_checked: state.awake; awake_checked: state.awake;
awake_toggled => { awake_toggled => {
AuraPageData.led_power.states[idx].awake = old_zone.awake_checked; AuraPageData.led_power.states[idx].awake = old_zone.awake_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
sleep_checked: state.sleep; sleep_checked: state.sleep;
sleep_toggled => { sleep_toggled => {
AuraPageData.led_power.states[idx].sleep = old_zone.sleep_checked; AuraPageData.led_power.states[idx].sleep = old_zone.sleep_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
} }
} }
+342 -180
View File
@@ -1,30 +1,24 @@
import { SystemSlider, SystemDropdown, SystemToggle } from "../widgets/common.slint"; import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint";
import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox} from "std-widgets.slint"; import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox, StandardButton} from "std-widgets.slint";
export struct AvailableSystemProperties { export struct AttrMinMax {
charge_control_end_threshold: bool, min: int,
panel_od: bool, max: int,
boot_sound: bool, current: float,
mini_led_mode: bool, }
disable_nvidia_powerd_on_battery: bool,
ac_command: bool, export struct AttrPossible {
bat_command: bool, range: [int],
throttle_thermal_policy: bool, current: int,
ppt_pl1_spl: bool,
ppt_pl2_sppt: bool,
ppt_fppt: bool,
ppt_apu_sppt: bool,
ppt_platform_sppt: bool,
nv_dynamic_boost: bool,
nv_temp_target: bool,
} }
export global SystemPageData { export global SystemPageData {
in-out property <bool> charge_control_enabled: true;
in-out property <float> charge_control_end_threshold: 30; in-out property <float> charge_control_end_threshold: 30;
callback set_charge_control_end_threshold(/* charge limit */ int); callback cb_charge_control_end_threshold(/* charge limit */ int);
in-out property <int> throttle_thermal_policy: 0; in-out property <int> platform_profile: 0;
in-out property <[string]> throttle_policy_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")]; in-out property <[string]> platform_profile_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")];
callback set_throttle_thermal_policy(int); callback cb_platform_profile(int);
in-out property <[string]> energy_performance_choices: [ in-out property <[string]> energy_performance_choices: [
@tr("Default"), @tr("Default"),
@tr("Performance"), @tr("Performance"),
@@ -32,60 +26,102 @@ export global SystemPageData {
@tr("BalancePower"), @tr("BalancePower"),
@tr("Power") @tr("Power")
]; ];
in-out property <int> throttle_balanced_epp: 0; in-out property <int> profile_balanced_epp: 0;
callback set_throttle_balanced_epp(int); callback cb_profile_balanced_epp(int);
in-out property <int> throttle_performance_epp: 0; in-out property <int> profile_performance_epp: 0;
callback set_throttle_performance_epp(int); callback cb_profile_performance_epp(int);
in-out property <int> throttle_quiet_epp: 0; in-out property <int> profile_quiet_epp: 0;
callback set_throttle_quiet_epp(int); callback cb_profile_quiet_epp(int);
// if the EPP should change with throttle // if the EPP should change with throttle
in-out property <bool> throttle_policy_linked_epp: true; in-out property <bool> platform_profile_linked_epp: true;
callback set_throttle_policy_linked_epp(bool); callback cb_platform_profile_linked_epp(bool);
in-out property <int> throttle_policy_on_ac: 0; in-out property <int> platform_profile_on_ac: 0;
callback set_throttle_policy_on_ac(int); callback cb_platform_profile_on_ac(int);
in-out property <bool> change_throttle_policy_on_ac: true; in-out property <bool> change_platform_profile_on_ac: true;
callback set_change_throttle_policy_on_ac(bool); callback cb_change_platform_profile_on_ac(bool);
in-out property <int> throttle_policy_on_battery: 0; in-out property <int> platform_profile_on_battery: 0;
callback set_throttle_policy_on_battery(int); callback cb_platform_profile_on_battery(int);
in-out property <bool> change_throttle_policy_on_battery: true; in-out property <bool> change_platform_profile_on_battery: true;
callback set_change_throttle_policy_on_battery(bool); callback cb_change_platform_profile_on_battery(bool);
in-out property <bool> panel_od; //
callback set_panel_od(bool); in-out property <int> panel_overdrive;
in-out property <bool> boot_sound; callback cb_panel_overdrive(int);
callback set_boot_sound(bool); in-out property <int> boot_sound;
in-out property <bool> mini_led_mode; callback cb_boot_sound(int);
callback set_mini_led_mode(bool); in-out property <int> mini_led_mode;
in-out property <float> ppt_pl1_spl: 5; callback cb_mini_led_mode(int);
callback set_ppt_pl1_spl(int); in-out property <bool> asus_armoury_loaded: false;
in-out property <float> ppt_pl2_sppt: 5;
callback set_ppt_pl2_sppt(int); in-out property <AttrMinMax> ppt_pl1_spl: {
in-out property <float> ppt_fppt: 5; min: 0,
callback set_ppt_fppt(int); max: 100,
in-out property <float> ppt_apu_sppt: 5; current: 20,
callback set_ppt_apu_sppt(int);
in-out property <float> ppt_platform_sppt: 5;
callback set_ppt_platform_sppt(int);
in-out property <float> nv_dynamic_boost: 5;
callback set_nv_dynamic_boost(int);
in-out property <float> nv_temp_target: 75;
callback set_nv_temp_target(int);
in-out property <AvailableSystemProperties> available: {
charge_control_end_threshold: true,
panel_od: true,
boot_sound: true,
mini_led_mode: true,
disable_nvidia_powerd_on_battery: true,
ac_command: true,
bat_command: true,
throttle_thermal_policy: true,
ppt_pl1_spl: true,
ppt_pl2_sppt: true,
ppt_fppt: true,
ppt_apu_sppt: true,
ppt_platform_sppt: true,
nv_dynamic_boost: true,
nv_temp_target: true,
}; };
callback cb_ppt_pl1_spl(int);
callback cb_default_ppt_pl1_spl();
in-out property <AttrMinMax> ppt_pl2_sppt: {
min: 0,
max: 100,
current: 20,
};
callback cb_ppt_pl2_sppt(int);
callback cb_default_ppt_pl2_sppt();
in-out property <AttrMinMax> ppt_pl3_fppt: {
min: 0,
max: 100,
current: 20,
};
callback cb_ppt_pl3_fppt(int);
callback cb_default_ppt_pl3_fppt();
in-out property <AttrMinMax> ppt_fppt: {
min: 0,
max: 100,
current: 20,
};
callback cb_ppt_fppt(int);
callback cb_default_ppt_fppt();
in-out property <AttrMinMax> ppt_apu_sppt: {
min: 0,
max: 100,
current: 20,
};
callback cb_ppt_apu_sppt(int);
callback cb_default_ppt_apu_sppt();
in-out property <AttrMinMax> ppt_platform_sppt: {
min: 0,
max: 100,
current: 20,
};
callback cb_ppt_platform_sppt(int);
callback cb_default_ppt_platform_sppt();
in-out property <AttrMinMax> nv_dynamic_boost: {
min: 0,
max: 30,
current: 5,
};
callback cb_nv_dynamic_boost(int);
callback cb_default_nv_dynamic_boost();
in-out property <AttrMinMax> nv_temp_target: {
min: 0,
max: 80,
current: 75,
};
callback cb_nv_temp_target(int);
callback cb_default_nv_temp_target();
in-out property <bool> enable_ppt_group: false;
callback cb_enable_ppt_group(bool);
in-out property <bool> ppt_enabled_available;
in-out property <bool> ppt_enabled;
callback cb_ppt_enabled(bool);
} }
export component PageSystem inherits Rectangle { export component PageSystem inherits Rectangle {
@@ -97,6 +133,7 @@ export component PageSystem inherits Rectangle {
VerticalLayout { VerticalLayout {
padding: 10px; padding: 10px;
spacing: 10px; spacing: 10px;
alignment: LayoutAlignment.start;
Rectangle { Rectangle {
background: Palette.alternate-background; background: Palette.alternate-background;
border-color: Palette.accent-background; border-color: Palette.accent-background;
@@ -107,29 +144,32 @@ export component PageSystem inherits Rectangle {
font-size: 18px; font-size: 18px;
color: Palette.control-foreground; color: Palette.control-foreground;
horizontal-alignment: TextHorizontalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center;
text: @tr("Base system settings"); text: @tr("Power settings");
} }
} }
if SystemPageData.available.charge-control-end-threshold: SystemSlider { if SystemPageData.charge_control_end_threshold != -1: SystemSlider {
text: @tr("Charge limit"); text: @tr("Charge limit");
minimum: 20; minimum: 20;
maximum: 100; maximum: 100;
value <=> SystemPageData.charge_control_end_threshold; has_reset: false;
enabled <=> SystemPageData.charge_control_enabled;
value: SystemPageData.charge_control_end_threshold;
released => { released => {
SystemPageData.set_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold)) SystemPageData.charge_control_end_threshold = self.value;
SystemPageData.cb_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold))
} }
} }
if SystemPageData.available.throttle-thermal-policy: HorizontalLayout { if SystemPageData.platform_profile != -1: HorizontalLayout {
spacing: 10px; spacing: 10px;
SystemDropdown { SystemDropdown {
text: @tr("Throttle Policy"); text: @tr("Platform Profile");
current_index <=> SystemPageData.throttle_thermal_policy; current_index <=> SystemPageData.platform_profile;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy]; current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.platform_profile_choices;
selected => { selected => {
SystemPageData.set_throttle_thermal_policy(SystemPageData.throttle_thermal_policy) SystemPageData.cb_platform_profile(SystemPageData.platform_profile)
} }
} }
@@ -142,34 +182,6 @@ export component PageSystem inherits Rectangle {
} }
} }
HorizontalBox {
padding: 0px;
spacing: 10px;
if SystemPageData.available.panel-od: SystemToggle {
text: @tr("Panel Overdrive");
checked <=> SystemPageData.panel_od;
toggled => {
SystemPageData.set_panel_od(SystemPageData.panel_od)
}
}
if SystemPageData.available.mini-led-mode: SystemToggle {
text: @tr("MiniLED Mode");
checked <=> SystemPageData.mini_led_mode;
toggled => {
SystemPageData.set_mini_led_mode(SystemPageData.mini_led_mode)
}
}
if SystemPageData.available.boot-sound: SystemToggle {
text: @tr("POST boot sound");
checked <=> SystemPageData.boot_sound;
toggled => {
SystemPageData.set_boot_sound(SystemPageData.boot_sound)
}
}
}
Rectangle { Rectangle {
background: Palette.alternate-background; background: Palette.alternate-background;
border-color: Palette.accent-background; border-color: Palette.accent-background;
@@ -180,77 +192,227 @@ export component PageSystem inherits Rectangle {
font-size: 18px; font-size: 18px;
color: Palette.control-foreground; color: Palette.control-foreground;
horizontal-alignment: TextHorizontalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center;
text: @tr("System performance settings"); text: @tr("Armoury settings");
} }
} }
if SystemPageData.available.ppt-pl1-spl: SystemSlider { if !SystemPageData.asus_armoury_loaded: Rectangle {
text: @tr("ppt_pl1_spl" => "PL1, sustained power limit"); border-width: 3px;
minimum: 5; border-color: red;
maximum: 250; max-height: 30px;
value <=> SystemPageData.ppt_pl1_spl; VerticalBox {
released => { Text {
SystemPageData.set_ppt_pl1_spl(Math.round(SystemPageData.ppt_pl1_spl)) text: @tr("no_asus_armoury_driver_1" => "The asus-armoury driver is not loaded");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
Text {
text: @tr("no_asus_armoury_driver_2" => "For advanced features you will require a kernel with this driver added.");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
} }
} }
if SystemPageData.available.ppt-pl2-sppt: SystemSlider { HorizontalBox {
text: @tr("ppt_pl2_sppt" => "PL2, turbo power limit"); padding: 0px;
minimum: 5; spacing: 10px;
maximum: 250; if SystemPageData.panel_overdrive != -1: SystemToggleInt {
value <=> SystemPageData.ppt_pl2_sppt; text: @tr("Panel Overdrive");
released => { checked_int <=> SystemPageData.panel_overdrive;
SystemPageData.set_ppt_pl2_sppt(Math.round(SystemPageData.ppt_pl2_sppt)) toggled => {
SystemPageData.cb_panel_overdrive(SystemPageData.panel_overdrive)
}
}
if SystemPageData.mini_led_mode != -1: SystemToggleInt {
text: @tr("MiniLED Mode");
checked_int <=> SystemPageData.mini_led_mode;
toggled => {
SystemPageData.cb_mini_led_mode(SystemPageData.mini_led_mode)
}
}
if SystemPageData.boot_sound != -1: SystemToggleInt {
text: @tr("POST boot sound");
checked_int <=> SystemPageData.boot_sound;
toggled => {
SystemPageData.cb_boot_sound(SystemPageData.boot_sound)
}
} }
} }
if SystemPageData.available.ppt-fppt: SystemSlider { if SystemPageData.ppt_pl1_spl.current != -1 || SystemPageData.ppt_pl2_sppt.current != -1 || SystemPageData.nv_dynamic_boost.current != -1: HorizontalLayout {
text: @tr("ppt_fppt" => "FPPT, Fast Power Limit"); padding-right: 10px;
minimum: 5; padding-left: 10px;
maximum: 250; alignment: LayoutAlignment.space-between;
value <=> SystemPageData.ppt_fppt; Rectangle {
height: 32px;
Text {
font-size: 16px;
text: @tr("ppt_warning" => "The following settings are not applied until the toggle is enabled.");
}
}
if !SystemPageData.ppt_enabled_available: Switch {
text: @tr("ppt_group_enabled" => "Enable Tuning");
checked <=> SystemPageData.enable_ppt_group;
toggled => {
SystemPageData.cb_enable_ppt_group(SystemPageData.enable_ppt_group)
}
}
if SystemPageData.ppt_enabled_available: Switch {
text: @tr("ppt_group_enabled" => "Enable Tuning");
checked <=> SystemPageData.ppt_enabled;
toggled => {
SystemPageData.enable_ppt_group = self.checked;
SystemPageData.cb_ppt_enabled(SystemPageData.ppt_enabled)
}
}
}
if SystemPageData.ppt_pl1_spl.current != -1: SystemSlider {
text: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit");
title: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit");
help_text: @tr("ppt_pl1_spl_help" => "Long-term CPU power limit that affects sustained workload performance. Higher values may increase heat and power consumption.");
minimum: SystemPageData.ppt_pl1_spl.min;
maximum: SystemPageData.ppt_pl1_spl.max;
value: SystemPageData.ppt_pl1_spl.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl1_spl();
}
released => { released => {
SystemPageData.set_ppt_fppt(Math.round(SystemPageData.ppt_fppt)) SystemPageData.ppt_pl1_spl.current = self.value;
SystemPageData.cb_ppt_pl1_spl(Math.round(self.value));
} }
} }
if SystemPageData.available.ppt-apu-sppt: SystemSlider { if SystemPageData.ppt_pl2_sppt.current != -1: SystemSlider {
text: @tr("ppt_apu_sppt" => "SPPT, APU slow power limit"); text: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit");
minimum: 5; title: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit");
maximum: 130; help_text: @tr("ppt_pl2_sppt_help" => "Short-term CPU power limit for boost periods. Controls maximum power during brief high-performance bursts.");
value <=> SystemPageData.ppt_apu_sppt; minimum: SystemPageData.ppt_pl2_sppt.min;
maximum: SystemPageData.ppt_pl2_sppt.max;
value: SystemPageData.ppt_pl2_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl2_sppt();
}
released => { released => {
SystemPageData.set_ppt_apu_sppt(Math.round(SystemPageData.ppt_apu_sppt)) SystemPageData.ppt_pl2_sppt.current = self.value;
SystemPageData.cb_ppt_pl2_sppt(Math.round(self.value))
} }
} }
if SystemPageData.available.ppt-platform-sppt: SystemSlider { if SystemPageData.ppt_pl3_fppt.current != -1: SystemSlider {
text: @tr("ppt_platform_sppt" => "Slow package power tracking limit"); text: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit");
maximum: 130; title: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit");
minimum: 5; help_text: @tr("ppt_pl3_fppt_help" => "Ultra-short duration power limit for instantaneous CPU bursts. Affects responsiveness during sudden workload spikes.");
value <=> SystemPageData.ppt_platform_sppt; minimum: SystemPageData.ppt_pl3_fppt.min;
maximum: SystemPageData.ppt_pl3_fppt.max;
value: SystemPageData.ppt_pl3_fppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl3_fppt();
}
released => { released => {
SystemPageData.set_ppt_platform_sppt(Math.round(SystemPageData.ppt_platform_sppt)) SystemPageData.ppt_pl3_fppt.current = self.value;
SystemPageData.cb_ppt_pl3_fppt(Math.round(self.value))
}
}
if SystemPageData.ppt_fppt.current != -1: SystemSlider {
text: @tr("ppt_fppt" => "Fast Package Power Limit");
title: @tr("ppt_fppt" => "Fast Package Power Limit");
help_text: @tr("ppt_fppt_help" => "Ultra-short duration power limit for system package. Controls maximum power during millisecond-scale load spikes.");
minimum: SystemPageData.ppt_fppt.min;
maximum: SystemPageData.ppt_fppt.max;
value: SystemPageData.ppt_fppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_fppt();
}
released => {
SystemPageData.ppt_fppt.current = self.value;
SystemPageData.cb_ppt_fppt(Math.round(self.value))
} }
} }
if SystemPageData.available.nv-dynamic-boost: SystemSlider { if SystemPageData.ppt_apu_sppt.current != -1: SystemSlider {
text: @tr("nv_dynamic_boost" => "dGPU boost overclock"); text: @tr("ppt_apu_sppt" => "APU Sustained Power Limit");
minimum: 5; title: @tr("ppt_apu_sppt" => "APU Sustained Power Limit");
maximum: 25; help_text: @tr("ppt_apu_sppt_help" => "Long-term power limit for integrated graphics and CPU combined. Affects sustained performance of APU-based workloads.");
value <=> SystemPageData.nv_dynamic_boost; minimum: SystemPageData.ppt_apu_sppt.min;
maximum: SystemPageData.ppt_apu_sppt.max;
value: SystemPageData.ppt_apu_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_apu_sppt();
}
released => { released => {
SystemPageData.set_nv_dynamic_boost(Math.round(SystemPageData.nv_dynamic_boost)) SystemPageData.ppt_apu_sppt.current = self.value;
SystemPageData.cb_ppt_apu_sppt(Math.round(self.value))
} }
} }
if SystemPageData.available.nv-temp-target: SystemSlider { if SystemPageData.ppt_platform_sppt.current != -1: SystemSlider {
text: @tr("nv_temp_target" => "dGPU temperature max"); text: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit");
minimum: 75; title: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit");
maximum: 87; help_text: @tr("ppt_platform_sppt_help" => "Overall system power limit for sustained operations. Controls total platform power consumption over extended periods.");
value <=> SystemPageData.nv_temp_target; minimum: SystemPageData.ppt_platform_sppt.min;
maximum: SystemPageData.ppt_platform_sppt.max;
value: SystemPageData.ppt_platform_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_platform_sppt();
}
released => { released => {
SystemPageData.set_nv_temp_target(Math.round(SystemPageData.nv_temp_target)) SystemPageData.ppt_platform_sppt.current = self.value;
SystemPageData.cb_ppt_platform_sppt(Math.round(self.value))
}
}
if SystemPageData.nv_dynamic_boost.current != -1: SystemSlider {
text: @tr("nv_dynamic_boost" => "GPU Power Boost");
title: @tr("nv_dynamic_boost" => "GPU Power Boost");
help_text: @tr("nv_dynamic_boost_help" => "Additional power allocation for GPU dynamic boost. Higher values increase GPU performance but generate more heat.");
minimum: SystemPageData.nv_dynamic_boost.min;
maximum: SystemPageData.nv_dynamic_boost.max;
value: SystemPageData.nv_dynamic_boost.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_nv_dynamic_boost();
}
released => {
SystemPageData.nv_dynamic_boost.current = self.value;
SystemPageData.cb_nv_dynamic_boost(Math.round(self.value))
}
}
if SystemPageData.nv_temp_target.current != -1: SystemSlider {
text: @tr("nv_temp_target" => "GPU Temperature Limit");
title: @tr("nv_temp_target" => "GPU Temperature Limit");
help_text: @tr("nv_temp_target_help" => "Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain temperature below this limit.");
minimum: SystemPageData.nv_temp_target.min;
maximum: SystemPageData.nv_temp_target.max;
value: SystemPageData.nv_temp_target.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_nv_temp_target();
}
released => {
SystemPageData.nv_temp_target.current = self.value;
SystemPageData.cb_nv_temp_target(Math.round(self.value))
} }
} }
} }
@@ -296,39 +458,39 @@ export component PageSystem inherits Rectangle {
SystemToggle { SystemToggle {
text: @tr("Change EPP based on Throttle Policy"); text: @tr("Change EPP based on Throttle Policy");
checked <=> SystemPageData.throttle_policy_linked_epp; checked <=> SystemPageData.platform_profile_linked_epp;
toggled => { toggled => {
SystemPageData.set_throttle_policy_linked_epp(SystemPageData.throttle_policy_linked_epp) SystemPageData.cb_platform_profile_linked_epp(SystemPageData.platform_profile_linked_epp)
} }
} }
SystemDropdown { SystemDropdown {
text: @tr("EPP for Balanced Policy"); text: @tr("EPP for Balanced Policy");
current_index <=> SystemPageData.throttle_balanced_epp; current_index <=> SystemPageData.profile_balanced_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_balanced_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_balanced_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.set_throttle_balanced_epp(SystemPageData.throttle_balanced_epp) SystemPageData.cb_profile_balanced_epp(SystemPageData.profile_balanced_epp)
} }
} }
SystemDropdown { SystemDropdown {
text: @tr("EPP for Performance Policy"); text: @tr("EPP for Performance Policy");
current_index <=> SystemPageData.throttle_performance_epp; current_index <=> SystemPageData.profile_performance_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_performance_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_performance_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.set_throttle_performance_epp(SystemPageData.throttle_performance_epp) SystemPageData.cb_profile_performance_epp(SystemPageData.profile_performance_epp)
} }
} }
SystemDropdown { SystemDropdown {
text: @tr("EPP for Quiet Policy"); text: @tr("EPP for Quiet Policy");
current_index <=> SystemPageData.throttle_quiet_epp; current_index <=> SystemPageData.profile_quiet_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_quiet_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_quiet_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.set_throttle_quiet_epp(SystemPageData.throttle_quiet_epp) SystemPageData.cb_profile_quiet_epp(SystemPageData.profile_quiet_epp)
} }
} }
} }
@@ -348,19 +510,19 @@ export component PageSystem inherits Rectangle {
spacing: 10px; spacing: 10px;
SystemDropdown { SystemDropdown {
text: @tr("Throttle Policy on Battery"); text: @tr("Throttle Policy on Battery");
current_index <=> SystemPageData.throttle_policy_on_battery; current_index <=> SystemPageData.platform_profile_on_battery;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_battery]; current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile_on_battery];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.platform_profile_choices;
selected => { selected => {
SystemPageData.set_throttle_policy_on_battery(SystemPageData.throttle_policy_on_battery) SystemPageData.cb_platform_profile_on_battery(SystemPageData.platform_profile_on_battery)
} }
} }
SystemToggle { SystemToggle {
text: @tr("Enabled"); text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_battery; checked <=> SystemPageData.change_platform_profile_on_battery;
toggled => { toggled => {
SystemPageData.set_change_throttle_policy_on_battery(SystemPageData.change_throttle_policy_on_battery); SystemPageData.cb_change_platform_profile_on_battery(SystemPageData.change_platform_profile_on_battery);
} }
} }
} }
@@ -369,19 +531,19 @@ export component PageSystem inherits Rectangle {
spacing: 10px; spacing: 10px;
SystemDropdown { SystemDropdown {
text: @tr("Throttle Policy on AC"); text: @tr("Throttle Policy on AC");
current_index <=> SystemPageData.throttle_policy_on_ac; current_index <=> SystemPageData.platform_profile_on_ac;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_ac]; current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile_on_ac];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.platform_profile_choices;
selected => { selected => {
SystemPageData.set_throttle_policy_on_ac(SystemPageData.throttle_policy_on_ac) SystemPageData.cb_platform_profile_on_ac(SystemPageData.platform_profile_on_ac)
} }
} }
SystemToggle { SystemToggle {
text: @tr("Enabled"); text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_ac; checked <=> SystemPageData.change_platform_profile_on_ac;
toggled => { toggled => {
SystemPageData.set_change_throttle_policy_on_ac(SystemPageData.change_throttle_policy_on_ac); SystemPageData.cb_change_platform_profile_on_ac(SystemPageData.change_platform_profile_on_ac);
} }
} }
} }
+6 -6
View File
@@ -71,7 +71,7 @@ export global AuraPageData {
@tr("Aura brightness" => "High"), @tr("Aura brightness" => "High"),
]; ];
in-out property <int> brightness; in-out property <int> brightness;
callback set_brightness(int); callback cb_brightness(int);
in-out property <[string]> mode_names: [ in-out property <[string]> mode_names: [
@tr("Basic aura mode" => "Static"), @tr("Basic aura mode" => "Static"),
@tr("Basic aura mode" => "Breathe"), @tr("Basic aura mode" => "Breathe"),
@@ -95,7 +95,7 @@ export global AuraPageData {
in-out property <int> current_available_mode: 0; in-out property <int> current_available_mode: 0;
in-out property <[int]> supported_basic_modes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12]; in-out property <[int]> supported_basic_modes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12];
in-out property <int> led_mode; in-out property <int> led_mode;
callback set_led_mode(int); callback cb_led_mode(int);
in-out property <[string]> zone_names: [ in-out property <[string]> zone_names: [
@tr("Aura zone" => "None"), @tr("Aura zone" => "None"),
@tr("Aura zone" => "Key1"), @tr("Aura zone" => "Key1"),
@@ -130,7 +130,7 @@ export global AuraPageData {
speed: 0, speed: 0,
direction: 0, direction: 0,
}; };
callback set_led_mode_data(AuraEffect); callback cb_led_mode_data(AuraEffect);
in-out property <color> color1; in-out property <color> color1;
in-out property <brush> colorbox1; in-out property <brush> colorbox1;
in-out property <color> color2; in-out property <color> color2;
@@ -147,8 +147,8 @@ export global AuraPageData {
colorbox1 = data.colour1; colorbox1 = data.colour1;
colorbox2 = data.colour2; colorbox2 = data.colour2;
} }
callback set_hex_from_colour(color) -> string; callback cb_hex_from_colour(color) -> string;
callback set_hex_to_colour(string) -> color; callback cb_hex_to_colour(string) -> color;
in-out property <AuraDevType> device_type: AuraDevType.Old; in-out property <AuraDevType> device_type: AuraDevType.Old;
// List of indexes to power_zone_names. Must correspond to rog-aura crate // List of indexes to power_zone_names. Must correspond to rog-aura crate
in-out property <[PowerZones]> supported_power_zones: [ in-out property <[PowerZones]> supported_power_zones: [
@@ -165,5 +165,5 @@ export global AuraPageData {
shutdown: true, shutdown: true,
}] }]
}; };
callback set_led_power(LaptopAuraPower); callback cb_led_power(LaptopAuraPower);
} }
@@ -4,6 +4,7 @@ export enum Profile {
Balanced, Balanced,
Performance, Performance,
Quiet, Quiet,
LowPower,
} }
export enum FanType { export enum FanType {
+158 -14
View File
@@ -10,35 +10,56 @@ export component RogItem inherits Rectangle {
} }
export component SystemSlider inherits RogItem { export component SystemSlider inherits RogItem {
in property <string> title;
in property <string> text; in property <string> text;
in-out property <bool> enabled: true;
in-out property <float> value; in-out property <float> value;
in-out property <float> minimum; in-out property <float> minimum;
in-out property <float> maximum; in-out property <float> maximum;
callback released(int); callback released(int);
in-out property <string> help_text;
in-out property <bool> has_reset: false;
callback cb_do_reset();
HorizontalLayout { HorizontalLayout {
HorizontalLayout { HorizontalLayout {
width: 50%; width: 40%;
alignment: LayoutAlignment.space-between; alignment: LayoutAlignment.stretch;
padding-left: 10px; padding-left: 10px;
Text { TouchArea {
font-size: 16px; enabled <=> root.enabled;
vertical-alignment: TextVerticalAlignment.center; clicked => {
color: Palette.control-foreground; slider.value += 1;
text <=> root.text; if slider.value > slider.maximum {
} slider.value = slider.minimum;
}
}
HorizontalLayout {
spacing: 6px;
Text {
font-size: 16px;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
Text { Text {
font-size: 16px; font-size: 16px;
vertical-alignment: TextVerticalAlignment.center; horizontal-alignment: TextHorizontalAlignment.right;
color: Palette.control-foreground; vertical-alignment: TextVerticalAlignment.center;
text: "\{Math.round(root.value)}"; color: Palette.control-foreground;
text: "\{Math.round(root.value)}";
}
}
} }
} }
HorizontalBox { HorizontalBox {
// alignment: LayoutAlignment.end; // alignment: LayoutAlignment.end;
padding-right: 20px; padding-right: 20px;
Slider { slider := Slider {
enabled <=> root.enabled;
maximum: root.maximum; maximum: root.maximum;
minimum: root.minimum; minimum: root.minimum;
value <=> root.value; value <=> root.value;
@@ -47,6 +68,97 @@ export component SystemSlider inherits RogItem {
} }
} }
} }
help_popup := PopupWindow {
x: help.x - self.width + help.width - 10px;
y: help.y - self.height + help.height - 10px;
Rectangle {
drop-shadow-blur: 10px;
drop-shadow-color: black;
border-radius: 10px;
border-color: Palette.accent-background;
background: Palette.background;
Dialog {
title <=> root.title;
VerticalBox {
Text {
max-width: 420px;
font-size: 18px;
wrap: TextWrap.word-wrap;
horizontal-alignment: TextHorizontalAlignment.center;
text <=> root.title;
}
Rectangle {
height: 1px;
border-color: black;
border-width: 1px;
}
Text {
max-width: 420px;
font-size: 16px;
wrap: TextWrap.word-wrap;
text <=> root.help_text;
}
}
StandardButton {
kind: ok;
}
}
}
}
help := HorizontalBox {
if (help_text != ""): StandardButton {
kind: StandardButtonKind.help;
clicked => {
help_popup.show();
}
}
}
reset_popup := PopupWindow {
x: reset.x - self.width + reset.width;
y: reset.y - self.height + reset.height;
Rectangle {
drop-shadow-blur: 10px;
drop-shadow-color: black;
border-radius: 10px;
border-color: Palette.accent-background;
background: Palette.background;
Dialog {
Text {
max-width: 420px;
font-size: 16px;
wrap: TextWrap.word-wrap;
text: @tr("confirm_reset" => "Are you sure you want to reset this?");
}
StandardButton {
kind: ok;
clicked => {
root.cb_do_reset();
}
}
StandardButton {
kind: cancel;
}
}
}
}
reset := HorizontalBox {
if (has_reset): StandardButton {
kind: StandardButtonKind.reset;
enabled <=> root.enabled;
clicked => {
reset_popup.show();
}
}
}
} }
} }
@@ -80,6 +192,38 @@ export component SystemToggle inherits RogItem {
} }
} }
export component SystemToggleInt inherits RogItem {
in property <string> text;
// in-out property <bool> checked;
in-out property <int> checked_int;
callback toggled(int);
HorizontalLayout {
spacing: 6px;
HorizontalLayout {
alignment: LayoutAlignment.start;
padding-left: 10px;
Text {
font-size: 16px;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
}
HorizontalLayout {
alignment: LayoutAlignment.end;
padding-right: 20px;
Switch {
checked: root.checked_int != 0;
toggled => {
root.checked_int = self.checked ? 1 : 0;
root.toggled(root.checked_int);
}
}
}
}
}
export component SystemToggleVert inherits RogItem { export component SystemToggleVert inherits RogItem {
in property <string> text; in property <string> text;
in-out property <bool> checked; in-out property <bool> checked;
@@ -42,6 +42,7 @@ component SideBarItem inherits Rectangle {
label := Text { label := Text {
color: Palette.foreground; color: Palette.foreground;
vertical-alignment: center; vertical-alignment: center;
font-size: 14px;
} }
} }
+53
View File
@@ -0,0 +1,53 @@
//! # D-Bus interface proxy for: `xyz.ljones.AsusArmoury`
//!
//! `zbus-xmlgen system xyz.ljones.Asusd
//! /xyz/ljones/asus_armoury/nv_temp_target`
use rog_platform::asus_armoury::FirmwareAttribute;
use zbus::proxy;
#[proxy(
interface = "xyz.ljones.AsusArmoury",
default_service = "xyz.ljones.Asusd",
default_path = "/xyz/ljones/asus_armoury/nv_temp_target"
)]
pub trait AsusArmoury {
/// A list of the properties this attribute actually uses. Any property
/// not listed will return either an empty array or `-1`
#[zbus(property)]
fn available_attrs(&self) -> zbus::Result<Vec<String>>;
/// CurrentValue property
#[zbus(property)]
fn current_value(&self) -> zbus::Result<i32>;
#[zbus(property)]
fn set_current_value(&self, value: i32) -> zbus::Result<()>;
/// DefaultValue property
#[zbus(property)]
fn default_value(&self) -> zbus::Result<i32>;
/// MaxValue property. Maximum allowed current_value. Returns `-1` if unused
/// or not set.
#[zbus(property)]
fn max_value(&self) -> zbus::Result<i32>;
/// MinValue property. Minimum allowed current_value. Returns `-1` if unused
/// or not set.
#[zbus(property)]
fn min_value(&self) -> zbus::Result<i32>;
/// PossibleValues property. Return the allowed values for `current_value`
/// if used or set, otherwise the array is empty.
#[zbus(property)]
fn possible_values(&self) -> zbus::Result<Vec<i32>>;
/// Name property
#[zbus(property)]
fn name(&self) -> zbus::Result<FirmwareAttribute>;
/// ScalarIncrement property. The increment steps that `current_value` may
/// take. Returns `-1` if not used or set.
#[zbus(property)]
fn scalar_increment(&self) -> zbus::Result<i32>;
async fn restore_default(&self) -> zbus::Result<()>;
}
+44 -3
View File
@@ -1,5 +1,7 @@
pub use asusd::{DBUS_IFACE, DBUS_NAME, DBUS_PATH}; pub use asusd::{DBUS_IFACE, DBUS_NAME, DBUS_PATH};
use zbus::proxy::ProxyImpl;
pub mod asus_armoury;
pub mod scsi_aura; pub mod scsi_aura;
pub mod zbus_anime; pub mod zbus_anime;
pub mod zbus_aura; pub mod zbus_aura;
@@ -11,7 +13,7 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub fn list_iface_blocking() -> Result<Vec<String>, Box<dyn std::error::Error>> { pub fn list_iface_blocking() -> Result<Vec<String>, Box<dyn std::error::Error>> {
let conn = zbus::blocking::Connection::system()?; let conn = zbus::blocking::Connection::system()?;
let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/")?; let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/")?;
let interfaces = f.get_managed_objects()?; let interfaces = f.get_managed_objects()?;
let mut ifaces = Vec::new(); let mut ifaces = Vec::new();
for v in interfaces.iter() { for v in interfaces.iter() {
@@ -24,7 +26,7 @@ pub fn list_iface_blocking() -> Result<Vec<String>, Box<dyn std::error::Error>>
pub fn has_iface_blocking(iface: &str) -> Result<bool, Box<dyn std::error::Error>> { pub fn has_iface_blocking(iface: &str) -> Result<bool, Box<dyn std::error::Error>> {
let conn = zbus::blocking::Connection::system()?; let conn = zbus::blocking::Connection::system()?;
let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/")?; let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/")?;
let interfaces = f.get_managed_objects()?; let interfaces = f.get_managed_objects()?;
for v in interfaces.iter() { for v in interfaces.iter() {
for k in v.1.keys() { for k in v.1.keys() {
@@ -38,7 +40,7 @@ pub fn has_iface_blocking(iface: &str) -> Result<bool, Box<dyn std::error::Error
pub async fn has_iface(iface: &str) -> Result<bool, Box<dyn std::error::Error>> { pub async fn has_iface(iface: &str) -> Result<bool, Box<dyn std::error::Error>> {
let conn = zbus::Connection::system().await?; let conn = zbus::Connection::system().await?;
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").await?; let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").await?;
let interfaces = f.get_managed_objects().await?; let interfaces = f.get_managed_objects().await?;
for v in interfaces.iter() { for v in interfaces.iter() {
for k in v.1.keys() { for k in v.1.keys() {
@@ -49,3 +51,42 @@ pub async fn has_iface(iface: &str) -> Result<bool, Box<dyn std::error::Error>>
} }
Ok(false) Ok(false)
} }
pub async fn find_iface_async<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>,
{
let conn = zbus::Connection::system().await?;
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").await?;
let interfaces = f.get_managed_objects().await?;
let mut 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() == iface_name {
// println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone());
}
}
}
if paths.len() > 1 {
println!("Multiple asusd interfaces devices found");
}
if !paths.is_empty() {
let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(b));
for path in paths {
ctrl.push(
T::builder(&conn)
.path(path.clone())?
.destination("xyz.ljones.Asusd")?
.build()
.await?,
);
}
return Ok(ctrl);
}
Err(format!("Did not find {iface_name}").into())
}
+6 -6
View File
@@ -1,8 +1,8 @@
//! # D-Bus interface proxy for: `org.asuslinux.ScsiAura` //! # D-Bus interface proxy for: `xyz.ljones.ScsiAura`
//! //!
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection //! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection
//! data. Source: `Interface '/org/asuslinux/M3D0AP048745_scsi' from service //! data. Source: `Interface '/xyz/ljones/M3D0AP048745_scsi' from service
//! 'org.asuslinux.Daemon' on system bus`. //! 'xyz.ljones.Asusd' on system bus`.
//! //!
//! You may prefer to adapt it, instead of using it verbatim. //! You may prefer to adapt it, instead of using it verbatim.
//! //!
@@ -23,9 +23,9 @@
use rog_scsi::{AuraEffect, AuraMode}; use rog_scsi::{AuraEffect, AuraMode};
use zbus::proxy; use zbus::proxy;
#[proxy( #[proxy(
interface = "org.asuslinux.ScsiAura", interface = "xyz.ljones.ScsiAura",
default_service = "org.asuslinux.Daemon", default_service = "xyz.ljones.Asusd",
default_path = "/org/asuslinux" default_path = "/xyz/ljones"
)] )]
pub trait ScsiAura { pub trait ScsiAura {
/// AllModeData method /// AllModeData method
+3 -3
View File
@@ -3,9 +3,9 @@ use rog_anime::{Animations, AnimeDataBuffer, DeviceState as AnimeDeviceState};
use zbus::proxy; use zbus::proxy;
#[proxy( #[proxy(
interface = "org.asuslinux.Anime", interface = "xyz.ljones.Anime",
default_service = "org.asuslinux.Daemon", default_service = "xyz.ljones.Asusd",
default_path = "/org/asuslinux" default_path = "/xyz/ljones"
)] )]
pub trait Anime { pub trait Anime {
/// DeviceState method /// DeviceState method
+6 -6
View File
@@ -1,8 +1,8 @@
//! # `DBus` interface proxy for: `org.asuslinux.Daemon` //! # `DBus` interface proxy for: `xyz.ljones.Asusd`
//! //!
//! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection //! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection
//! data. Source: `Interface '/org/asuslinux/Aura' from service //! data. Source: `Interface '/xyz/ljones/Aura' from service
//! 'org.asuslinux.Daemon' on system bus`. //! 'xyz.ljones.Asusd' on system bus`.
//! //!
//! You may prefer to adapt it, instead of using it verbatim. //! You may prefer to adapt it, instead of using it verbatim.
//! //!
@@ -30,9 +30,9 @@ use zbus::{proxy, Result};
const BLOCKING_TIME: u64 = 33; // 100ms = 10 FPS, max 50ms = 20 FPS, 40ms = 25 FPS const BLOCKING_TIME: u64 = 33; // 100ms = 10 FPS, max 50ms = 20 FPS, 40ms = 25 FPS
#[proxy( #[proxy(
interface = "org.asuslinux.Aura", interface = "xyz.ljones.Aura",
default_service = "org.asuslinux.Daemon", default_service = "xyz.ljones.Asusd",
default_path = "/org/asuslinux/Aura" default_path = "/xyz/ljones/Aura"
)] )]
pub trait Aura { pub trait Aura {
/// AllModeData method /// AllModeData method
+13 -13
View File
@@ -1,8 +1,8 @@
//! # `DBus` interface proxy for: `org.asuslinux.Daemon` //! # `DBus` interface proxy for: `xyz.ljones.Asusd`
//! //!
//! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection //! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection
//! data. Source: `Interface '/org/asuslinux/Profile' from service //! data. Source: `Interface '/xyz/ljones/Profile' from service
//! 'org.asuslinux.Daemon' on system bus`. //! 'xyz.ljones.Asusd' on system bus`.
//! //!
//! You may prefer to adapt it, instead of using it verbatim. //! You may prefer to adapt it, instead of using it verbatim.
//! //!
@@ -20,42 +20,42 @@
//! //!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces. //! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
use zbus::proxy; use zbus::proxy;
#[proxy( #[proxy(
interface = "org.asuslinux.FanCurves", interface = "xyz.ljones.FanCurves",
default_service = "org.asuslinux.Daemon", default_service = "xyz.ljones.Asusd",
default_path = "/org/asuslinux" default_path = "/xyz/ljones"
)] )]
pub trait FanCurves { pub trait FanCurves {
/// Get the fan-curve data for the currently active PlatformProfile /// Get the fan-curve data for the currently active PlatformProfile
fn fan_curve_data(&self, profile: ThrottlePolicy) -> zbus::Result<Vec<CurveData>>; fn fan_curve_data(&self, profile: PlatformProfile) -> zbus::Result<Vec<CurveData>>;
/// Reset the stored (self) and device curve to the defaults of the /// Reset the stored (self) and device curve to the defaults of the
/// platform. /// platform.
/// ///
/// Each platform_profile has a different default and the defualt can be /// Each platform_profile has a different default and the defualt can be
/// read only for the currently active profile. /// read only for the currently active profile.
fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::Result<()>; fn reset_profile_curves(&self, profile: PlatformProfile) -> zbus::Result<()>;
/// SetActiveCurveToDefaults method /// SetActiveCurveToDefaults method
fn set_curves_to_defaults(&self, profile: ThrottlePolicy) -> zbus::Result<()>; fn set_curves_to_defaults(&self, profile: PlatformProfile) -> zbus::Result<()>;
/// Set the fan curve for the specified profile, or the profile the user is /// Set the fan curve for the specified profile, or the profile the user is
/// currently in if profile == None. Will also activate the fan curve. /// currently in if profile == None. Will also activate the fan curve.
fn set_fan_curve(&self, profile: ThrottlePolicy, curve: CurveData) -> zbus::Result<()>; fn set_fan_curve(&self, profile: PlatformProfile, curve: CurveData) -> zbus::Result<()>;
/// Set a profile fan curve enabled status. Will also activate a fan curve. /// Set a profile fan curve enabled status. Will also activate a fan curve.
fn set_fan_curves_enabled(&self, profile: ThrottlePolicy, enabled: bool) -> zbus::Result<()>; fn set_fan_curves_enabled(&self, profile: PlatformProfile, enabled: bool) -> zbus::Result<()>;
/// Set a single fan curve for a profile to enabled status. Will also /// Set a single fan curve for a profile to enabled status. Will also
/// activate a fan curve. /// activate a fan curve.
async fn set_profile_fan_curve_enabled( async fn set_profile_fan_curve_enabled(
&self, &self,
profile: ThrottlePolicy, profile: PlatformProfile,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool, enabled: bool,
) -> zbus::Result<()>; ) -> zbus::Result<()>;
+41 -100
View File
@@ -1,8 +1,8 @@
//! # `DBus` interface proxy for: `org.asuslinux.Daemon` //! # `DBus` interface proxy for: `xyz.ljones.Asusd`
//! //!
//! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection //! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection
//! data. Source: `Interface '/org/asuslinux/Platform' from service //! data. Source: `Interface '/xyz/ljones/Platform' from service
//! 'org.asuslinux.Daemon' on system bus`. //! 'xyz.ljones.Asusd' on system bus`.
//! //!
//! You may prefer to adapt it, instead of using it verbatim. //! You may prefer to adapt it, instead of using it verbatim.
//! //!
@@ -21,20 +21,20 @@
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces. //! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use rog_platform::cpu::CPUEPP; use rog_platform::cpu::CPUEPP;
use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy}; use rog_platform::platform::{PlatformProfile, Properties};
use zbus::proxy; use zbus::proxy;
#[proxy( #[proxy(
interface = "org.asuslinux.Platform", interface = "xyz.ljones.Platform",
default_service = "org.asuslinux.Daemon", default_service = "xyz.ljones.Asusd",
default_path = "/org/asuslinux" default_path = "/xyz/ljones"
)] )]
pub trait Platform { pub trait Platform {
#[zbus(property)] #[zbus(property)]
fn version(&self) -> zbus::Result<String>; fn version(&self) -> zbus::Result<String>;
/// NextThrottleThermalPolicy method /// NextThrottleThermalPolicy method
fn next_throttle_thermal_policy(&self) -> zbus::Result<()>; fn next_platform_profile(&self) -> zbus::Result<()>;
/// SupportedProperties method /// SupportedProperties method
fn supported_properties(&self) -> zbus::Result<Vec<Properties>>; fn supported_properties(&self) -> zbus::Result<Vec<Properties>>;
@@ -48,131 +48,72 @@ pub trait Platform {
// Toggle one-shot charge to 100% // Toggle one-shot charge to 100%
fn one_shot_full_charge(&self) -> zbus::Result<()>; fn one_shot_full_charge(&self) -> zbus::Result<()>;
/// DgpuDisable property
#[zbus(property)]
fn dgpu_disable(&self) -> zbus::Result<bool>;
/// EgpuEnable property
#[zbus(property)]
fn egpu_enable(&self) -> zbus::Result<bool>;
/// GpuMuxMode property
#[zbus(property)]
fn gpu_mux_mode(&self) -> zbus::Result<u8>;
#[zbus(property)]
fn set_gpu_mux_mode(&self, value: GpuMode) -> zbus::Result<()>;
/// MiniLedMode property
#[zbus(property)]
fn mini_led_mode(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_mini_led_mode(&self, value: bool) -> zbus::Result<()>;
/// NvDynamicBoost property
#[zbus(property)]
fn nv_dynamic_boost(&self) -> zbus::Result<u8>;
#[zbus(property)]
fn set_nv_dynamic_boost(&self, value: u8) -> zbus::Result<()>;
/// NvTempTarget property
#[zbus(property)]
fn nv_temp_target(&self) -> zbus::Result<u8>;
#[zbus(property)]
fn set_nv_temp_target(&self, value: u8) -> zbus::Result<()>;
/// PanelOd property
#[zbus(property)]
fn panel_od(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_panel_od(&self, value: bool) -> zbus::Result<()>;
/// PostAnimationSound property
#[zbus(property)]
fn boot_sound(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_boot_sound(&self, value: bool) -> zbus::Result<()>;
/// PptApuSppt property
#[zbus(property)]
fn ppt_apu_sppt(&self) -> zbus::Result<u8>;
#[zbus(property)]
fn set_ppt_apu_sppt(&self, value: u8) -> zbus::Result<()>;
/// PptFppt property
#[zbus(property)]
fn ppt_fppt(&self) -> zbus::Result<u8>;
#[zbus(property)]
fn set_ppt_fppt(&self, value: u8) -> zbus::Result<()>;
/// PptPl1Spl property
#[zbus(property)]
fn ppt_pl1_spl(&self) -> zbus::Result<u8>;
#[zbus(property)]
fn set_ppt_pl1_spl(&self, value: u8) -> zbus::Result<()>;
/// PptPl2Sppt property
#[zbus(property)]
fn ppt_pl2_sppt(&self) -> zbus::Result<u8>;
#[zbus(property)]
fn set_ppt_pl2_sppt(&self, value: u8) -> zbus::Result<()>;
/// PptPlatformSppt property
#[zbus(property)]
fn ppt_platform_sppt(&self) -> zbus::Result<u8>;
#[zbus(property)]
fn set_ppt_platform_sppt(&self, value: u8) -> zbus::Result<()>;
/// ThrottleBalancedEpp property /// ThrottleBalancedEpp property
#[zbus(property)] #[zbus(property)]
fn throttle_balanced_epp(&self) -> zbus::Result<CPUEPP>; fn profile_balanced_epp(&self) -> zbus::Result<CPUEPP>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_balanced_epp(&self, epp: CPUEPP) -> zbus::Result<()>; fn set_profile_balanced_epp(&self, epp: CPUEPP) -> zbus::Result<()>;
/// ThrottlePerformanceEpp property /// ThrottlePerformanceEpp property
#[zbus(property)] #[zbus(property)]
fn throttle_performance_epp(&self) -> zbus::Result<CPUEPP>; fn profile_performance_epp(&self) -> zbus::Result<CPUEPP>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_performance_epp(&self, epp: CPUEPP) -> zbus::Result<()>; fn set_profile_performance_epp(&self, epp: CPUEPP) -> zbus::Result<()>;
/// ThrottlePolicyLinkedEpp property /// ThrottlePolicyLinkedEpp property
#[zbus(property)] #[zbus(property)]
fn throttle_policy_linked_epp(&self) -> zbus::Result<bool>; fn platform_profile_linked_epp(&self) -> zbus::Result<bool>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_policy_linked_epp(&self, value: bool) -> zbus::Result<()>; fn set_platform_profile_linked_epp(&self, value: bool) -> zbus::Result<()>;
/// ThrottlePolicyOnAc property /// ThrottlePolicyOnAc property
#[zbus(property)] #[zbus(property)]
fn throttle_policy_on_ac(&self) -> zbus::Result<ThrottlePolicy>; fn platform_profile_on_ac(&self) -> zbus::Result<PlatformProfile>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_policy_on_ac(&self, throttle_policy: ThrottlePolicy) -> zbus::Result<()>; fn set_platform_profile_on_ac(&self, platform_profile: PlatformProfile) -> zbus::Result<()>;
/// ChangeThrottlePolicyOnAc property /// ChangeThrottlePolicyOnAc property
#[zbus(property)] #[zbus(property)]
fn change_throttle_policy_on_ac(&self) -> zbus::Result<bool>; fn change_platform_profile_on_ac(&self) -> zbus::Result<bool>;
#[zbus(property)] #[zbus(property)]
fn set_change_throttle_policy_on_ac(&self, change: bool) -> zbus::Result<()>; fn set_change_platform_profile_on_ac(&self, change: bool) -> zbus::Result<()>;
/// ThrottlePolicyOnBattery property /// ThrottlePolicyOnBattery property
#[zbus(property)] #[zbus(property)]
fn throttle_policy_on_battery(&self) -> zbus::Result<ThrottlePolicy>; fn platform_profile_on_battery(&self) -> zbus::Result<PlatformProfile>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_policy_on_battery(&self, throttle_policy: ThrottlePolicy) -> zbus::Result<()>; fn set_platform_profile_on_battery(
&self,
platform_profile: PlatformProfile,
) -> zbus::Result<()>;
/// ChangeThrottlePolicyOnAc property /// ChangeThrottlePolicyOnAc property
#[zbus(property)] #[zbus(property)]
fn change_throttle_policy_on_battery(&self) -> zbus::Result<bool>; fn change_platform_profile_on_battery(&self) -> zbus::Result<bool>;
#[zbus(property)] #[zbus(property)]
fn set_change_throttle_policy_on_battery(&self, change: bool) -> zbus::Result<()>; fn set_change_platform_profile_on_battery(&self, change: bool) -> zbus::Result<()>;
/// ThrottleQuietEpp property /// ThrottleQuietEpp property
#[zbus(property)] #[zbus(property)]
fn throttle_quiet_epp(&self) -> zbus::Result<CPUEPP>; fn profile_quiet_epp(&self) -> zbus::Result<CPUEPP>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_quiet_epp(&self, epp: CPUEPP) -> zbus::Result<()>; fn set_profile_quiet_epp(&self, epp: CPUEPP) -> zbus::Result<()>;
/// PlatformProfileChoices property
#[zbus(property)]
fn platform_profile_choices(&self) -> zbus::Result<Vec<PlatformProfile>>;
/// ThrottlePolicy property /// ThrottlePolicy property
#[zbus(property)] #[zbus(property)]
fn throttle_thermal_policy(&self) -> zbus::Result<ThrottlePolicy>; fn platform_profile(&self) -> zbus::Result<PlatformProfile>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_thermal_policy(&self, throttle_policy: ThrottlePolicy) -> zbus::Result<()>; fn set_platform_profile(&self, platform_profile: PlatformProfile) -> zbus::Result<()>;
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
fn enable_ppt_group(&self) -> zbus::Result<bool>;
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
fn set_enable_ppt_group(&self, enable: bool) -> zbus::Result<()>;
} }
+35 -5
View File
@@ -2,9 +2,9 @@ use rog_slash::SlashMode;
use zbus::proxy; use zbus::proxy;
#[proxy( #[proxy(
interface = "org.asuslinux.Slash", interface = "xyz.ljones.Slash",
default_service = "org.asuslinux.Daemon", default_service = "xyz.ljones.Asusd",
default_path = "/org/asuslinux" default_path = "/xyz/ljones"
)] )]
pub trait Slash { pub trait Slash {
/// EnableDisplay property /// EnableDisplay property
@@ -27,7 +27,37 @@ pub trait Slash {
/// Slash modes property /// Slash modes property
#[zbus(property)] #[zbus(property)]
fn slash_mode(&self) -> zbus::Result<SlashMode>; fn mode(&self) -> zbus::Result<SlashMode>;
#[zbus(property)] #[zbus(property)]
fn set_slash_mode(&self, value: SlashMode) -> zbus::Result<()>; fn set_mode(&self, value: SlashMode) -> zbus::Result<()>;
/// ShowBatteryWarning property
#[zbus(property)]
fn show_battery_warning(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_show_battery_warning(&self, value: bool) -> zbus::Result<()>;
/// ShowOnBattery property
#[zbus(property)]
fn show_on_battery(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_show_on_battery(&self, value: bool) -> zbus::Result<()>;
/// ShowOnBoot property
#[zbus(property)]
fn show_on_boot(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_show_on_boot(&self, value: bool) -> zbus::Result<()>;
/// ShowOnShutdown property
#[zbus(property)]
fn show_on_shutdown(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_show_on_shutdown(&self, value: bool) -> zbus::Result<()>;
/// ShowOnSleep property
#[zbus(property)]
fn show_on_sleep(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_show_on_sleep(&self, value: bool) -> zbus::Result<()>;
} }
-1
View File
@@ -15,6 +15,5 @@ zbus.workspace = true
concat-idents.workspace = true concat-idents.workspace = true
udev.workspace = true udev.workspace = true
inotify.workspace = true inotify.workspace = true
typeshare.workspace = true
rusb.workspace = true rusb.workspace = true
@@ -23,19 +23,33 @@ pub fn main() -> Result<(), Box<dyn Error>> {
// node.write_bytes(&[0x5a, 0xd1, 0x0a, 0x01])?; // TODO: need to CHECK // node.write_bytes(&[0x5a, 0xd1, 0x0a, 0x01])?; // TODO: need to CHECK
println!("Set mouse mode for 10 seconds"); println!("Set mouse mode for 10 seconds");
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x03])?; node.write_bytes(&[
node.write_bytes(&[0x5a, 0xd1, 0x0f, 0x20])?; 0x5a, 0xd1, 0x01, 0x01, 0x03,
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x00])?; ])?;
node.write_bytes(&[
0x5a, 0xd1, 0x0f, 0x20,
])?;
node.write_bytes(&[
0x5a, 0xd1, 0x01, 0x01, 0x00,
])?;
sleep(Duration::from_secs(10)); sleep(Duration::from_secs(10));
println!("Set wasd mode for 10 seconds"); println!("Set wasd mode for 10 seconds");
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x02])?; node.write_bytes(&[
node.write_bytes(&[0x5a, 0xd1, 0x0f, 0x20])?; 0x5a, 0xd1, 0x01, 0x01, 0x02,
])?;
node.write_bytes(&[
0x5a, 0xd1, 0x0f, 0x20,
])?;
sleep(Duration::from_secs(10)); sleep(Duration::from_secs(10));
println!("Set back to gamepad mode"); println!("Set back to gamepad mode");
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x01])?; node.write_bytes(&[
node.write_bytes(&[0x5a, 0xd1, 0x0f, 0x20])?; 0x5a, 0xd1, 0x01, 0x01, 0x01,
])?;
node.write_bytes(&[
0x5a, 0xd1, 0x0f, 0x20,
])?;
Ok(()) Ok(())
} }
@@ -21,9 +21,15 @@ pub fn main() -> Result<(), Box<dyn Error>> {
// node.write_bytes(&[0x5a, 0xd1, 0x0a, 0x01])?; // TODO: need to CHECK // node.write_bytes(&[0x5a, 0xd1, 0x0a, 0x01])?; // TODO: need to CHECK
println!("Set mouse mode for 10 seconds"); println!("Set mouse mode for 10 seconds");
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x03])?; node.write_bytes(&[
node.write_bytes(&[0x5a, 0xd1, 0x0f, 0x20])?; 0x5a, 0xd1, 0x01, 0x01, 0x03,
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x00])?; ])?;
node.write_bytes(&[
0x5a, 0xd1, 0x0f, 0x20,
])?;
node.write_bytes(&[
0x5a, 0xd1, 0x01, 0x01, 0x00,
])?;
// sleep(Duration::from_secs(10)); // sleep(Duration::from_secs(10));
// println!("Set wasd mode for 10 seconds"); // println!("Set wasd mode for 10 seconds");
@@ -2,9 +2,9 @@ use std::fs::{read_dir, File, OpenOptions};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use log::{debug, error};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare; use zbus::zvariant::{OwnedValue, Type, Value};
use zbus::zvariant::Type;
use crate::error::PlatformError; use crate::error::PlatformError;
@@ -31,7 +31,7 @@ fn read_string(path: &Path) -> Result<String, PlatformError> {
Ok(buf.trim().to_string()) Ok(buf.trim().to_string())
} }
#[derive(Debug, Default, PartialEq, PartialOrd)] #[derive(Debug, Default, Clone, PartialEq, PartialOrd)]
pub enum AttrValue { pub enum AttrValue {
Integer(i32), Integer(i32),
String(String), String(String),
@@ -41,7 +41,7 @@ pub enum AttrValue {
None, None,
} }
#[derive(Debug, Default)] #[derive(Debug, Default, Clone)]
pub struct Attribute { pub struct Attribute {
name: String, name: String,
help: String, help: String,
@@ -49,7 +49,7 @@ pub struct Attribute {
possible_values: AttrValue, possible_values: AttrValue,
min_value: AttrValue, min_value: AttrValue,
max_value: AttrValue, max_value: AttrValue,
scalar_increment: Option<i32>, scalar_increment: AttrValue,
base_path: PathBuf, base_path: PathBuf,
} }
@@ -76,12 +76,21 @@ impl Attribute {
} }
} }
pub fn base_path_exists(&self) -> bool {
let exists = self.base_path.exists();
debug!(
"Attribute path {:?} exits? {exists}",
self.base_path.as_os_str()
);
exists
}
/// Write the `current_value` directly to the attribute path /// Write the `current_value` directly to the attribute path
pub fn set_current_value(&self, new_value: AttrValue) -> Result<(), PlatformError> { pub fn set_current_value(&self, new_value: &AttrValue) -> Result<(), PlatformError> {
let path = self.base_path.join("current_value"); let path = self.base_path.join("current_value");
let value_str = match new_value { let value_str = match new_value {
AttrValue::Integer(val) => val.to_string(), AttrValue::Integer(val) => &val.to_string(),
AttrValue::String(val) => val, AttrValue::String(val) => val,
_ => return Err(PlatformError::InvalidValue), _ => return Err(PlatformError::InvalidValue),
}; };
@@ -95,6 +104,10 @@ impl Attribute {
&self.default_value &self.default_value
} }
pub fn restore_default(&self) -> Result<(), PlatformError> {
self.set_current_value(&self.default_value)
}
pub fn possible_values(&self) -> &AttrValue { pub fn possible_values(&self) -> &AttrValue {
&self.possible_values &self.possible_values
} }
@@ -107,8 +120,8 @@ impl Attribute {
&self.max_value &self.max_value
} }
pub fn scalar_increment(&self) -> Option<i32> { pub fn scalar_increment(&self) -> &AttrValue {
self.scalar_increment &self.scalar_increment
} }
/// Read all the immutable values to struct data. These should *never* /// Read all the immutable values to struct data. These should *never*
@@ -116,7 +129,7 @@ impl Attribute {
/// subject to `firmware_attributes` class changes in kernel. /// subject to `firmware_attributes` class changes in kernel.
fn read_base_values( fn read_base_values(
base_path: &Path, base_path: &Path,
) -> (AttrValue, AttrValue, AttrValue, AttrValue, Option<i32>) { ) -> (AttrValue, AttrValue, AttrValue, AttrValue, AttrValue) {
let default_value = match read_string(&base_path.join("default_value")) { let default_value = match read_string(&base_path.join("default_value")) {
Ok(val) => { Ok(val) => {
if let Ok(int) = val.parse::<i32>() { if let Ok(int) = val.parse::<i32>() {
@@ -149,18 +162,37 @@ impl Attribute {
.ok() .ok()
.map(AttrValue::Integer) .map(AttrValue::Integer)
.unwrap_or_default(); .unwrap_or_default();
let scalar_increment = read_i32(&base_path.join("scalar_increment")).ok(); let scalar_increment = read_i32(&base_path.join("scalar_increment"))
.ok()
.map(AttrValue::Integer)
.unwrap_or_default();
( (
default_value, default_value, possible_values, min_value, max_value, scalar_increment,
possible_values,
min_value,
max_value,
scalar_increment,
) )
} }
pub fn get_watcher(&self, attr: &str) -> Result<inotify::Inotify, PlatformError> {
let path = self.base_path.join(attr);
if let Some(path) = path.to_str() {
let inotify = inotify::Inotify::init()?;
inotify
.watches()
.add(path, inotify::WatchMask::MODIFY)
.map_err(|e| {
if e.kind() == std::io::ErrorKind::NotFound {
PlatformError::AttrNotFound(self.name().to_string())
} else {
PlatformError::IoPath(path.to_string(), e)
}
})?;
return Ok(inotify);
}
Err(PlatformError::AttrNotFound(self.name().to_string()))
}
} }
#[derive(Clone)]
pub struct FirmwareAttributes { pub struct FirmwareAttributes {
attrs: Vec<Attribute>, attrs: Vec<Attribute>,
} }
@@ -173,6 +205,9 @@ impl FirmwareAttributes {
for entry in dir.flatten() { for entry in dir.flatten() {
let base_path = entry.path(); let base_path = entry.path();
let name = base_path.file_name().unwrap().to_string_lossy().to_string(); let name = base_path.file_name().unwrap().to_string_lossy().to_string();
if name == "pending_reboot" {
continue;
}
let help = read_string(&base_path.join("display_name")).unwrap_or_default(); let help = read_string(&base_path.join("display_name")).unwrap_or_default();
let (default_value, possible_values, min_value, max_value, scalar_increment) = let (default_value, possible_values, min_value, max_value, scalar_increment) =
@@ -221,59 +256,79 @@ macro_rules! define_attribute_getters {
} }
define_attribute_getters!( define_attribute_getters!(
apu_mem, apu_mem, cores_performance, cores_efficiency, ppt_pl1_spl, ppt_pl2_sppt, ppt_apu_sppt,
cores_performance, ppt_platform_sppt, ppt_fppt, nv_dynamic_boost, nv_temp_target, dgpu_base_tgp, dgpu_tgp,
cores_efficiency, charge_mode, boot_sound, mcu_powersave, panel_od, panel_hd_mode, egpu_connected, egpu_enable,
ppt_pl1_spl, dgpu_disable, gpu_mux_mode, mini_led_mode
ppt_pl2_sppt,
ppt_apu_sppt,
ppt_platform_sppt,
ppt_fppt,
nv_dynamic_boost,
nv_temp_target,
dgpu_base_tgp,
dgpu_tgp,
charge_mode,
boot_sound,
mcu_powersave,
panel_od,
panel_hd_mode,
egpu_connected,
egpu_enable,
dgpu_disable,
gpu_mux_mode,
mini_led_mode
); );
/// CamelCase names of the properties. Intended for use with DBUS /// CamelCase names of the properties. Intended for use with DBUS
#[typeshare]
#[repr(u8)] #[repr(u8)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Type, PartialEq, PartialOrd)] #[derive(
Clone,
Copy,
Serialize,
Deserialize,
Type,
Value,
OwnedValue,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
)]
#[zvariant(signature = "s")] #[zvariant(signature = "s")]
pub enum FirmwareAttribute { pub enum FirmwareAttribute {
ApuMem, ApuMem = 0,
CoresPerformance, CoresPerformance = 1,
CoresEfficiency, CoresEfficiency = 2,
PptPl1Spl, PptPl1Spl = 3,
PptPl2Sppt, PptPl2Sppt = 4,
PptApuSppt, PptPl3Fppt = 5,
PptPlatformSppt, PptFppt = 6,
PptFppt, PptApuSppt = 7,
NvDynamicBoost, PptPlatformSppt = 8,
NvTempTarget, NvDynamicBoost = 9,
DgpuBaseTgp, NvTempTarget = 10,
DgpuTgp, DgpuBaseTgp = 11,
ChargeMode, DgpuTgp = 12,
BootSound, ChargeMode = 13,
McuPowersave, BootSound = 14,
PanelOverdrive, McuPowersave = 15,
PanelHdMode, PanelOverdrive = 16,
EgpuConnected, PanelHdMode = 17,
EgpuEnable, EgpuConnected = 18,
DgpuDisable, EgpuEnable = 19,
GpuMuxMode, DgpuDisable = 20,
MiniLedMode, GpuMuxMode = 21,
PendingReboot, MiniLedMode = 22,
PendingReboot = 23,
PptEnabled = 24,
None = 25,
}
impl FirmwareAttribute {
pub fn is_ppt(&self) -> bool {
matches!(
self,
FirmwareAttribute::PptPl1Spl
| FirmwareAttribute::PptPl2Sppt
| FirmwareAttribute::PptPl3Fppt
| FirmwareAttribute::PptFppt
| FirmwareAttribute::PptApuSppt
| FirmwareAttribute::PptPlatformSppt
)
}
pub fn is_dgpu(&self) -> bool {
matches!(
self,
FirmwareAttribute::NvDynamicBoost
| FirmwareAttribute::NvTempTarget
| FirmwareAttribute::DgpuTgp
)
}
} }
impl From<&str> for FirmwareAttribute { impl From<&str> for FirmwareAttribute {
@@ -282,14 +337,16 @@ impl From<&str> for FirmwareAttribute {
"apu_mem" => Self::ApuMem, "apu_mem" => Self::ApuMem,
"cores_performance" => Self::CoresPerformance, "cores_performance" => Self::CoresPerformance,
"cores_efficiency" => Self::CoresEfficiency, "cores_efficiency" => Self::CoresEfficiency,
"ppt_enabled" => Self::PptEnabled,
"ppt_pl1_spl" => Self::PptPl1Spl, "ppt_pl1_spl" => Self::PptPl1Spl,
"ppt_pl2_sppt" => Self::PptPl2Sppt, "ppt_pl2_sppt" => Self::PptPl2Sppt,
"ppt_pl3_fppt" => Self::PptPl3Fppt,
"ppt_fppt" => Self::PptFppt,
"ppt_apu_sppt" => Self::PptApuSppt, "ppt_apu_sppt" => Self::PptApuSppt,
"ppt_platform_sppt" => Self::PptPlatformSppt, "ppt_platform_sppt" => Self::PptPlatformSppt,
"ppt_fppt" => Self::PptFppt,
"nv_dynamic_boost" => Self::NvDynamicBoost, "nv_dynamic_boost" => Self::NvDynamicBoost,
"nv_temp_target" => Self::NvTempTarget, "nv_temp_target" => Self::NvTempTarget,
"dgpu_base_tgp" => Self::DgpuBaseTgp, "nv_base_tgp" => Self::DgpuBaseTgp,
"dgpu_tgp" => Self::DgpuTgp, "dgpu_tgp" => Self::DgpuTgp,
"charge_mode" => Self::ChargeMode, "charge_mode" => Self::ChargeMode,
"boot_sound" => Self::BootSound, "boot_sound" => Self::BootSound,
@@ -302,22 +359,27 @@ impl From<&str> for FirmwareAttribute {
"gpu_mux_mode" => Self::GpuMuxMode, "gpu_mux_mode" => Self::GpuMuxMode,
"mini_led_mode" => Self::MiniLedMode, "mini_led_mode" => Self::MiniLedMode,
"pending_reboot" => Self::PendingReboot, "pending_reboot" => Self::PendingReboot,
_ => panic!("Invalid firmware attribute: {}", s), _ => {
error!("Invalid firmware attribute: {}", s);
Self::None
}
} }
} }
} }
impl From<FirmwareAttribute> for &'static str { impl From<FirmwareAttribute> for &str {
fn from(attr: FirmwareAttribute) -> Self { fn from(attr: FirmwareAttribute) -> Self {
match attr { match attr {
FirmwareAttribute::ApuMem => "apu_mem", FirmwareAttribute::ApuMem => "apu_mem",
FirmwareAttribute::CoresPerformance => "cores_performance", FirmwareAttribute::CoresPerformance => "cores_performance",
FirmwareAttribute::CoresEfficiency => "cores_efficiency", FirmwareAttribute::CoresEfficiency => "cores_efficiency",
FirmwareAttribute::PptEnabled => "ppt_enabled",
FirmwareAttribute::PptPl1Spl => "ppt_pl1_spl", FirmwareAttribute::PptPl1Spl => "ppt_pl1_spl",
FirmwareAttribute::PptPl2Sppt => "ppt_pl2_sppt", FirmwareAttribute::PptPl2Sppt => "ppt_pl2_sppt",
FirmwareAttribute::PptPl3Fppt => "ppt_pl3_fppt",
FirmwareAttribute::PptFppt => "ppt_fppt",
FirmwareAttribute::PptApuSppt => "ppt_apu_sppt", FirmwareAttribute::PptApuSppt => "ppt_apu_sppt",
FirmwareAttribute::PptPlatformSppt => "ppt_platform_sppt", FirmwareAttribute::PptPlatformSppt => "ppt_platform_sppt",
FirmwareAttribute::PptFppt => "ppt_fppt",
FirmwareAttribute::NvDynamicBoost => "nv_dynamic_boost", FirmwareAttribute::NvDynamicBoost => "nv_dynamic_boost",
FirmwareAttribute::NvTempTarget => "nv_temp_target", FirmwareAttribute::NvTempTarget => "nv_temp_target",
FirmwareAttribute::DgpuBaseTgp => "dgpu_base_tgp", FirmwareAttribute::DgpuBaseTgp => "dgpu_base_tgp",
@@ -333,6 +395,7 @@ impl From<FirmwareAttribute> for &'static str {
FirmwareAttribute::GpuMuxMode => "gpu_mux_mode", FirmwareAttribute::GpuMuxMode => "gpu_mux_mode",
FirmwareAttribute::MiniLedMode => "mini_led_mode", FirmwareAttribute::MiniLedMode => "mini_led_mode",
FirmwareAttribute::PendingReboot => "pending_reboot", FirmwareAttribute::PendingReboot => "pending_reboot",
FirmwareAttribute::None => "none",
} }
} }
} }
@@ -415,6 +478,6 @@ mod tests {
if let AttrValue::Integer(val) = &mut val { if let AttrValue::Integer(val) = &mut val {
*val = 0; *val = 0;
} }
attr.set_current_value(val).unwrap(); attr.set_current_value(&val).unwrap();
} }
} }
+18 -23
View File
@@ -2,11 +2,10 @@ use std::path::PathBuf;
use log::{info, warn}; use log::{info, warn};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
use crate::error::{PlatformError, Result}; use crate::error::{PlatformError, Result};
use crate::platform::ThrottlePolicy; use crate::platform::PlatformProfile;
use crate::{read_attr_string, to_device}; use crate::{read_attr_string, to_device};
const ATTR_AVAILABLE_GOVERNORS: &str = "cpufreq/scaling_available_governors"; const ATTR_AVAILABLE_GOVERNORS: &str = "cpufreq/scaling_available_governors";
@@ -147,7 +146,6 @@ impl CPUControl {
} }
} }
#[typeshare]
#[repr(u8)] #[repr(u8)]
#[derive( #[derive(
Deserialize, Serialize, Type, Value, OwnedValue, Debug, PartialEq, PartialOrd, Clone, Copy, Deserialize, Serialize, Type, Value, OwnedValue, Debug, PartialEq, PartialOrd, Clone, Copy,
@@ -179,7 +177,6 @@ impl From<CPUGovernor> for String {
} }
} }
#[typeshare]
#[repr(u32)] #[repr(u32)]
#[derive( #[derive(
Deserialize, Deserialize,
@@ -204,12 +201,13 @@ pub enum CPUEPP {
Power = 4, Power = 4,
} }
impl From<ThrottlePolicy> for CPUEPP { impl From<PlatformProfile> for CPUEPP {
fn from(value: ThrottlePolicy) -> Self { fn from(value: PlatformProfile) -> Self {
match value { match value {
ThrottlePolicy::Balanced => CPUEPP::BalancePerformance, PlatformProfile::Balanced => CPUEPP::BalancePerformance,
ThrottlePolicy::Performance => CPUEPP::Performance, PlatformProfile::Performance => CPUEPP::Performance,
ThrottlePolicy::Quiet => CPUEPP::Power, PlatformProfile::Quiet => CPUEPP::Power,
PlatformProfile::LowPower => CPUEPP::Power,
} }
} }
} }
@@ -268,21 +266,18 @@ mod tests {
fn check_cpu() { fn check_cpu() {
let cpu = CPUControl::new().unwrap(); let cpu = CPUControl::new().unwrap();
assert_eq!(cpu.get_governor().unwrap(), CPUGovernor::Powersave); assert_eq!(cpu.get_governor().unwrap(), CPUGovernor::Powersave);
assert_eq!( assert_eq!(cpu.get_available_governors().unwrap(), vec![
cpu.get_available_governors().unwrap(), CPUGovernor::Performance,
vec![CPUGovernor::Performance, CPUGovernor::Powersave] CPUGovernor::Powersave
); ]);
assert_eq!(cpu.get_epp().unwrap(), CPUEPP::BalancePower); assert_eq!(cpu.get_epp().unwrap(), CPUEPP::BalancePower);
assert_eq!( assert_eq!(cpu.get_available_epp().unwrap(), vec![
cpu.get_available_epp().unwrap(), CPUEPP::Default,
vec![ CPUEPP::Performance,
CPUEPP::Default, CPUEPP::BalancePerformance,
CPUEPP::Performance, CPUEPP::BalancePower,
CPUEPP::BalancePerformance, CPUEPP::Power,
CPUEPP::BalancePower, ]);
CPUEPP::Power,
]
);
} }
} }
+17 -2
View File
@@ -1,9 +1,9 @@
//! This crate functions as a wrapper of all the relevant ASUS functionality //! This crate functions as a wrapper of all the relevant ASUS functionality
//! on ROG, Strix, and TUF laptops. //! on ROG, Strix, and TUF laptops.
pub mod asus_armoury;
pub mod cpu; pub mod cpu;
pub mod error; pub mod error;
pub mod firmware_attributes;
pub mod hid_raw; pub mod hid_raw;
pub mod keyboard_led; pub mod keyboard_led;
pub(crate) mod macros; pub(crate) mod macros;
@@ -15,6 +15,7 @@ use std::path::Path;
use error::{PlatformError, Result}; use error::{PlatformError, Result};
use log::warn; use log::warn;
use platform::PlatformProfile;
use udev::Device; use udev::Device;
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");
@@ -107,11 +108,25 @@ pub fn write_attr_string(device: &mut Device, attr: &str, value: &str) -> Result
.map_err(|e| PlatformError::IoPath(attr.into(), e)) .map_err(|e| PlatformError::IoPath(attr.into(), e))
} }
pub fn read_attr_string_array(device: &Device, attr_name: &str) -> Result<Vec<PlatformProfile>> {
if let Some(value) = device.attribute_value(attr_name) {
let tmp: Vec<PlatformProfile> = value
.to_string_lossy()
.split(' ')
.map(PlatformProfile::from)
.collect();
return Ok(tmp);
}
Err(PlatformError::AttrNotFound(attr_name.to_owned()))
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[test] #[test]
fn check() { fn check() {
let data = [1, 2, 3, 4, 5]; let data = [
1, 2, 3, 4, 5,
];
let mut tmp = String::new(); let mut tmp = String::new();
for n in data { for n in data {
tmp.push_str(&n.to_string()); tmp.push_str(&n.to_string());
+21
View File
@@ -154,6 +154,18 @@ macro_rules! get_attr_string {
}; };
} }
#[macro_export]
macro_rules! get_attr_string_array {
($(#[$attr:meta])* $attr_name:literal $item:ident) => {
concat_idents::concat_idents!(fn_name = get_, $attr_name {
$(#[$attr])*
pub fn fn_name(&self) -> Result<Vec<PlatformProfile>> {
$crate::read_attr_string_array(&to_device(&self.$item)?, $attr_name)
}
});
};
}
#[macro_export] #[macro_export]
macro_rules! set_attr_string { macro_rules! set_attr_string {
($(#[$attr:meta])* $attr_name:literal $item:ident) => { ($(#[$attr:meta])* $attr_name:literal $item:ident) => {
@@ -175,3 +187,12 @@ macro_rules! attr_string {
$crate::watch_attr!($attr_name $item); $crate::watch_attr!($attr_name $item);
}; };
} }
#[macro_export]
macro_rules! attr_string_array {
($(#[$attr:meta])* $attr_name:literal, $item:ident) => {
$crate::has_attr!($attr_name $item);
$crate::get_attr_string_array!($attr_name $item);
$crate::watch_attr!($attr_name $item);
};
}
+68 -130
View File
@@ -4,11 +4,10 @@ use std::str::FromStr;
use log::{info, warn}; use log::{info, warn};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
use crate::error::{PlatformError, Result}; use crate::error::{PlatformError, Result};
use crate::{attr_bool, attr_string, attr_u8, to_device}; use crate::{attr_string, attr_string_array, to_device};
/// The "platform" device provides access to things like: /// The "platform" device provides access to things like:
/// - `dgpu_disable` /// - `dgpu_disable`
@@ -25,84 +24,16 @@ pub struct RogPlatform {
} }
impl RogPlatform { impl RogPlatform {
attr_bool!("dgpu_disable", path);
attr_bool!("egpu_enable", path);
attr_u8!("gpu_mux_mode", path);
attr_bool!("panel_od", path);
attr_bool!("mini_led_mode", path);
attr_u8!(
/// This is technically the same as `platform_profile` since both are
/// tied in-kernel
"throttle_thermal_policy",
path
);
attr_string!( attr_string!(
/// The acpi platform_profile support /// The acpi platform_profile support
"platform_profile", "platform_profile",
pp_path pp_path
); );
attr_u8!( attr_string_array!(
/// Package Power Target total of CPU: PL1 on Intel, SPL on AMD. /// The acpi platform_profile support
/// Shown on Intel+Nvidia or AMD+Nvidia based systems: "platform_profile_choices",
/// * min=5, max=250 pp_path
"ppt_pl1_spl",
path
);
attr_u8!(
/// 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
"ppt_pl2_sppt",
path
);
attr_u8!(
/// Fast Package Power Tracking Limit of CPU. AMD+Nvidia only:
/// * min=5, max=250
"ppt_fppt",
path
);
attr_u8!(
/// APU SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
"ppt_apu_sppt",
path
);
attr_u8!(
/// Platform SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
"ppt_platform_sppt",
path
);
attr_u8!(
/// Dynamic boost limit of the Nvidia dGPU:
/// * min=5, max=25
"nv_dynamic_boost",
path
);
attr_u8!(
/// Target temperature limit of the Nvidia dGPU:
/// * min=75, max=87
"nv_temp_target",
path
);
attr_bool!(
/// Control the POST animation "FWOOoosh" sound
"boot_sound",
path
); );
pub fn new() -> Result<Self> { pub fn new() -> Result<Self> {
@@ -148,7 +79,6 @@ impl Default for RogPlatform {
} }
} }
#[typeshare]
#[repr(u8)] #[repr(u8)]
#[derive( #[derive(
Serialize, Deserialize, Default, Type, Value, OwnedValue, Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, Default, Type, Value, OwnedValue, Debug, PartialEq, Eq, Clone, Copy,
@@ -245,8 +175,7 @@ impl Display for GpuMode {
} }
} }
#[typeshare] #[repr(i32)]
#[repr(u32)]
#[derive( #[derive(
Deserialize, Deserialize,
Serialize, Serialize,
@@ -258,40 +187,44 @@ impl Display for GpuMode {
PartialEq, PartialEq,
Eq, Eq,
PartialOrd, PartialOrd,
Ord,
Hash, Hash,
Clone, Clone,
Copy, Copy,
)] )]
#[zvariant(signature = "u")] #[zvariant(signature = "i")]
/// `throttle_thermal_policy` in asus_wmi /// `platform_profile` in asus_wmi
pub enum ThrottlePolicy { pub enum PlatformProfile {
#[default] #[default]
Balanced = 0, Balanced = 0,
Performance = 1, Performance = 1,
Quiet = 2, Quiet = 2,
LowPower = 3,
} }
impl ThrottlePolicy { impl PlatformProfile {
pub const fn next(self) -> Self { pub fn next(current: Self, choices: &[Self]) -> Self {
match self { match current {
Self::Balanced => Self::Performance, Self::Balanced => Self::Performance,
Self::Performance => Self::Quiet, Self::Performance => {
if choices.contains(&Self::LowPower) {
Self::LowPower
} else {
Self::Quiet
}
}
Self::Quiet => Self::Balanced, Self::Quiet => Self::Balanced,
Self::LowPower => Self::Balanced,
} }
} }
pub const fn list() -> [Self; 3] {
[Self::Balanced, Self::Performance, Self::Quiet]
}
} }
impl From<u8> for ThrottlePolicy { impl From<i32> for PlatformProfile {
fn from(num: u8) -> Self { fn from(num: i32) -> Self {
match num { match num {
0 => Self::Balanced, 0 => Self::Balanced,
1 => Self::Performance, 1 => Self::Performance,
2 => Self::Quiet, 2 => Self::Quiet,
3 => Self::LowPower,
_ => { _ => {
warn!("Unknown number for PlatformProfile: {}", num); warn!("Unknown number for PlatformProfile: {}", num);
Self::Balanced Self::Balanced
@@ -300,59 +233,71 @@ impl From<u8> for ThrottlePolicy {
} }
} }
impl From<i32> for ThrottlePolicy { impl From<PlatformProfile> for i32 {
fn from(num: i32) -> Self { fn from(p: PlatformProfile) -> Self {
(num as u8).into() p as i32
} }
} }
impl From<ThrottlePolicy> for u8 { impl From<&PlatformProfile> for &str {
fn from(p: ThrottlePolicy) -> Self { fn from(profile: &PlatformProfile) -> &'static str {
match p {
ThrottlePolicy::Balanced => 0,
ThrottlePolicy::Performance => 1,
ThrottlePolicy::Quiet => 2,
}
}
}
impl From<ThrottlePolicy> for i32 {
fn from(p: ThrottlePolicy) -> Self {
<u8>::from(p) as i32
}
}
impl From<ThrottlePolicy> for &str {
fn from(profile: ThrottlePolicy) -> &'static str {
match profile { match profile {
ThrottlePolicy::Balanced => "balanced", PlatformProfile::Balanced => "balanced",
ThrottlePolicy::Performance => "performance", PlatformProfile::Performance => "performance",
ThrottlePolicy::Quiet => "quiet", PlatformProfile::Quiet => "quiet",
PlatformProfile::LowPower => "low-power",
} }
} }
} }
impl std::str::FromStr for ThrottlePolicy { impl From<PlatformProfile> for &str {
fn from(profile: PlatformProfile) -> &'static str {
<&str>::from(&profile)
}
}
impl From<String> for PlatformProfile {
fn from(profile: String) -> Self {
Self::from(profile.as_str())
}
}
impl Display for PlatformProfile {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "({})", <&str>::from(self))
}
}
impl std::str::FromStr for PlatformProfile {
type Err = PlatformError; type Err = PlatformError;
fn from_str(profile: &str) -> Result<Self> { fn from_str(profile: &str) -> Result<Self> {
match profile.to_ascii_lowercase().trim() { match profile.to_ascii_lowercase().trim() {
"balanced" => Ok(ThrottlePolicy::Balanced), "balanced" => Ok(PlatformProfile::Balanced),
"performance" => Ok(ThrottlePolicy::Performance), "performance" => Ok(PlatformProfile::Performance),
"quiet" => Ok(ThrottlePolicy::Quiet), "quiet" => Ok(PlatformProfile::Quiet),
"low-power" => Ok(PlatformProfile::LowPower),
_ => Err(PlatformError::NotSupported), _ => Err(PlatformError::NotSupported),
} }
} }
} }
impl Display for ThrottlePolicy { impl From<&str> for PlatformProfile {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn from(profile: &str) -> Self {
write!(f, "{:?}", self) match profile.to_ascii_lowercase().trim() {
"balanced" => PlatformProfile::Balanced,
"performance" => PlatformProfile::Performance,
"quiet" => PlatformProfile::Quiet,
"low-power" => PlatformProfile::LowPower,
_ => {
warn!("{profile} is unknown, using ThrottlePolicy::Balanced");
PlatformProfile::Balanced
}
}
} }
} }
/// CamelCase names of the properties. Intended for use with DBUS /// CamelCase names of the properties. Intended for use with DBUS
#[typeshare]
#[repr(u8)] #[repr(u8)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Type, PartialEq, PartialOrd)] #[derive(Debug, Clone, Copy, Serialize, Deserialize, Type, PartialEq, PartialOrd)]
#[zvariant(signature = "s")] #[zvariant(signature = "s")]
@@ -365,11 +310,4 @@ pub enum Properties {
MiniLedMode, MiniLedMode,
EgpuEnable, EgpuEnable,
ThrottlePolicy, ThrottlePolicy,
PptPl1Spl,
PptPl2Sppt,
PptFppt,
PptApuSppt,
PptPlatformSppt,
NvDynamicBoost,
NvTempTarget,
} }
-1
View File
@@ -16,7 +16,6 @@ dbus = ["zbus"]
log.workspace = true log.workspace = true
udev.workspace = true udev.workspace = true
serde.workspace = true serde.workspace = true
typeshare.workspace = true
rog_platform = { path = "../rog-platform" } rog_platform = { path = "../rog-platform" }
zbus = { workspace = true, optional = true } zbus = { workspace = true, optional = true }
+1 -2
View File
@@ -16,8 +16,7 @@ pub enum ProfileError {
/// (pwm/temp, prev, next) /// (pwm/temp, prev, next)
ParseFanCurvePrevHigher(&'static str, u8, u8), ParseFanCurvePrevHigher(&'static str, u8, u8),
ParseFanCurvePercentOver100(u8), ParseFanCurvePercentOver100(u8),
NotEnoughPoints, NotEnoughPoints, // Zbus(zbus::Error),
// Zbus(zbus::Error),
} }
impl fmt::Display for ProfileError { impl fmt::Display for ProfileError {

Some files were not shown because too many files have changed in this diff Show More