Compare commits

...

10 Commits

Author SHA1 Message Date
Luke D. Jones 2d396a49da Update crate versions 2023-07-24 10:14:24 +12:00
Luke D. Jones a6d89a622b Various cleanup. Add GA402X LED modes 2023-07-24 10:04:10 +12:00
Luke D. Jones 51bcb0082b profiles: add mid fan curve support 2023-07-24 09:29:56 +12:00
Luke D. Jones eb54250e4d aura: support FX505G 2023-07-24 09:28:09 +12:00
Luke D. Jones eafc831231 gex: update xml and aura power parsing 2023-07-12 14:21:57 +12:00
Luke D. Jones c625e97b7b Update changelog 2023-07-11 21:08:10 +12:00
Luke D. Jones fea56879d6 Update changelog 2023-07-11 21:06:27 +12:00
Luke D. Jones 03052e129b aura: update dbus xml 2023-07-11 21:02:40 +12:00
Luke D. Jones 3dbc893905 aura: update bindings 2023-07-11 21:00:42 +12:00
Luke D. Jones 50152961c7 aura: refactor modern rog power settings 2023-07-11 20:59:43 +12:00
33 changed files with 1412 additions and 1071 deletions
+6 -1
View File
@@ -5,12 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
## [v4.7.0-RC2] ## [v4.7.0-RC3]
### Added ### Added
- Support for FX507Z LED modes - Support for FX507Z LED modes
- Support for GL503V LED modes - Support for GL503V LED modes
- Support for G733C LED modes - Support for G733C LED modes
- Support for GV601VI LED modes - Support for GV601VI LED modes
- Support for FX505G LED modes
- Support for GA402X LED modes
- Support for G634J LED modes (layout is in progress) - Support for G634J LED modes (layout is in progress)
- Support the Rear Glow on some laptops - Support the Rear Glow on some laptops
- Added field to aura_support to determine which LED power zones are supported. This will need folks to contribute data. - Added field to aura_support to determine which LED power zones are supported. This will need folks to contribute data.
@@ -26,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add generation of typescript types from the rust types used via dbus using typeshare - Add generation of typescript types from the rust types used via dbus using typeshare
- Add generation of introspection XML from asusd dbus - Add generation of introspection XML from asusd dbus
- Add a reworked gnome extension to the main repo under `desktop-extensions/gnome/`. This was done to better keep the extension in sync with work done on asusd, especially around breaking dbus - Add a reworked gnome extension to the main repo under `desktop-extensions/gnome/`. This was done to better keep the extension in sync with work done on asusd, especially around breaking dbus
- Add support for the mid fan custom curves on some laptops
### Changed ### Changed
- Move FX506HC to FX506H in arua DB to catch full series of this range - Move FX506HC to FX506H in arua DB to catch full series of this range
- Move FX506LH to FX506L in arua DB to catch full series of this range - Move FX506LH to FX506L in arua DB to catch full series of this range
@@ -35,10 +38,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Prevent the multiple notifications from a profile change from occuring (too many functions with side effects!) - Prevent the multiple notifications from a profile change from occuring (too many functions with side effects!)
- Apply keyboard brightness when setting a mode - Apply keyboard brightness when setting a mode
- Update GL503 led config - Update GL503 led config
- Arua LED power control has been heavily refactored for 0x19b6+ devices
- Rog Control Center: - Rog Control Center:
- Added option to enable/disable system tray - Added option to enable/disable system tray
- Added button to fully quit app (exits from background) - Added button to fully quit app (exits from background)
- Moved application settings to new page - Moved application settings to new page
- Aura LED power refactor is now taken advantage of in RCC, exposing all settings
### BREAKING ### BREAKING
- All Anime related DBUS methods/notifs are changed - All Anime related DBUS methods/notifs are changed
- All dbus interfaces that handled an enum have now been forced to use the enum as String type, not uint or similar, this unfortunately breaks a heap of stuff but has the benefit of allowing asusctl to use crates to generate a typescript (or other) binding to the types being used by zbus for the proxies. The implication here is that there will be an eventual tighter integration with the gnome extension and maybe KDE also. - All dbus interfaces that handled an enum have now been forced to use the enum as String type, not uint or similar, this unfortunately breaks a heap of stuff but has the benefit of allowing asusctl to use crates to generate a typescript (or other) binding to the types being used by zbus for the proxies. The implication here is that there will be an eventual tighter integration with the gnome extension and maybe KDE also.
Generated
+148 -114
View File
@@ -163,9 +163,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.71" version = "1.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854"
[[package]] [[package]]
name = "arboard" name = "arboard"
@@ -199,7 +199,7 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]] [[package]]
name = "asusctl" name = "asusctl"
version = "4.7.0-RC1" version = "4.7.0-RC3"
dependencies = [ dependencies = [
"asusd", "asusd",
"cargo-husky", "cargo-husky",
@@ -218,7 +218,7 @@ dependencies = [
[[package]] [[package]]
name = "asusd" name = "asusd"
version = "4.7.0-RC1" version = "4.7.0-RC3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"cargo-husky", "cargo-husky",
@@ -242,7 +242,7 @@ dependencies = [
[[package]] [[package]]
name = "asusd-user" name = "asusd-user"
version = "4.7.0-RC1" version = "4.7.0-RC3"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"config-traits", "config-traits",
@@ -272,9 +272,9 @@ dependencies = [
[[package]] [[package]]
name = "async-channel" name = "async-channel"
version = "1.8.0" version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35"
dependencies = [ dependencies = [
"concurrent-queue", "concurrent-queue",
"event-listener", "event-listener",
@@ -290,7 +290,7 @@ dependencies = [
"async-lock", "async-lock",
"async-task", "async-task",
"concurrent-queue", "concurrent-queue",
"fastrand", "fastrand 1.9.0",
"futures-lite", "futures-lite",
"slab", "slab",
] ]
@@ -321,7 +321,7 @@ dependencies = [
"log", "log",
"parking", "parking",
"polling", "polling",
"rustix 0.37.22", "rustix 0.37.23",
"slab", "slab",
"socket2", "socket2",
"waker-fn", "waker-fn",
@@ -361,7 +361,7 @@ dependencies = [
"cfg-if", "cfg-if",
"event-listener", "event-listener",
"futures-lite", "futures-lite",
"rustix 0.37.22", "rustix 0.37.23",
"signal-hook", "signal-hook",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
@@ -374,7 +374,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
@@ -385,13 +385,13 @@ checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae"
[[package]] [[package]]
name = "async-trait" name = "async-trait"
version = "0.1.69" version = "0.1.72"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b2d0f03b3640e3a630367e40c468cb7f309529c708ed1d88597047b0e7c6ef7" checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
@@ -566,7 +566,7 @@ dependencies = [
"async-lock", "async-lock",
"async-task", "async-task",
"atomic-waker", "atomic-waker",
"fastrand", "fastrand 1.9.0",
"futures-lite", "futures-lite",
"log", "log",
] ]
@@ -594,7 +594,7 @@ checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
@@ -767,7 +767,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f76990911f2267d837d9d0ad060aa63aaad170af40904b29461734c339030d4d" checksum = "f76990911f2267d837d9d0ad060aa63aaad170af40904b29461734c339030d4d"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
@@ -781,7 +781,7 @@ dependencies = [
[[package]] [[package]]
name = "config-traits" name = "config-traits"
version = "4.7.0-RC1" version = "4.7.0-RC3"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"log", "log",
@@ -834,9 +834,9 @@ dependencies = [
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.8" version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c" checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@@ -1026,9 +1026,9 @@ dependencies = [
[[package]] [[package]]
name = "either" name = "either"
version = "1.8.1" version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]] [[package]]
name = "emath" name = "emath"
@@ -1079,7 +1079,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
@@ -1111,6 +1111,12 @@ dependencies = [
"parking_lot", "parking_lot",
] ]
[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.3.1" version = "0.3.1"
@@ -1157,6 +1163,12 @@ dependencies = [
"instant", "instant",
] ]
[[package]]
name = "fastrand"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764"
[[package]] [[package]]
name = "fdeflate" name = "fdeflate"
version = "0.3.0" version = "0.3.0"
@@ -1257,7 +1269,7 @@ version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce"
dependencies = [ dependencies = [
"fastrand", "fastrand 1.9.0",
"futures-core", "futures-core",
"futures-io", "futures-io",
"memchr", "memchr",
@@ -1274,7 +1286,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
@@ -1520,9 +1532,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]] [[package]]
name = "glow" name = "glow"
version = "0.12.2" version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "807edf58b70c0b5b2181dd39fe1839dbdb3ba02645630dc5f753e23da307f762" checksum = "ca0fe580e4b60a8ab24a868bc08e2f03cbcb20d3d676601fa909386713333728"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"slotmap", "slotmap",
@@ -1682,9 +1694,9 @@ dependencies = [
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.12.3" version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
[[package]] [[package]]
name = "heck" name = "heck"
@@ -1694,9 +1706,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.3.1" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
[[package]] [[package]]
name = "hex" name = "hex"
@@ -1754,11 +1766,11 @@ dependencies = [
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.9.3" version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
dependencies = [ dependencies = [
"autocfg", "equivalent",
"hashbrown", "hashbrown",
] ]
@@ -1809,12 +1821,12 @@ dependencies = [
[[package]] [[package]]
name = "is-terminal" name = "is-terminal"
version = "0.4.8" version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24fddda5af7e54bf7da53067d6e802dbcc381d0a8eef629df528e3ebf68755cb" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi",
"rustix 0.38.2", "rustix 0.38.4",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
@@ -1829,9 +1841,9 @@ dependencies = [
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.7" version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0aa48fab2893d8a49caa94082ae8488f4e1050d73b367881dcd2198f4199fd8" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]] [[package]]
name = "jni" name = "jni"
@@ -2003,9 +2015,9 @@ dependencies = [
[[package]] [[package]]
name = "mac-notification-sys" name = "mac-notification-sys"
version = "0.5.6" version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e72d50edb17756489e79d52eb146927bec8eba9dd48faadf9ef08bca3791ad5" checksum = "abc434554ad0e640d772f7f262aa28e61d485212533d3673abe5f3d1729bd42a"
dependencies = [ dependencies = [
"cc", "cc",
"dirs-next", "dirs-next",
@@ -2206,9 +2218,9 @@ dependencies = [
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.15" version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2"
dependencies = [ dependencies = [
"autocfg", "autocfg",
] ]
@@ -2262,7 +2274,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
@@ -2426,9 +2438,9 @@ dependencies = [
[[package]] [[package]]
name = "paste" name = "paste"
version = "1.0.12" version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]] [[package]]
name = "peeking_take_while" name = "peeking_take_while"
@@ -2547,9 +2559,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.63" version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@@ -2565,9 +2577,9 @@ dependencies = [
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.29" version = "1.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@@ -2639,9 +2651,21 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.8.4" version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@@ -2650,13 +2674,13 @@ dependencies = [
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.7.2" version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
[[package]] [[package]]
name = "rog-control-center" name = "rog-control-center"
version = "4.7.0-RC1" version = "4.7.0-RC3"
dependencies = [ dependencies = [
"asusd", "asusd",
"cargo-husky", "cargo-husky",
@@ -2689,7 +2713,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_anime" name = "rog_anime"
version = "4.7.0-RC1" version = "4.7.0-RC3"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"gif", "gif",
@@ -2706,7 +2730,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_aura" name = "rog_aura"
version = "4.7.0-RC1" version = "4.7.0-RC3"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"log", "log",
@@ -2720,7 +2744,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_dbus" name = "rog_dbus"
version = "4.7.0-RC1" version = "4.7.0-RC3"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"rog_anime", "rog_anime",
@@ -2732,13 +2756,14 @@ dependencies = [
[[package]] [[package]]
name = "rog_platform" name = "rog_platform"
version = "4.7.0-RC1" version = "4.7.0-RC3"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"concat-idents", "concat-idents",
"inotify", "inotify",
"log", "log",
"rog_aura", "rog_aura",
"rog_profiles",
"rusb", "rusb",
"serde", "serde",
"serde_derive", "serde_derive",
@@ -2750,9 +2775,10 @@ dependencies = [
[[package]] [[package]]
name = "rog_profiles" name = "rog_profiles"
version = "4.7.0-RC1" version = "4.7.0-RC3"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"log",
"serde", "serde",
"serde_derive", "serde_derive",
"typeshare", "typeshare",
@@ -2762,7 +2788,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_simulators" name = "rog_simulators"
version = "4.7.0-RC1" version = "4.7.0-RC3"
dependencies = [ dependencies = [
"glam", "glam",
"log", "log",
@@ -2815,9 +2841,9 @@ dependencies = [
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.37.22" version = "0.37.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8818fa822adcc98b18fedbb3632a6a33213c070556b5aa7c4c8cc21cff565c4c" checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"errno", "errno",
@@ -2829,9 +2855,9 @@ dependencies = [
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.38.2" version = "0.38.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aabcb0461ebd01d6b79945797c27f8529082226cb630a9865a71870ff63532a4" checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5"
dependencies = [ dependencies = [
"bitflags 2.3.3", "bitflags 2.3.3",
"errno", "errno",
@@ -2842,9 +2868,9 @@ dependencies = [
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.13" version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]] [[package]]
name = "same-file" name = "same-file"
@@ -2863,9 +2889,9 @@ checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.1.0" version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]] [[package]]
name = "sctk-adwaita" name = "sctk-adwaita"
@@ -2905,35 +2931,35 @@ dependencies = [
[[package]] [[package]]
name = "semver" name = "semver"
version = "1.0.17" version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.164" version = "1.0.174"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" checksum = "3b88756493a5bd5e5395d53baa70b194b05764ab85b59e43e4b8f4e1192fa9b1"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.164" version = "1.0.174"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" checksum = "6e5c3a298c7f978e53536f95a63bdc4c4a64550582f31a0359a9afda6aede62e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.99" version = "1.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@@ -2942,13 +2968,13 @@ dependencies = [
[[package]] [[package]]
name = "serde_repr" name = "serde_repr"
version = "0.1.12" version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" checksum = "e168eaaf71e8f9bd6037feb05190485708e019f4fd87d161b3c0a0d37daf85e5"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
@@ -2979,9 +3005,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]] [[package]]
name = "signal-hook" name = "signal-hook"
version = "0.3.15" version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "732768f1176d21d09e076c23a93123d40bba92d50c4058da34d45c8de8e682b9" checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801"
dependencies = [ dependencies = [
"libc", "libc",
"signal-hook-registry", "signal-hook-registry",
@@ -3022,9 +3048,9 @@ dependencies = [
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.10.0" version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
[[package]] [[package]]
name = "smithay-client-toolkit" name = "smithay-client-toolkit"
@@ -3128,9 +3154,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.23" version = "2.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -3155,7 +3181,7 @@ dependencies = [
"cfg-expr", "cfg-expr",
"heck", "heck",
"pkg-config", "pkg-config",
"toml 0.7.3", "toml 0.7.6",
"version-compare", "version-compare",
] ]
@@ -3171,9 +3197,9 @@ dependencies = [
[[package]] [[package]]
name = "target-lexicon" name = "target-lexicon"
version = "0.12.8" version = "0.12.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac" checksum = "1d2faeef5759ab89935255b1a4cd98e0baf99d1085e37d36599c625dac49ae8e"
[[package]] [[package]]
name = "tauri-winrt-notification" name = "tauri-winrt-notification"
@@ -3187,15 +3213,14 @@ dependencies = [
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.6.0" version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" checksum = "5486094ee78b2e5038a6382ed7645bc084dc2ec433426ca4c3cb61e2007b8998"
dependencies = [ dependencies = [
"autocfg",
"cfg-if", "cfg-if",
"fastrand", "fastrand 2.0.0",
"redox_syscall 0.3.5", "redox_syscall 0.3.5",
"rustix 0.37.22", "rustix 0.38.4",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
@@ -3210,29 +3235,29 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.40" version = "1.0.44"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.40" version = "1.0.44"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.22" version = "0.3.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446"
dependencies = [ dependencies = [
"serde", "serde",
"time-core", "time-core",
@@ -3318,7 +3343,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
@@ -3332,9 +3357,9 @@ dependencies = [
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.7.3" version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542"
dependencies = [ dependencies = [
"serde", "serde",
"serde_spanned", "serde_spanned",
@@ -3353,15 +3378,15 @@ dependencies = [
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
version = "0.19.8" version = "0.19.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"serde", "serde",
"serde_spanned", "serde_spanned",
"toml_datetime", "toml_datetime",
"winnow", "winnow 0.5.0",
] ]
[[package]] [[package]]
@@ -3384,7 +3409,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.23", "syn 2.0.27",
] ]
[[package]] [[package]]
@@ -3490,9 +3515,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.9" version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
[[package]] [[package]]
name = "unicode-normalization" name = "unicode-normalization"
@@ -4055,6 +4080,15 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "winnow"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81fac9742fd1ad1bd9643b991319f72dd031016d44b77039a26977eb667141e7"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "x11-dl" name = "x11-dl"
version = "2.21.0" version = "2.21.0"
@@ -4109,9 +4143,9 @@ dependencies = [
[[package]] [[package]]
name = "xml-rs" name = "xml-rs"
version = "0.8.15" version = "0.8.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a56c84a8ccd4258aed21c92f70c0f6dea75356b6892ae27c24139da456f9336" checksum = "47430998a7b5d499ccee752b41567bc3afc57e1327dc855b1a2aa44ce29b5fa1"
[[package]] [[package]]
name = "zbus" name = "zbus"
@@ -4164,7 +4198,7 @@ dependencies = [
"quote", "quote",
"regex", "regex",
"syn 1.0.109", "syn 1.0.109",
"winnow", "winnow 0.4.1",
"zvariant_utils", "zvariant_utils",
] ]
+1 -1
View File
@@ -3,7 +3,7 @@ members = ["asusctl", "asusd", "asusd-user", "config-traits", "rog-platform", "r
default-members = ["asusctl", "asusd", "asusd-user", "rog-control-center"] default-members = ["asusctl", "asusd", "asusd-user", "rog-control-center"]
[workspace.package] [workspace.package]
version = "4.7.0-RC1" version = "4.7.0-RC3"
[workspace.dependencies] [workspace.dependencies]
async-trait = "^0.1" async-trait = "^0.1"
+25 -45
View File
@@ -4,7 +4,7 @@ use gumdrop::Options;
use rog_aura::error::Error; use rog_aura::error::Error;
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour, Direction, Speed}; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour, Direction, Speed};
#[derive(Options)] #[derive(Options, Debug)]
pub struct LedPowerCommand1 { pub struct LedPowerCommand1 {
#[options(help = "print help message")] #[options(help = "print help message")]
pub help: bool, pub help: bool,
@@ -20,63 +20,43 @@ pub struct LedPowerCommand1 {
pub sleep: Option<bool>, pub sleep: Option<bool>,
} }
#[derive(Options)] #[derive(Options, Debug)]
pub struct LedPowerCommand2 { pub struct LedPowerCommand2 {
#[options(help = "print help message")] #[options(help = "print help message")]
pub help: bool, pub help: bool,
#[options(command)] #[options(command)]
pub command: Option<SetAuraEnabled>, pub command: Option<SetAuraZoneEnabled>,
} }
#[derive(Options)] #[derive(Options, Debug)]
pub enum SetAuraEnabled { pub enum SetAuraZoneEnabled {
/// Applies to both old and new models /// Applies to both old and new models
#[options(help = "set <keyboard, logo, lightbar, rearglow> to enabled while device is awake")] #[options(help = "")]
Awake(AuraEnabled), Keyboard(AuraPowerStates),
#[options( #[options(help = "")]
help = "set <keyboard, logo, lightbar, rearglow> to enabled while the device is booting" Logo(AuraPowerStates),
)] #[options(help = "")]
Boot(AuraEnabled), Lightbar(AuraPowerStates),
#[options( #[options(help = "")]
help = "set <keyboard, logo, lightbar, rearglow> to animate while the device is suspended" Lid(AuraPowerStates),
)] #[options(help = "")]
Sleep(AuraEnabled), RearGlow(AuraPowerStates),
#[options(
help = "set <keyboard, logo, lightbar, rearglow> to animate while the device is shutdown"
)]
Shutdown(AuraEnabled),
} }
#[derive(Debug, Clone, Default, Options)] #[derive(Debug, Clone, Options)]
pub struct AuraEnabled { pub struct AuraPowerStates {
#[options(help = "print help message")] #[options(help = "print help message")]
pub help: bool, pub help: bool,
#[options(meta = "", help = "<true/false>")] #[options(help = "defaults to false if option unused")]
pub keyboard: Option<bool>, pub boot: bool,
#[options(meta = "", help = "<true/false>")] #[options(help = "defaults to false if option unused")]
pub logo: Option<bool>, pub awake: bool,
#[options(meta = "", help = "<true/false>")] #[options(help = "defaults to false if option unused")]
pub frontglow: Option<bool>, pub sleep: bool,
#[options(meta = "", help = "<true/false>")] #[options(help = "defaults to false if option unused")]
pub rearglow: Option<bool>, pub shutdown: bool,
#[options(meta = "", help = "<true/false>")]
pub lid: Option<bool>,
} }
// impl FromStr for AuraEnabled {
// type Err = Error;
// fn from_str(s: &str) -> Result<Self, Self::Err> {
// let s = s.to_lowercase();
// Ok(Self {
// help: false,
// keyboard: None,
// logo: None,
// lightbar: None,
// })
// }
// }
#[derive(Options)] #[derive(Options)]
pub struct LedBrightness { pub struct LedBrightness {
level: Option<u32>, level: Option<u32>,
+28 -71
View File
@@ -10,14 +10,15 @@ use gumdrop::{Opt, Options};
use profiles_cli::{FanCurveCommand, ProfileCommand}; use profiles_cli::{FanCurveCommand, ProfileCommand};
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::usb::{AuraDevRog1, AuraDevRog2, AuraDevTuf, AuraDevice, AuraPowerDev}; use rog_aura::power::KbAuraPowerState;
use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev};
use rog_aura::{self, AuraEffect}; use rog_aura::{self, AuraEffect};
use rog_dbus::RogDbusClientBlocking; use rog_dbus::RogDbusClientBlocking;
use rog_platform::platform::GpuMode; use rog_platform::platform::GpuMode;
use rog_platform::supported::*; use rog_platform::supported::*;
use rog_profiles::error::ProfileError; use rog_profiles::error::ProfileError;
use crate::aura_cli::LedBrightness; use crate::aura_cli::{AuraPowerStates, LedBrightness};
use crate::cli_opts::*; use crate::cli_opts::*;
mod anime_cli; mod anime_cli;
@@ -503,16 +504,14 @@ fn handle_led_power_1_do_1866(
check(power.lightbar, AuraDevRog1::Lightbar); check(power.lightbar, AuraDevRog1::Lightbar);
let data = AuraPowerDev { let data = AuraPowerDev {
x1866: enabled, old_rog: enabled,
x19b6: vec![], ..Default::default()
tuf: vec![],
}; };
dbus.proxies().led().set_led_power(data, true)?; dbus.proxies().led().set_led_power(data, true)?;
let data = AuraPowerDev { let data = AuraPowerDev {
x1866: disabled, old_rog: disabled,
x19b6: vec![], ..Default::default()
tuf: vec![],
}; };
dbus.proxies().led().set_led_power(data, false)?; dbus.proxies().led().set_led_power(data, false)?;
@@ -542,16 +541,14 @@ fn handle_led_power_1_do_tuf(
check(power.keyboard, AuraDevTuf::Keyboard); check(power.keyboard, AuraDevTuf::Keyboard);
let data = AuraPowerDev { let data = AuraPowerDev {
x1866: vec![],
x19b6: vec![],
tuf: enabled, tuf: enabled,
..Default::default()
}; };
dbus.proxies().led().set_led_power(data, true)?; dbus.proxies().led().set_led_power(data, true)?;
let data = AuraPowerDev { let data = AuraPowerDev {
x1866: vec![],
x19b6: vec![],
tuf: disabled, tuf: disabled,
..Default::default()
}; };
dbus.proxies().led().set_led_power(data, false)?; dbus.proxies().led().set_led_power(data, false)?;
@@ -591,66 +588,25 @@ fn handle_led_power2(
println!("This option applies only to keyboards with product ID 0x19b6"); println!("This option applies only to keyboards with product ID 0x19b6");
} }
let mut enabled: Vec<AuraDevRog2> = Vec::new(); let set = |power: &mut KbAuraPowerState, set_to: &AuraPowerStates| {
let mut disabled: Vec<AuraDevRog2> = Vec::new(); power.boot = set_to.boot;
let mut check = |e: Option<bool>, a: AuraDevRog2| { power.awake = set_to.awake;
if let Some(arg) = e { power.sleep = set_to.sleep;
if arg { power.shutdown = set_to.shutdown;
enabled.push(a);
} else {
disabled.push(a);
}
}
}; };
match pow { let mut enabled = dbus.proxies().led().led_power()?;
aura_cli::SetAuraEnabled::Boot(arg) => { if let Some(cmd) = &power.command {
check(arg.keyboard, AuraDevRog2::BootKeyb); match cmd {
check(arg.logo, AuraDevRog2::BootLogo); aura_cli::SetAuraZoneEnabled::Keyboard(k) => set(&mut enabled.rog.keyboard, k),
check(arg.frontglow, AuraDevRog2::BootBar); aura_cli::SetAuraZoneEnabled::Logo(l) => set(&mut enabled.rog.logo, l),
check(arg.rearglow, AuraDevRog2::BootRearGlow); aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(&mut enabled.rog.lightbar, l),
check(arg.lid, AuraDevRog2::AwakeLid); aura_cli::SetAuraZoneEnabled::Lid(l) => set(&mut enabled.rog.lid, l),
} aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(&mut enabled.rog.rear_glow, r),
aura_cli::SetAuraEnabled::Sleep(arg) => {
check(arg.keyboard, AuraDevRog2::SleepKeyb);
check(arg.logo, AuraDevRog2::SleepLogo);
check(arg.frontglow, AuraDevRog2::SleepBar);
check(arg.rearglow, AuraDevRog2::SleepRearGlow);
check(arg.lid, AuraDevRog2::SleepLid);
}
aura_cli::SetAuraEnabled::Awake(arg) => {
check(arg.keyboard, AuraDevRog2::AwakeKeyb);
check(arg.logo, AuraDevRog2::AwakeLogo);
check(arg.frontglow, AuraDevRog2::AwakeBar);
check(arg.rearglow, AuraDevRog2::AwakeRearGlow);
check(arg.lid, AuraDevRog2::AwakeLid);
}
aura_cli::SetAuraEnabled::Shutdown(arg) => {
check(arg.keyboard, AuraDevRog2::ShutdownKeyb);
check(arg.logo, AuraDevRog2::ShutdownLogo);
check(arg.frontglow, AuraDevRog2::ShutdownBar);
check(arg.rearglow, AuraDevRog2::ShutdownRearGlow);
check(arg.lid, AuraDevRog2::ShutdownLid);
} }
} }
if !enabled.is_empty() { dbus.proxies().led().set_led_power(enabled, true)?;
let data = AuraPowerDev {
tuf: vec![],
x1866: vec![],
x19b6: enabled,
};
dbus.proxies().led().set_led_power(data, true)?;
}
if !disabled.is_empty() {
let data = AuraPowerDev {
tuf: vec![],
x1866: vec![],
x19b6: disabled,
};
dbus.proxies().led().set_led_power(data, false)?;
}
} }
Ok(()) Ok(())
@@ -704,7 +660,7 @@ fn handle_fan_curve(
supported: &PlatformProfileFunctions, supported: &PlatformProfileFunctions,
cmd: &FanCurveCommand, cmd: &FanCurveCommand,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
if !supported.fan_curves { if supported.fans.is_empty() {
println!("Fan-curves not supported by either this kernel or by the laptop."); println!("Fan-curves not supported by either this kernel or by the laptop.");
println!("This requires kernel 5.17 or the fan curve patch listed in the readme."); println!("This requires kernel 5.17 or the fan curve patch listed in the readme.");
return Err(ProfileError::NotSupported.into()); return Err(ProfileError::NotSupported.into());
@@ -730,8 +686,9 @@ fn handle_fan_curve(
} }
if cmd.get_enabled { if cmd.get_enabled {
let res = dbus.proxies().profile().enabled_fan_profiles()?; // TODO:
println!("{:?}", res); // let res = dbus.proxies().profile().enabled_fan_profiles()?;
// println!("{:?}", res);
} }
if cmd.default { if cmd.default {
@@ -748,7 +705,7 @@ fn handle_fan_curve(
if let Some(enabled) = cmd.enabled { if let Some(enabled) = cmd.enabled {
dbus.proxies() dbus.proxies()
.profile() .profile()
.set_fan_curve_enabled(profile, enabled)?; .set_fan_curves_enabled(profile, enabled)?;
} }
if let Some(mut curve) = cmd.data.clone() { if let Some(mut curve) = cmd.data.clone() {
+2 -2
View File
@@ -34,12 +34,12 @@ pub struct FanCurveCommand {
pub mod_profile: Option<Profile>, pub mod_profile: Option<Profile>,
#[options( #[options(
meta = "", meta = "",
help = "enable or disable <true/false> fan curve. `mod-profile` required" help = "enable or disable <true/false> fan curve. `mod_profile` required"
)] )]
pub enabled: Option<bool>, pub enabled: Option<bool>,
#[options( #[options(
meta = "", meta = "",
help = "select fan <cpu/gpu> to modify. `mod-profile` required" help = "select fan <cpu/gpu/mid> to modify. `mod_profile` required"
)] )]
pub fan: Option<FanCurvePU>, pub fan: Option<FanCurvePU>,
+24 -41
View File
@@ -1,9 +1,12 @@
use std::collections::{BTreeMap, HashSet}; use std::collections::{BTreeMap, HashSet};
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use rog_aura::aura_detection::LaptopLedData; use log::warn;
use rog_aura::usb::{AuraDevRog1, AuraDevRog2, AuraDevTuf, AuraDevice, AuraPowerDev}; use rog_aura::aura_detection::{LaptopLedData, ASUS_KEYBOARD_DEVICES};
use rog_aura::power::AuraPower;
use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev};
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT}; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT};
use rog_platform::hid_raw::HidRaw;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
const CONFIG_FILE: &str = "aura.ron"; const CONFIG_FILE: &str = "aura.ron";
@@ -15,7 +18,7 @@ const CONFIG_FILE: &str = "aura.ron";
pub enum AuraPowerConfig { pub enum AuraPowerConfig {
AuraDevTuf(HashSet<AuraDevTuf>), AuraDevTuf(HashSet<AuraDevTuf>),
AuraDevRog1(HashSet<AuraDevRog1>), AuraDevRog1(HashSet<AuraDevRog1>),
AuraDevRog2(HashSet<AuraDevRog2>), AuraDevRog2(AuraPower),
} }
impl AuraPowerConfig { impl AuraPowerConfig {
@@ -27,10 +30,7 @@ impl AuraPowerConfig {
let c: Vec<AuraDevRog1> = c.iter().copied().collect(); let c: Vec<AuraDevRog1> = c.iter().copied().collect();
AuraDevRog1::to_bytes(&c) AuraDevRog1::to_bytes(&c)
} }
AuraPowerConfig::AuraDevRog2(c) => { AuraPowerConfig::AuraDevRog2(c) => c.to_bytes(),
let c: Vec<AuraDevRog2> = c.iter().copied().collect();
AuraDevRog2::to_bytes(&c)
}
} }
} }
@@ -78,13 +78,9 @@ impl AuraPowerConfig {
} }
} }
pub fn set_0x19b6(&mut self, power: AuraDevRog2, on: bool) { pub fn set_0x19b6(&mut self, power: AuraPower) {
if let Self::AuraDevRog2(p) = self { if let Self::AuraDevRog2(p) = self {
if on { *p = power;
p.insert(power);
} else {
p.remove(&power);
}
} }
} }
} }
@@ -94,18 +90,15 @@ impl From<&AuraPowerConfig> for AuraPowerDev {
match config { match config {
AuraPowerConfig::AuraDevTuf(d) => AuraPowerDev { AuraPowerConfig::AuraDevTuf(d) => AuraPowerDev {
tuf: d.iter().copied().collect(), tuf: d.iter().copied().collect(),
x1866: vec![], ..Default::default()
x19b6: vec![],
}, },
AuraPowerConfig::AuraDevRog1(d) => AuraPowerDev { AuraPowerConfig::AuraDevRog1(d) => AuraPowerDev {
tuf: vec![], old_rog: d.iter().copied().collect(),
x1866: d.iter().copied().collect(), ..Default::default()
x19b6: vec![],
}, },
AuraPowerConfig::AuraDevRog2(d) => AuraPowerDev { AuraPowerConfig::AuraDevRog2(d) => AuraPowerDev {
tuf: vec![], rog: d.clone(),
x1866: vec![], ..Default::default()
x19b6: d.iter().copied().collect(),
}, },
} }
} }
@@ -124,8 +117,15 @@ pub struct AuraConfig {
impl StdConfig for AuraConfig { impl StdConfig for AuraConfig {
fn new() -> Self { fn new() -> Self {
// Self::create_default(AuraDevice::X19b6, &LaptopLedData::get_data()) warn!("AuraConfig: creating new config");
panic!("AuraConfig::new() should not be used, use AuraConfig::create_default() instead"); let mut prod_id = AuraDevice::Unknown;
for prod in ASUS_KEYBOARD_DEVICES {
if HidRaw::new(prod.into()).is_ok() {
prod_id = prod;
break;
}
}
Self::create_default(prod_id, &LaptopLedData::get_data())
} }
fn config_dir() -> std::path::PathBuf { fn config_dir() -> std::path::PathBuf {
@@ -143,24 +143,7 @@ impl AuraConfig {
pub fn create_default(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self { pub fn create_default(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self {
// create a default config here // create a default config here
let enabled = if prod_id == AuraDevice::X19b6 { let enabled = if prod_id == AuraDevice::X19b6 {
AuraPowerConfig::AuraDevRog2(HashSet::from([ AuraPowerConfig::AuraDevRog2(AuraPower::new_all_on())
AuraDevRog2::BootLogo,
AuraDevRog2::BootKeyb,
AuraDevRog2::SleepLogo,
AuraDevRog2::SleepKeyb,
AuraDevRog2::AwakeLogo,
AuraDevRog2::AwakeKeyb,
AuraDevRog2::ShutdownLogo,
AuraDevRog2::ShutdownKeyb,
AuraDevRog2::BootBar,
AuraDevRog2::AwakeBar,
AuraDevRog2::SleepBar,
AuraDevRog2::ShutdownBar,
AuraDevRog2::BootRearGlow,
AuraDevRog2::AwakeRearGlow,
AuraDevRog2::SleepRearGlow,
AuraDevRog2::ShutdownRearGlow,
]))
} else if prod_id == AuraDevice::Tuf { } else if prod_id == AuraDevice::Tuf {
AuraPowerConfig::AuraDevTuf(HashSet::from([ AuraPowerConfig::AuraDevTuf(HashSet::from([
AuraDevTuf::Awake, AuraDevTuf::Awake,
+3 -46
View File
@@ -53,48 +53,7 @@ impl CtrlKbdLedZbus {
/// Set a variety of states, input is array of enum. /// Set a variety of states, input is array of enum.
/// `enabled` sets if the sent array should be disabled or enabled /// `enabled` sets if the sent array should be disabled or enabled
/// ///
/// ```text /// For Modern ROG devices the "enabled" flag is ignored.
/// pub struct AuraPowerDev {
/// tuf: Vec<AuraDevTuf>,
/// x1866: Vec<AuraDevRog1>,
/// x19b6: Vec<AuraDevRog2>,
/// }
/// pub enum AuraDevTuf {
/// Boot,
/// Awake,
/// Sleep,
/// Keyboard,
/// }
/// pub enum AuraDevRog1 {
/// Awake = 0x000002,
/// Keyboard = 0x080000,
/// Lightbar = 0x040500,
/// Boot = 0xc31209,
/// Sleep = 0x300804,
/// }
/// pub enum AuraDevRog2 {
/// BootLogo = 1,
/// BootKeyb = 1 << 1,
/// AwakeLogo = 1 << 2,
/// AwakeKeyb = 1 << 3,
/// SleepLogo = 1 << 4,
/// SleepKeyb = 1 << 5,
/// ShutdownLogo = 1 << 6,
/// ShutdownKeyb = 1 << 7,
/// BootBar = 1 << (7 + 2),
/// AwakeBar = 1 << (7 + 3),
/// SleepBar = 1 << (7 + 4),
/// ShutdownBar = 1 << (7 + 5),
/// BootLid = 1 << (15 + 1),
/// AwakeLid = 1 << (15 + 2),
/// SleepLid = 1 << (15 + 3),
/// ShutdownLid = 1 << (15 + 4),
/// BootRearGlow = 1 << (23 + 1),
/// AwakeRearGlow = 1 << (23 + 2),
/// SleepRearGlow = 1 << (23 + 3),
/// ShutdownRearGlow = 1 << (23 + 4),
/// }
/// ```
async fn set_led_power( async fn set_led_power(
&mut self, &mut self,
#[zbus(signal_context)] ctxt: SignalContext<'_>, #[zbus(signal_context)] ctxt: SignalContext<'_>,
@@ -105,12 +64,10 @@ impl CtrlKbdLedZbus {
for p in options.tuf { for p in options.tuf {
ctrl.config.enabled.set_tuf(p, enabled); ctrl.config.enabled.set_tuf(p, enabled);
} }
for p in options.x1866 { for p in options.old_rog {
ctrl.config.enabled.set_0x1866(p, enabled); ctrl.config.enabled.set_0x1866(p, enabled);
} }
for p in options.x19b6 { ctrl.config.enabled.set_0x19b6(options.rog);
ctrl.config.enabled.set_0x19b6(p, enabled);
}
ctrl.config.write(); ctrl.config.write();
+4 -4
View File
@@ -1,7 +1,7 @@
use std::path::PathBuf; use std::path::PathBuf;
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use rog_profiles::fan_curve_set::FanCurveSet; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::Profile; use rog_profiles::Profile;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
@@ -36,9 +36,9 @@ impl StdConfigLoad for ProfileConfig {}
#[derive(Deserialize, Serialize, Debug, Default)] #[derive(Deserialize, Serialize, Debug, Default)]
pub struct FanCurveConfig { pub struct FanCurveConfig {
pub balanced: FanCurveSet, pub balanced: Vec<CurveData>,
pub performance: FanCurveSet, pub performance: Vec<CurveData>,
pub quiet: FanCurveSet, pub quiet: Vec<CurveData>,
} }
impl StdConfig for FanCurveConfig { impl StdConfig for FanCurveConfig {
+7 -11
View File
@@ -56,13 +56,9 @@ impl GetSupported for CtrlPlatformProfile {
); );
} }
let res = FanCurveProfiles::is_supported(); let res = FanCurveProfiles::supported_fans();
let mut fan_curve_supported = res.is_err();
if let Ok(r) = res {
fan_curve_supported = r;
};
if !fan_curve_supported { if res.is_err() {
info!( info!(
"fan curves kernel interface not found, your laptop does not support this, or the \ "fan curves kernel interface not found, your laptop does not support this, or the \
interface is missing." interface is missing."
@@ -71,7 +67,7 @@ impl GetSupported for CtrlPlatformProfile {
PlatformProfileFunctions { PlatformProfileFunctions {
platform_profile: Profile::is_platform_profile_supported(), platform_profile: Profile::is_platform_profile_supported(),
fan_curves: fan_curve_supported, fans: res.unwrap_or_default(),
} }
} }
} }
@@ -113,10 +109,10 @@ impl CtrlPlatformProfile {
let active = Profile::get_active_profile().unwrap_or(Profile::Balanced); let active = Profile::get_active_profile().unwrap_or(Profile::Balanced);
if let Some(curves) = controller.fan_curves.as_ref() { if let Some(curves) = controller.fan_curves.as_ref() {
info!( info!("{MOD_NAME}: {active:?}:");
"{MOD_NAME}: {active:?}: {}", for curve in curves.profiles().get_fan_curves_for(active) {
String::from(curves.profiles().get_fan_curves_for(active)) info!("{}", String::from(curve));
); }
} }
} }
if let Some(curves) = controller.fan_curves.as_ref() { if let Some(curves) = controller.fan_curves.as_ref() {
+34 -18
View File
@@ -4,8 +4,8 @@ use std::sync::Arc;
use async_trait::async_trait; use async_trait::async_trait;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{error, info, warn}; use log::{error, info, warn};
use rog_profiles::fan_curve_set::{CurveData, FanCurveSet}; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::{FanCurveProfiles, Profile}; use rog_profiles::{FanCurvePU, FanCurveProfiles, Profile};
use zbus::export::futures_util::lock::Mutex; use zbus::export::futures_util::lock::Mutex;
use zbus::export::futures_util::StreamExt; use zbus::export::futures_util::StreamExt;
use zbus::fdo::Error; use zbus::fdo::Error;
@@ -83,19 +83,9 @@ impl ProfileZbus {
.ok(); .ok();
} }
/// Get a list of profiles that have fan-curves enabled. /// Set all fan curves for a profile to enabled status. Will also activate a
async fn enabled_fan_profiles(&mut self) -> zbus::fdo::Result<Vec<Profile>> { /// fan curve if in the same profile mode
let mut ctrl = self.0.lock().await; async fn set_fan_curves_enabled(
ctrl.profile_config.read();
if let Some(curves) = &mut ctrl.fan_curves {
return Ok(curves.profiles().get_enabled_curve_profiles());
}
Err(Error::Failed(UNSUPPORTED_MSG.to_owned()))
}
/// Set a profile fan curve enabled status. Will also activate a fan curve
/// if in the same profile mode
async fn set_fan_curve_enabled(
&mut self, &mut self,
profile: Profile, profile: Profile,
enabled: bool, enabled: bool,
@@ -105,7 +95,33 @@ impl ProfileZbus {
if let Some(curves) = &mut ctrl.fan_curves { if let Some(curves) = &mut ctrl.fan_curves {
curves curves
.profiles_mut() .profiles_mut()
.set_profile_curve_enabled(profile, enabled); .set_profile_curves_enabled(profile, enabled);
ctrl.write_profile_curve_to_platform()
.map_err(|e| warn!("{MOD_NAME}: write_profile_curve_to_platform, {}", e))
.ok();
ctrl.save_config();
Ok(())
} else {
Err(Error::Failed(UNSUPPORTED_MSG.to_owned()))
}
}
/// Set a single fan curve for a profile to enabled status. Will also
/// activate a fan curve if in the same profile mode
async fn set_profile_fan_curve_enabled(
&mut self,
profile: Profile,
fan: FanCurvePU,
enabled: bool,
) -> zbus::fdo::Result<()> {
let mut ctrl = self.0.lock().await;
ctrl.profile_config.read();
if let Some(curves) = &mut ctrl.fan_curves {
curves
.profiles_mut()
.set_profile_fan_curve_enabled(profile, fan, enabled);
ctrl.write_profile_curve_to_platform() ctrl.write_profile_curve_to_platform()
.map_err(|e| warn!("{MOD_NAME}: write_profile_curve_to_platform, {}", e)) .map_err(|e| warn!("{MOD_NAME}: write_profile_curve_to_platform, {}", e))
@@ -119,12 +135,12 @@ impl ProfileZbus {
} }
/// Get the fan-curve data for the currently active Profile /// Get the fan-curve data for the currently active Profile
async fn fan_curve_data(&mut self, profile: Profile) -> zbus::fdo::Result<FanCurveSet> { async fn fan_curve_data(&mut self, profile: Profile) -> zbus::fdo::Result<Vec<CurveData>> {
let mut ctrl = self.0.lock().await; let mut ctrl = self.0.lock().await;
ctrl.profile_config.read(); ctrl.profile_config.read();
if let Some(curves) = &mut ctrl.fan_curves { if let Some(curves) = &mut ctrl.fan_curves {
let curve = curves.profiles().get_fan_curves_for(profile); let curve = curves.profiles().get_fan_curves_for(profile);
return Ok(curve.clone()); return Ok(curve.to_vec());
} }
Err(Error::Failed(UNSUPPORTED_MSG.to_owned())) Err(Error::Failed(UNSUPPORTED_MSG.to_owned()))
} }
+4 -45
View File
@@ -11,51 +11,10 @@
Set a variety of states, input is array of enum. Set a variety of states, input is array of enum.
`enabled` sets if the sent array should be disabled or enabled `enabled` sets if the sent array should be disabled or enabled
```text For Modern ROG devices the "enabled" flag is ignored.
pub struct AuraPowerDev {
tuf: Vec<AuraDevTuf>,
x1866: Vec<AuraDevRog1>,
x19b6: Vec<AuraDevRog2>,
}
pub enum AuraDevTuf {
Boot,
Awake,
Sleep,
Keyboard,
}
pub enum AuraDevRog1 {
Awake = 0x000002,
Keyboard = 0x080000,
Lightbar = 0x040500,
Boot = 0xc31209,
Sleep = 0x300804,
}
pub enum AuraDevRog2 {
BootLogo = 1,
BootKeyb = 1 << 1,
AwakeLogo = 1 << 2,
AwakeKeyb = 1 << 3,
SleepLogo = 1 << 4,
SleepKeyb = 1 << 5,
ShutdownLogo = 1 << 6,
ShutdownKeyb = 1 << 7,
BootBar = 1 << (7 + 2),
AwakeBar = 1 << (7 + 3),
SleepBar = 1 << (7 + 4),
ShutdownBar = 1 << (7 + 5),
BootLid = 1 << (15 + 1),
AwakeLid = 1 << (15 + 2),
SleepLid = 1 << (15 + 3),
ShutdownLid = 1 << (15 + 4),
BootRearGlow = 1 << (23 + 1),
AwakeRearGlow = 1 << (23 + 2),
SleepRearGlow = 1 << (23 + 3),
ShutdownRearGlow = 1 << (23 + 4),
}
```
--> -->
<method name="SetLedPower"> <method name="SetLedPower">
<arg name="options" type="(asasas)" direction="in"/> <arg name="options" type="(asas((sbbbb)(sbbbb)(sbbbb)(sbbbb)(sbbbb)))" direction="in"/>
<arg name="enabled" type="b" direction="in"/> <arg name="enabled" type="b" direction="in"/>
</method> </method>
<method name="SetLedMode"> <method name="SetLedMode">
@@ -76,7 +35,7 @@
<arg type="s" direction="out"/> <arg type="s" direction="out"/>
</method> </method>
<method name="LedPower"> <method name="LedPower">
<arg type="asasas" direction="out"/> <arg type="asas((sbbbb)(sbbbb)(sbbbb)(sbbbb)(sbbbb))" direction="out"/>
</method> </method>
<!-- <!--
Return the current mode data Return the current mode data
@@ -102,7 +61,7 @@
<arg name="data" type="(ss(yyy)(yyy)ss)"/> <arg name="data" type="(ss(yyy)(yyy)ss)"/>
</signal> </signal>
<signal name="NotifyPowerStates"> <signal name="NotifyPowerStates">
<arg name="data" type="(asasas)"/> <arg name="data" type="(asas((sbbbb)(sbbbb)(sbbbb)(sbbbb)(sbbbb)))"/>
</signal> </signal>
<!-- <!--
Return the current LED brightness Return the current LED brightness
+69 -65
View File
@@ -107,6 +107,64 @@ export interface AuraEffect {
direction: Direction; direction: Direction;
} }
/** The powerr zones this laptop supports */
export enum PowerZones {
/** The logo on some laptop lids */
Logo = "Logo",
/** The full keyboard (not zones) */
Keyboard = "Keyboard",
/** The lightbar, typically on the front of the laptop */
Lightbar = "Lightbar",
/** The leds that may be placed around the edge of the laptop lid */
Lid = "Lid",
/** The led strip on the rear of some laptops */
RearGlow = "RearGlow",
}
export interface KbAuraPowerState {
zone: PowerZones;
boot: boolean;
awake: boolean;
sleep: boolean;
shutdown: boolean;
}
/**
* Track and control the Aura keyboard power state
*
* # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models
*
* | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label |
* |--------|---------|---------|---------|----------|
* |00000001| 00000000| 00000000| 00000000|boot_logo_|
* |00000010| 00000000| 00000000| 00000000|boot_keyb_|
* |00000100| 00000000| 00000000| 00000000|awake_logo|
* |00001000| 00000000| 00000000| 00000000|awake_keyb|
* |00010000| 00000000| 00000000| 00000000|sleep_logo|
* |00100000| 00000000| 00000000| 00000000|sleep_keyb|
* |01000000| 00000000| 00000000| 00000000|shut_logo_|
* |10000000| 00000000| 00000000| 00000000|shut_keyb_|
* |00000000| 00000010| 00000000| 00000000|boot_bar__|
* |00000000| 00000100| 00000000| 00000000|awake_bar_|
* |00000000| 00001000| 00000000| 00000000|sleep_bar_|
* |00000000| 00010000| 00000000| 00000000|shut_bar__|
* |00000000| 00000000| 00000001| 00000000|boot_lid__|
* |00000000| 00000000| 00000010| 00000000|awkae_lid_|
* |00000000| 00000000| 00000100| 00000000|sleep_lid_|
* |00000000| 00000000| 00001000| 00000000|shut_lid__|
* |00000000| 00000000| 00000000| 00000001|boot_rear_|
* |00000000| 00000000| 00000000| 00000010|awake_rear|
* |00000000| 00000000| 00000000| 00000100|sleep_rear|
* |00000000| 00000000| 00000000| 00001000|shut_rear_|
*/
export interface AuraPower {
keyboard: KbAuraPowerState;
logo: KbAuraPowerState;
lightbar: KbAuraPowerState;
lid: KbAuraPowerState;
rear_glow: KbAuraPowerState;
}
export enum AuraDevTuf { export enum AuraDevTuf {
Boot = "Boot", Boot = "Boot",
Awake = "Awake", Awake = "Awake",
@@ -138,74 +196,20 @@ export enum AuraDevRog1 {
Sleep = "Sleep", Sleep = "Sleep",
} }
/**
* # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models
*
* | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label |
* |--------|---------|---------|---------|----------|
* |00000001| 00000000| 00000000| 00000000|boot_logo_|
* |00000010| 00000000| 00000000| 00000000|boot_keyb_|
* |00000100| 00000000| 00000000| 00000000|awake_logo|
* |00001000| 00000000| 00000000| 00000000|awake_keyb|
* |00010000| 00000000| 00000000| 00000000|sleep_logo|
* |00100000| 00000000| 00000000| 00000000|sleep_keyb|
* |01000000| 00000000| 00000000| 00000000|shut_logo_|
* |10000000| 00000000| 00000000| 00000000|shut_keyb_|
* |00000000| 00000010| 00000000| 00000000|boot_bar__|
* |00000000| 00000100| 00000000| 00000000|awake_bar_|
* |00000000| 00001000| 00000000| 00000000|sleep_bar_|
* |00000000| 00010000| 00000000| 00000000|shut_bar__|
* |00000000| 00000000| 00000001| 00000000|boot_lid__|
* |00000000| 00000000| 00000010| 00000000|awkae_lid_|
* |00000000| 00000000| 00000100| 00000000|sleep_lid_|
* |00000000| 00000000| 00001000| 00000000|shut_lid__|
* |00000000| 00000000| 00000000| 00000001|boot_rear_|
* |00000000| 00000000| 00000000| 00000010|awake_rear|
* |00000000| 00000000| 00000000| 00000100|sleep_rear|
* |00000000| 00000000| 00000000| 00001000|shut_rear_|
*/
export enum AuraDevRog2 {
BootLogo = "BootLogo",
BootKeyb = "BootKeyb",
AwakeLogo = "AwakeLogo",
AwakeKeyb = "AwakeKeyb",
SleepLogo = "SleepLogo",
SleepKeyb = "SleepKeyb",
ShutdownLogo = "ShutdownLogo",
ShutdownKeyb = "ShutdownKeyb",
BootBar = "BootBar",
AwakeBar = "AwakeBar",
SleepBar = "SleepBar",
ShutdownBar = "ShutdownBar",
BootLid = "BootLid",
AwakeLid = "AwakeLid",
SleepLid = "SleepLid",
ShutdownLid = "ShutdownLid",
BootRearGlow = "BootRearGlow",
AwakeRearGlow = "AwakeRearGlow",
SleepRearGlow = "SleepRearGlow",
ShutdownRearGlow = "ShutdownRearGlow",
}
/** This struct is intended as a helper to pass args to generic dbus interface */ /** This struct is intended as a helper to pass args to generic dbus interface */
export interface AuraPowerDev { export interface AuraPowerDev {
/**
* TUF laptops use a similar style of control to the older ROG devices but
* through WMI
*/
tuf: AuraDevTuf[]; tuf: AuraDevTuf[];
x1866: AuraDevRog1[]; /**
x19b6: AuraDevRog2[]; * Pre-0x19b6 devices use a different smaller scheme to the newer ROG
} * devices
*/
/** The powerr zones this laptop supports */ old_rog: AuraDevRog1[];
export enum PowerZones { /** ASUS standardised control scheme from 2020 onwards */
/** The logo on some laptop lids */ rog: AuraPower;
Logo = "Logo",
/** The full keyboard (not zones) */
Keyboard = "Keyboard",
/** The lightbar, typically on the front of the laptop */
Lightbar = "Lightbar",
/** The leds that may be placed around the edge of the laptop lid */
Lid = "Lid",
/** The led strip on the rear of some laptops */
RearGlow = "RearGlow",
} }
export enum LedBrightness { export enum LedBrightness {
@@ -1,4 +1,4 @@
import { AuraDevRog1, AuraDevRog2, AuraDevTuf, AuraDevice, AuraEffect, AuraModeNum, AuraPowerDev, AuraZone, Direction, Speed } from "../../bindings/aura"; import { AuraDevRog1, AuraDevTuf, AuraDevice, AuraEffect, AuraModeNum, AuraPower, AuraPowerDev, AuraZone, Direction, PowerZones, Speed } from "../../bindings/aura";
import { DbusBase } from "./base"; import { DbusBase } from "./base";
export class AuraDbus extends DbusBase { export class AuraDbus extends DbusBase {
@@ -7,8 +7,44 @@ export class AuraDbus extends DbusBase {
public aura_modes: Map<AuraModeNum, AuraEffect> = new Map; public aura_modes: Map<AuraModeNum, AuraEffect> = new Map;
public leds_powered: AuraPowerDev = { public leds_powered: AuraPowerDev = {
tuf: [], tuf: [],
x1866: [], old_rog: [],
x19b6: [] rog: {
keyboard: {
zone: PowerZones.Keyboard,
boot: false,
awake: false,
sleep: false,
shutdown: false
},
logo: {
zone: PowerZones.Logo,
boot: false,
awake: false,
sleep: false,
shutdown: false
},
lightbar: {
zone: PowerZones.Lightbar,
boot: false,
awake: false,
sleep: false,
shutdown: false
},
lid: {
zone: PowerZones.Lid,
boot: false,
awake: false,
sleep: false,
shutdown: false
},
rear_glow: {
zone: PowerZones.RearGlow,
boot: false,
awake: false,
sleep: false,
shutdown: false
},
}
}; };
// TODO: interface or something to enforce requirement of "sync()" method // TODO: interface or something to enforce requirement of "sync()" method
public notifyAuraModeSubscribers: any[] = []; public notifyAuraModeSubscribers: any[] = [];
@@ -32,21 +68,51 @@ export class AuraDbus extends DbusBase {
} }
_parsePowerStates(data: any[]) { _parsePowerStates(data: any[]) {
const power: AuraPowerDev = { const power: AuraPowerDev = this.leds_powered;
tuf: [],
x1866: [],
x19b6: []
};
power.tuf = data[0].map((value: string) => { power.tuf = data[0].map((value: string) => {
return AuraDevTuf[value as AuraDevTuf]; return AuraDevTuf[value as AuraDevTuf];
}); });
power.x1866 = data[1].map((value: string) => { power.old_rog = data[1].map((value: string) => {
return AuraDevRog1[value as AuraDevRog1]; return AuraDevRog1[value as AuraDevRog1];
}); });
power.x19b6 = data[2].map((value: string) => { power.rog = {
return AuraDevRog2[value as AuraDevRog2]; keyboard: {
}); zone: PowerZones[data[2][0][0] as PowerZones],
boot: data[2][0][1],
awake: data[2][0][2],
sleep: data[2][0][3],
shutdown: data[2][0][4]
},
logo: {
zone: PowerZones[data[2][1][0] as PowerZones],
boot: data[2][1][1],
awake: data[2][1][2],
sleep: data[2][1][3],
shutdown: data[2][1][4]
},
lightbar: {
zone: PowerZones[data[2][2][0] as PowerZones],
boot: data[2][2][1],
awake: data[2][2][2],
sleep: data[2][2][3],
shutdown: data[2][2][4]
},
lid: {
zone: PowerZones[data[2][3][0] as PowerZones],
boot: data[2][3][1],
awake: data[2][3][2],
sleep: data[2][3][3],
shutdown: data[2][3][4]
},
rear_glow: {
zone: PowerZones[data[2][4][0] as PowerZones],
boot: data[2][4][1],
awake: data[2][4][2],
sleep: data[2][4][3],
shutdown: data[2][4][4]
}
};
return power; return power;
} }
@@ -59,9 +125,9 @@ export class AuraDbus extends DbusBase {
//@ts-ignore //@ts-ignore
log("LED power tuf: " + this.leds_powered.tuf); log("LED power tuf: " + this.leds_powered.tuf);
//@ts-ignore //@ts-ignore
log("LED power x1866: " + this.leds_powered.x1866); log("LED power x1866: " + this.leds_powered.old_rog);
//@ts-ignore //@ts-ignore
log("LED power x19b6: " + this.leds_powered.x19b6); log("LED power x19b6: " + this.leds_powered.rog);
} catch (e) { } catch (e) {
//@ts-ignore //@ts-ignore
log("Failed to fetch supported functionalities", e); log("Failed to fetch supported functionalities", e);
@@ -180,26 +246,26 @@ export class AuraDbus extends DbusBase {
const power: AuraPowerDev = this._parsePowerStates(data[0]); const power: AuraPowerDev = this._parsePowerStates(data[0]);
this.leds_powered = power; this.leds_powered = power;
switch (this.device) { switch (this.device) {
case AuraDevice.Tuf: case AuraDevice.Tuf:
//@ts-ignore //@ts-ignore
log("LED power has changed to ", this.leds_powered.tuf); log("LED power has changed to ", this.leds_powered.tuf);
break; break;
case AuraDevice.X1854: case AuraDevice.X1854:
case AuraDevice.X1869: case AuraDevice.X1869:
case AuraDevice.X18c6: case AuraDevice.X18c6:
//@ts-ignore //@ts-ignore
log("LED power has changed to ", this.leds_powered.x1866); log("LED power has changed to ", this.leds_powered.old_rog);
break; break;
case AuraDevice.X19b6: case AuraDevice.X19b6:
case AuraDevice.X1a30: case AuraDevice.X1a30:
//@ts-ignore //@ts-ignore
log("LED power has changed to ", this.leds_powered.x19b6); log("LED power has changed to ", this.leds_powered.rog);
break; break;
default: default:
break; break;
} }
//@ts-ignore //@ts-ignore
log("LED power has changed to ", this.leds_powered.x19b6); log("LED power has changed to ", this.leds_powered.rog);
this.notifyAuraPowerSubscribers.forEach(sub => { this.notifyAuraPowerSubscribers.forEach(sub => {
sub.sync(); sub.sync();
}); });
+16
View File
@@ -31,6 +31,14 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
board_name: "FX505G",
layout_name: "fx505d",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
( (
board_name: "FX506H", board_name: "FX506H",
layout_name: "fa506i", layout_name: "fa506i",
@@ -375,6 +383,14 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
board_name: "GA402X",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse, Rainbow],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
( (
board_name: "GA503Q", board_name: "GA503Q",
layout_name: "ga401q", layout_name: "ga401q",
+1 -1
View File
@@ -24,7 +24,7 @@ pub struct LedSupportFile(Vec<LaptopLedData>);
/// The powerr zones this laptop supports /// The powerr zones this laptop supports
#[typeshare] #[typeshare]
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))] #[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Clone)] #[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Copy, Clone)]
pub enum PowerZones { pub enum PowerZones {
/// The logo on some laptop lids /// The logo on some laptop lids
#[default] #[default]
+162
View File
@@ -0,0 +1,162 @@
//! Older code that is not useful but stillr elevant as a reference
/// # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models
///
/// | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label |
/// |--------|---------|---------|---------|----------|
/// |00000001| 00000000| 00000000| 00000000|boot_logo_|
/// |00000010| 00000000| 00000000| 00000000|boot_keyb_|
/// |00000100| 00000000| 00000000| 00000000|awake_logo|
/// |00001000| 00000000| 00000000| 00000000|awake_keyb|
/// |00010000| 00000000| 00000000| 00000000|sleep_logo|
/// |00100000| 00000000| 00000000| 00000000|sleep_keyb|
/// |01000000| 00000000| 00000000| 00000000|shut_logo_|
/// |10000000| 00000000| 00000000| 00000000|shut_keyb_|
/// |00000000| 00000010| 00000000| 00000000|boot_bar__|
/// |00000000| 00000100| 00000000| 00000000|awake_bar_|
/// |00000000| 00001000| 00000000| 00000000|sleep_bar_|
/// |00000000| 00010000| 00000000| 00000000|shut_bar__|
/// |00000000| 00000000| 00000001| 00000000|boot_lid__|
/// |00000000| 00000000| 00000010| 00000000|awkae_lid_|
/// |00000000| 00000000| 00000100| 00000000|sleep_lid_|
/// |00000000| 00000000| 00001000| 00000000|shut_lid__|
/// |00000000| 00000000| 00000000| 00000001|boot_rear_|
/// |00000000| 00000000| 00000000| 00000010|awake_rear|
/// |00000000| 00000000| 00000000| 00000100|sleep_rear|
/// |00000000| 00000000| 00000000| 00001000|shut_rear_|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[repr(u32)]
pub enum AuraDevRog2 {
BootLogo = 1,
BootKeyb = 1 << 1,
AwakeLogo = 1 << 2,
AwakeKeyb = 1 << 3,
SleepLogo = 1 << 4,
SleepKeyb = 1 << 5,
ShutdownLogo = 1 << 6,
ShutdownKeyb = 1 << 7,
BootBar = 1 << (7 + 2),
AwakeBar = 1 << (7 + 3),
SleepBar = 1 << (7 + 4),
ShutdownBar = 1 << (7 + 5),
BootLid = 1 << (15 + 1),
AwakeLid = 1 << (15 + 2),
SleepLid = 1 << (15 + 3),
ShutdownLid = 1 << (15 + 4),
BootRearGlow = 1 << (23 + 1),
AwakeRearGlow = 1 << (23 + 2),
SleepRearGlow = 1 << (23 + 3),
ShutdownRearGlow = 1 << (23 + 4),
}
impl From<AuraDevRog2> for u32 {
fn from(a: AuraDevRog2) -> Self {
a as u32
}
}
impl AuraDevRog2 {
pub fn to_bytes(control: &[Self]) -> [u8; 4] {
let mut a: u32 = 0;
for n in control {
a |= *n as u32;
}
[
(a & 0xff) as u8,
((a & 0xff00) >> 8) as u8,
((a & 0xff0000) >> 16) as u8,
((a & 0xff000000) >> 24) as u8,
]
}
pub const fn dev_id() -> &'static str {
"0x196b"
}
}
#[cfg(test)]
mod tests {
use crate::deprecated::AuraDevRog2;
#[test]
fn check_0x19b6_control_bytes_binary_rep() {
fn to_binary_string(bytes: &[AuraDevRog2]) -> String {
let bytes = AuraDevRog2::to_bytes(bytes);
format!(
"{:08b}, {:08b}, {:08b}, {:08b}",
bytes[0], bytes[1], bytes[2], bytes[3]
)
}
let boot_logo_ = to_binary_string(&[AuraDevRog2::BootLogo]);
let boot_keyb_ = to_binary_string(&[AuraDevRog2::BootKeyb]);
let sleep_logo = to_binary_string(&[AuraDevRog2::SleepLogo]);
let sleep_keyb = to_binary_string(&[AuraDevRog2::SleepKeyb]);
let awake_logo = to_binary_string(&[AuraDevRog2::AwakeLogo]);
let awake_keyb = to_binary_string(&[AuraDevRog2::AwakeKeyb]);
let shut_logo_ = to_binary_string(&[AuraDevRog2::ShutdownLogo]);
let shut_keyb_ = to_binary_string(&[AuraDevRog2::ShutdownKeyb]);
let boot_bar__ = to_binary_string(&[AuraDevRog2::BootBar]);
let awake_bar_ = to_binary_string(&[AuraDevRog2::AwakeBar]);
let sleep_bar_ = to_binary_string(&[AuraDevRog2::SleepBar]);
let shut_bar__ = to_binary_string(&[AuraDevRog2::ShutdownBar]);
let boot_lid__ = to_binary_string(&[AuraDevRog2::BootLid]);
let awkae_lid_ = to_binary_string(&[AuraDevRog2::AwakeLid]);
let sleep_lid_ = to_binary_string(&[AuraDevRog2::SleepLid]);
let shut_lid__ = to_binary_string(&[AuraDevRog2::ShutdownLid]);
let boot_rear_ = to_binary_string(&[AuraDevRog2::BootRearGlow]);
let awake_rear = to_binary_string(&[AuraDevRog2::AwakeRearGlow]);
let sleep_rear = to_binary_string(&[AuraDevRog2::SleepRearGlow]);
let shut_rear_ = to_binary_string(&[AuraDevRog2::ShutdownRearGlow]);
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
assert_eq!(boot_keyb_, "00000010, 00000000, 00000000, 00000000");
assert_eq!(awake_logo, "00000100, 00000000, 00000000, 00000000");
assert_eq!(awake_keyb, "00001000, 00000000, 00000000, 00000000");
assert_eq!(sleep_logo, "00010000, 00000000, 00000000, 00000000");
assert_eq!(sleep_keyb, "00100000, 00000000, 00000000, 00000000");
assert_eq!(shut_logo_, "01000000, 00000000, 00000000, 00000000");
assert_eq!(shut_keyb_, "10000000, 00000000, 00000000, 00000000");
//
assert_eq!(boot_bar__, "00000000, 00000010, 00000000, 00000000");
assert_eq!(awake_bar_, "00000000, 00000100, 00000000, 00000000");
assert_eq!(sleep_bar_, "00000000, 00001000, 00000000, 00000000");
assert_eq!(shut_bar__, "00000000, 00010000, 00000000, 00000000");
//
assert_eq!(boot_lid__, "00000000, 00000000, 00000001, 00000000");
assert_eq!(awkae_lid_, "00000000, 00000000, 00000010, 00000000");
assert_eq!(sleep_lid_, "00000000, 00000000, 00000100, 00000000");
assert_eq!(shut_lid__, "00000000, 00000000, 00001000, 00000000");
//
assert_eq!(boot_rear_, "00000000, 00000000, 00000000, 00000001");
assert_eq!(awake_rear, "00000000, 00000000, 00000000, 00000010");
assert_eq!(sleep_rear, "00000000, 00000000, 00000000, 00000100");
assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000");
// All on
let byte1 = [
AuraDevRog2::BootLogo,
AuraDevRog2::BootKeyb,
AuraDevRog2::SleepLogo,
AuraDevRog2::SleepKeyb,
AuraDevRog2::AwakeLogo,
AuraDevRog2::AwakeKeyb,
AuraDevRog2::ShutdownLogo,
AuraDevRog2::ShutdownKeyb,
AuraDevRog2::BootBar,
AuraDevRog2::AwakeBar,
AuraDevRog2::SleepBar,
AuraDevRog2::ShutdownBar,
AuraDevRog2::AwakeLid,
AuraDevRog2::BootLid,
AuraDevRog2::SleepLid,
AuraDevRog2::ShutdownLid,
AuraDevRog2::AwakeRearGlow,
AuraDevRog2::BootRearGlow,
AuraDevRog2::SleepRearGlow,
AuraDevRog2::ShutdownRearGlow,
];
let out = to_binary_string(&byte1);
assert_eq!(out, "11111111, 00011110, 00001111, 00001111");
}
}
+4
View File
@@ -18,6 +18,10 @@ pub mod aura_detection;
pub mod layouts; pub mod layouts;
pub mod usb; pub mod usb;
pub mod power;
mod deprecated;
pub const LED_MSG_LEN: usize = 17; pub const LED_MSG_LEN: usize = 17;
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");
+343
View File
@@ -0,0 +1,343 @@
use std::fmt::Debug;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")]
use zbus::zvariant::Type;
use crate::aura_detection::PowerZones;
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct KbAuraPowerState {
pub zone: PowerZones,
pub boot: bool,
pub awake: bool,
pub sleep: bool,
pub shutdown: bool,
}
impl Default for KbAuraPowerState {
fn default() -> Self {
Self {
zone: PowerZones::Keyboard,
boot: false,
awake: false,
sleep: false,
shutdown: false,
}
}
}
impl KbAuraPowerState {
pub fn to_byte(&self, zone: PowerZones) -> u32 {
match zone {
PowerZones::Logo => {
self.boot as u32
| (self.awake as u32) << 2
| (self.sleep as u32) << 4
| (self.shutdown as u32) << 6
}
PowerZones::Keyboard => {
(self.boot as u32) << 1
| (self.awake as u32) << 3
| (self.sleep as u32) << 5
| (self.shutdown as u32) << 7
}
PowerZones::Lightbar => {
(self.boot as u32) << (7 + 2)
| (self.awake as u32) << (7 + 3)
| (self.sleep as u32) << (7 + 4)
| (self.shutdown as u32) << (7 + 5)
}
PowerZones::Lid => {
(self.boot as u32) << (15 + 1)
| (self.awake as u32) << (15 + 2)
| (self.sleep as u32) << (15 + 3)
| (self.shutdown as u32) << (15 + 4)
}
PowerZones::RearGlow => {
(self.boot as u32) << (23 + 1)
| (self.awake as u32) << (23 + 2)
| (self.sleep as u32) << (23 + 3)
| (self.shutdown as u32) << (23 + 4)
}
}
}
}
/// Track and control the Aura keyboard power state
///
/// # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models
///
/// | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label |
/// |--------|---------|---------|---------|----------|
/// |00000001| 00000000| 00000000| 00000000|boot_logo_|
/// |00000010| 00000000| 00000000| 00000000|boot_keyb_|
/// |00000100| 00000000| 00000000| 00000000|awake_logo|
/// |00001000| 00000000| 00000000| 00000000|awake_keyb|
/// |00010000| 00000000| 00000000| 00000000|sleep_logo|
/// |00100000| 00000000| 00000000| 00000000|sleep_keyb|
/// |01000000| 00000000| 00000000| 00000000|shut_logo_|
/// |10000000| 00000000| 00000000| 00000000|shut_keyb_|
/// |00000000| 00000010| 00000000| 00000000|boot_bar__|
/// |00000000| 00000100| 00000000| 00000000|awake_bar_|
/// |00000000| 00001000| 00000000| 00000000|sleep_bar_|
/// |00000000| 00010000| 00000000| 00000000|shut_bar__|
/// |00000000| 00000000| 00000001| 00000000|boot_lid__|
/// |00000000| 00000000| 00000010| 00000000|awkae_lid_|
/// |00000000| 00000000| 00000100| 00000000|sleep_lid_|
/// |00000000| 00000000| 00001000| 00000000|shut_lid__|
/// |00000000| 00000000| 00000000| 00000001|boot_rear_|
/// |00000000| 00000000| 00000000| 00000010|awake_rear|
/// |00000000| 00000000| 00000000| 00000100|sleep_rear|
/// |00000000| 00000000| 00000000| 00001000|shut_rear_|
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct AuraPower {
pub keyboard: KbAuraPowerState,
pub logo: KbAuraPowerState,
pub lightbar: KbAuraPowerState,
pub lid: KbAuraPowerState,
pub rear_glow: KbAuraPowerState,
}
impl AuraPower {
pub fn new_all_on() -> Self {
Self {
keyboard: KbAuraPowerState {
zone: PowerZones::Keyboard,
boot: true,
awake: true,
sleep: true,
shutdown: true,
},
logo: KbAuraPowerState {
zone: PowerZones::Logo,
boot: true,
awake: true,
sleep: true,
shutdown: true,
},
lightbar: KbAuraPowerState {
zone: PowerZones::Lightbar,
boot: true,
awake: true,
sleep: true,
shutdown: true,
},
lid: KbAuraPowerState {
zone: PowerZones::Lid,
boot: true,
awake: true,
sleep: true,
shutdown: true,
},
rear_glow: KbAuraPowerState {
zone: PowerZones::RearGlow,
boot: true,
awake: true,
sleep: true,
shutdown: true,
},
}
}
pub fn to_bytes(&self) -> [u8; 4] {
let mut a: u32 = 0;
a |= self.keyboard.to_byte(PowerZones::Keyboard);
a |= self.logo.to_byte(PowerZones::Logo);
a |= self.lid.to_byte(PowerZones::Lid);
a |= self.lightbar.to_byte(PowerZones::Lightbar);
a |= self.rear_glow.to_byte(PowerZones::RearGlow);
[
(a & 0xff) as u8,
((a & 0xff00) >> 8) as u8,
((a & 0xff0000) >> 16) as u8,
((a & 0xff000000) >> 24) as u8,
]
}
}
#[test]
fn check_0x19b6_control_bytes_binary_rep() {
fn to_binary_string(power: &AuraPower) -> String {
let bytes = power.to_bytes();
format!(
"{:08b}, {:08b}, {:08b}, {:08b}",
bytes[0], bytes[1], bytes[2], bytes[3]
)
}
let boot_logo_ = to_binary_string(&AuraPower {
logo: KbAuraPowerState {
boot: true,
..Default::default()
},
..Default::default()
});
let boot_keyb_ = to_binary_string(&AuraPower {
keyboard: KbAuraPowerState {
boot: true,
..Default::default()
},
..Default::default()
});
let sleep_logo = to_binary_string(&AuraPower {
logo: KbAuraPowerState {
sleep: true,
..Default::default()
},
..Default::default()
});
let sleep_keyb = to_binary_string(&AuraPower {
keyboard: KbAuraPowerState {
sleep: true,
..Default::default()
},
..Default::default()
});
let awake_logo = to_binary_string(&AuraPower {
logo: KbAuraPowerState {
awake: true,
..Default::default()
},
..Default::default()
});
let awake_keyb = to_binary_string(&AuraPower {
keyboard: KbAuraPowerState {
awake: true,
..Default::default()
},
..Default::default()
});
let shut_logo_ = to_binary_string(&AuraPower {
logo: KbAuraPowerState {
shutdown: true,
..Default::default()
},
..Default::default()
});
let shut_keyb_ = to_binary_string(&AuraPower {
keyboard: KbAuraPowerState {
shutdown: true,
..Default::default()
},
..Default::default()
});
let boot_bar__ = to_binary_string(&AuraPower {
lightbar: KbAuraPowerState {
boot: true,
..Default::default()
},
..Default::default()
});
let awake_bar_ = to_binary_string(&AuraPower {
lightbar: KbAuraPowerState {
awake: true,
..Default::default()
},
..Default::default()
});
let sleep_bar_ = to_binary_string(&AuraPower {
lightbar: KbAuraPowerState {
sleep: true,
..Default::default()
},
..Default::default()
});
let shut_bar__ = to_binary_string(&AuraPower {
lightbar: KbAuraPowerState {
shutdown: true,
..Default::default()
},
..Default::default()
});
let boot_lid__ = to_binary_string(&AuraPower {
lid: KbAuraPowerState {
boot: true,
..Default::default()
},
..Default::default()
});
let awkae_lid_ = to_binary_string(&AuraPower {
lid: KbAuraPowerState {
awake: true,
..Default::default()
},
..Default::default()
});
let sleep_lid_ = to_binary_string(&AuraPower {
lid: KbAuraPowerState {
sleep: true,
..Default::default()
},
..Default::default()
});
let shut_lid__ = to_binary_string(&AuraPower {
lid: KbAuraPowerState {
shutdown: true,
..Default::default()
},
..Default::default()
});
let boot_rear_ = to_binary_string(&AuraPower {
rear_glow: KbAuraPowerState {
boot: true,
..Default::default()
},
..Default::default()
});
let awake_rear = to_binary_string(&AuraPower {
rear_glow: KbAuraPowerState {
awake: true,
..Default::default()
},
..Default::default()
});
let sleep_rear = to_binary_string(&AuraPower {
rear_glow: KbAuraPowerState {
sleep: true,
..Default::default()
},
..Default::default()
});
let shut_rear_ = to_binary_string(&AuraPower {
rear_glow: KbAuraPowerState {
shutdown: true,
..Default::default()
},
..Default::default()
});
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
assert_eq!(boot_keyb_, "00000010, 00000000, 00000000, 00000000");
assert_eq!(awake_logo, "00000100, 00000000, 00000000, 00000000");
assert_eq!(awake_keyb, "00001000, 00000000, 00000000, 00000000");
assert_eq!(sleep_logo, "00010000, 00000000, 00000000, 00000000");
assert_eq!(sleep_keyb, "00100000, 00000000, 00000000, 00000000");
assert_eq!(shut_logo_, "01000000, 00000000, 00000000, 00000000");
assert_eq!(shut_keyb_, "10000000, 00000000, 00000000, 00000000");
//
assert_eq!(boot_bar__, "00000000, 00000010, 00000000, 00000000");
assert_eq!(awake_bar_, "00000000, 00000100, 00000000, 00000000");
assert_eq!(sleep_bar_, "00000000, 00001000, 00000000, 00000000");
assert_eq!(shut_bar__, "00000000, 00010000, 00000000, 00000000");
//
assert_eq!(boot_lid__, "00000000, 00000000, 00000001, 00000000");
assert_eq!(awkae_lid_, "00000000, 00000000, 00000010, 00000000");
assert_eq!(sleep_lid_, "00000000, 00000000, 00000100, 00000000");
assert_eq!(shut_lid__, "00000000, 00000000, 00001000, 00000000");
//
assert_eq!(boot_rear_, "00000000, 00000000, 00000000, 00000001");
assert_eq!(awake_rear, "00000000, 00000000, 00000000, 00000010");
assert_eq!(sleep_rear, "00000000, 00000000, 00000000, 00000100");
assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000");
// All on
let byte1 = AuraPower::new_all_on();
let out = to_binary_string(&byte1);
assert_eq!(out, "11111111, 00011110, 00001111, 00001111");
}
+9 -177
View File
@@ -6,6 +6,8 @@ use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::Type; use zbus::zvariant::Type;
use crate::power::AuraPower;
pub const LED_INIT1: [u8; 2] = [0x5d, 0xb9]; pub const LED_INIT1: [u8; 2] = [0x5d, 0xb9];
pub const LED_INIT2: &str = "]ASUS Tech.Inc."; // ] == 0x5d pub const LED_INIT2: &str = "]ASUS Tech.Inc."; // ] == 0x5d
pub const LED_INIT3: [u8; 6] = [0x5d, 0x05, 0x20, 0x31, 0, 0x08]; pub const LED_INIT3: [u8; 6] = [0x5d, 0x05, 0x20, 0x31, 0, 0x08];
@@ -88,9 +90,14 @@ impl Debug for AuraDevice {
#[cfg_attr(feature = "dbus", derive(Type))] #[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Clone, Default, Debug, Serialize, Deserialize)] #[derive(Clone, Default, Debug, Serialize, Deserialize)]
pub struct AuraPowerDev { pub struct AuraPowerDev {
/// TUF laptops use a similar style of control to the older ROG devices but
/// through WMI
pub tuf: Vec<AuraDevTuf>, pub tuf: Vec<AuraDevTuf>,
pub x1866: Vec<AuraDevRog1>, /// Pre-0x19b6 devices use a different smaller scheme to the newer ROG
pub x19b6: Vec<AuraDevRog2>, /// devices
pub old_rog: Vec<AuraDevRog1>,
/// ASUS standardised control scheme from 2020 onwards
pub rog: AuraPower,
} }
#[typeshare] #[typeshare]
@@ -177,102 +184,9 @@ impl BitAnd<AuraDevRog1> for AuraDevRog1 {
} }
} }
/// # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models
///
/// | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label |
/// |--------|---------|---------|---------|----------|
/// |00000001| 00000000| 00000000| 00000000|boot_logo_|
/// |00000010| 00000000| 00000000| 00000000|boot_keyb_|
/// |00000100| 00000000| 00000000| 00000000|awake_logo|
/// |00001000| 00000000| 00000000| 00000000|awake_keyb|
/// |00010000| 00000000| 00000000| 00000000|sleep_logo|
/// |00100000| 00000000| 00000000| 00000000|sleep_keyb|
/// |01000000| 00000000| 00000000| 00000000|shut_logo_|
/// |10000000| 00000000| 00000000| 00000000|shut_keyb_|
/// |00000000| 00000010| 00000000| 00000000|boot_bar__|
/// |00000000| 00000100| 00000000| 00000000|awake_bar_|
/// |00000000| 00001000| 00000000| 00000000|sleep_bar_|
/// |00000000| 00010000| 00000000| 00000000|shut_bar__|
/// |00000000| 00000000| 00000001| 00000000|boot_lid__|
/// |00000000| 00000000| 00000010| 00000000|awkae_lid_|
/// |00000000| 00000000| 00000100| 00000000|sleep_lid_|
/// |00000000| 00000000| 00001000| 00000000|shut_lid__|
/// |00000000| 00000000| 00000000| 00000001|boot_rear_|
/// |00000000| 00000000| 00000000| 00000010|awake_rear|
/// |00000000| 00000000| 00000000| 00000100|sleep_rear|
/// |00000000| 00000000| 00000000| 00001000|shut_rear_|
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum AuraDevRog2 {
BootLogo = 1,
BootKeyb = 1 << 1,
AwakeLogo = 1 << 2,
AwakeKeyb = 1 << 3,
SleepLogo = 1 << 4,
SleepKeyb = 1 << 5,
ShutdownLogo = 1 << 6,
ShutdownKeyb = 1 << 7,
BootBar = 1 << (7 + 2),
AwakeBar = 1 << (7 + 3),
SleepBar = 1 << (7 + 4),
ShutdownBar = 1 << (7 + 5),
BootLid = 1 << (15 + 1),
AwakeLid = 1 << (15 + 2),
SleepLid = 1 << (15 + 3),
ShutdownLid = 1 << (15 + 4),
BootRearGlow = 1 << (23 + 1),
AwakeRearGlow = 1 << (23 + 2),
SleepRearGlow = 1 << (23 + 3),
ShutdownRearGlow = 1 << (23 + 4),
}
impl From<AuraDevRog2> for u32 {
fn from(a: AuraDevRog2) -> Self {
a as u32
}
}
impl AuraDevRog2 {
pub fn to_bytes(control: &[Self]) -> [u8; 4] {
let mut a: u32 = 0;
for n in control {
a |= *n as u32;
}
[
(a & 0xff) as u8,
((a & 0xff00) >> 8) as u8,
((a & 0xff0000) >> 16) as u8,
((a & 0xff000000) >> 24) as u8,
]
}
pub const fn dev_id() -> &'static str {
"0x196b"
}
}
impl BitOr<AuraDevRog2> for AuraDevRog2 {
type Output = u16;
fn bitor(self, rhs: AuraDevRog2) -> Self::Output {
self as u16 | rhs as u16
}
}
impl BitAnd<AuraDevRog2> for AuraDevRog2 {
type Output = u16;
fn bitand(self, rhs: AuraDevRog2) -> Self::Output {
self as u16 & rhs as u16
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::AuraDevRog1; use super::AuraDevRog1;
use crate::usb::AuraDevRog2;
#[test] #[test]
fn check_0x1866_control_bytes() { fn check_0x1866_control_bytes() {
@@ -308,86 +222,4 @@ mod tests {
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]); assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]);
} }
#[test]
fn check_0x19b6_control_bytes_binary_rep() {
fn to_binary_string(bytes: &[AuraDevRog2]) -> String {
let bytes = AuraDevRog2::to_bytes(bytes);
format!(
"{:08b}, {:08b}, {:08b}, {:08b}",
bytes[0], bytes[1], bytes[2], bytes[3]
)
}
let boot_logo_ = to_binary_string(&[AuraDevRog2::BootLogo]);
let boot_keyb_ = to_binary_string(&[AuraDevRog2::BootKeyb]);
let sleep_logo = to_binary_string(&[AuraDevRog2::SleepLogo]);
let sleep_keyb = to_binary_string(&[AuraDevRog2::SleepKeyb]);
let awake_logo = to_binary_string(&[AuraDevRog2::AwakeLogo]);
let awake_keyb = to_binary_string(&[AuraDevRog2::AwakeKeyb]);
let shut_logo_ = to_binary_string(&[AuraDevRog2::ShutdownLogo]);
let shut_keyb_ = to_binary_string(&[AuraDevRog2::ShutdownKeyb]);
let boot_bar__ = to_binary_string(&[AuraDevRog2::BootBar]);
let awake_bar_ = to_binary_string(&[AuraDevRog2::AwakeBar]);
let sleep_bar_ = to_binary_string(&[AuraDevRog2::SleepBar]);
let shut_bar__ = to_binary_string(&[AuraDevRog2::ShutdownBar]);
let boot_lid__ = to_binary_string(&[AuraDevRog2::BootLid]);
let awkae_lid_ = to_binary_string(&[AuraDevRog2::AwakeLid]);
let sleep_lid_ = to_binary_string(&[AuraDevRog2::SleepLid]);
let shut_lid__ = to_binary_string(&[AuraDevRog2::ShutdownLid]);
let boot_rear_ = to_binary_string(&[AuraDevRog2::BootRearGlow]);
let awake_rear = to_binary_string(&[AuraDevRog2::AwakeRearGlow]);
let sleep_rear = to_binary_string(&[AuraDevRog2::SleepRearGlow]);
let shut_rear_ = to_binary_string(&[AuraDevRog2::ShutdownRearGlow]);
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
assert_eq!(boot_keyb_, "00000010, 00000000, 00000000, 00000000");
assert_eq!(awake_logo, "00000100, 00000000, 00000000, 00000000");
assert_eq!(awake_keyb, "00001000, 00000000, 00000000, 00000000");
assert_eq!(sleep_logo, "00010000, 00000000, 00000000, 00000000");
assert_eq!(sleep_keyb, "00100000, 00000000, 00000000, 00000000");
assert_eq!(shut_logo_, "01000000, 00000000, 00000000, 00000000");
assert_eq!(shut_keyb_, "10000000, 00000000, 00000000, 00000000");
//
assert_eq!(boot_bar__, "00000000, 00000010, 00000000, 00000000");
assert_eq!(awake_bar_, "00000000, 00000100, 00000000, 00000000");
assert_eq!(sleep_bar_, "00000000, 00001000, 00000000, 00000000");
assert_eq!(shut_bar__, "00000000, 00010000, 00000000, 00000000");
//
assert_eq!(boot_lid__, "00000000, 00000000, 00000001, 00000000");
assert_eq!(awkae_lid_, "00000000, 00000000, 00000010, 00000000");
assert_eq!(sleep_lid_, "00000000, 00000000, 00000100, 00000000");
assert_eq!(shut_lid__, "00000000, 00000000, 00001000, 00000000");
//
assert_eq!(boot_rear_, "00000000, 00000000, 00000000, 00000001");
assert_eq!(awake_rear, "00000000, 00000000, 00000000, 00000010");
assert_eq!(sleep_rear, "00000000, 00000000, 00000000, 00000100");
assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000");
// All on
let byte1 = [
AuraDevRog2::BootLogo,
AuraDevRog2::BootKeyb,
AuraDevRog2::SleepLogo,
AuraDevRog2::SleepKeyb,
AuraDevRog2::AwakeLogo,
AuraDevRog2::AwakeKeyb,
AuraDevRog2::ShutdownLogo,
AuraDevRog2::ShutdownKeyb,
AuraDevRog2::BootBar,
AuraDevRog2::AwakeBar,
AuraDevRog2::SleepBar,
AuraDevRog2::ShutdownBar,
AuraDevRog2::AwakeLid,
AuraDevRog2::BootLid,
AuraDevRog2::SleepLid,
AuraDevRog2::ShutdownLid,
AuraDevRog2::AwakeRearGlow,
AuraDevRog2::BootRearGlow,
AuraDevRog2::SleepRearGlow,
AuraDevRog2::ShutdownRearGlow,
];
let out = to_binary_string(&byte1);
assert_eq!(out, "11111111, 00011110, 00001111, 00001111");
}
} }
+56 -28
View File
@@ -1,6 +1,5 @@
use egui::Ui; use egui::{RichText, Ui};
use rog_platform::supported::SupportedFunctions; use rog_platform::supported::SupportedFunctions;
use rog_profiles::Profile;
use crate::system_state::{FanCurvesState, ProfilesState, SystemState}; use crate::system_state::{FanCurvesState, ProfilesState, SystemState};
use crate::widgets::fan_graphs; use crate::widgets::fan_graphs;
@@ -12,10 +11,6 @@ impl RogApp {
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("Custom fan curves"); ui.heading("Custom fan curves");
ui.label(
"A fan curve is only active when the related profile is active and the curve is \
enabled",
);
Self::fan_curve( Self::fan_curve(
supported, supported,
&mut states.profiles, &mut states.profiles,
@@ -44,35 +39,68 @@ impl RogApp {
ui: &mut Ui, ui: &mut Ui,
) { ) {
ui.separator(); ui.separator();
ui.label("Enabled fan-curves");
let mut changed = false; let mut changed = false;
ui.horizontal(|ui| { ui.horizontal(|ui| {
let mut item = |p: Profile, curves: &mut FanCurvesState, mut checked: bool| { ui.label("Current profile: ");
if ui ui.label(RichText::new(format!("{}", profiles.current)).strong());
.add(egui::Checkbox::new(&mut checked, format!("{:?}", p))) });
.changed()
{
dbus.proxies()
.profile()
.set_fan_curve_enabled(p, checked)
.map_err(|err| {
*do_error = Some(err.to_string());
})
.ok();
if !checked { // ui.horizontal(|ui| {
curves.enabled.remove(&p); // ui.label("Enabled fan-curves: ");
} else { // let mut fan_curve_enable = |profile: Profile, fan: FanCurvePU, mut
curves.enabled.insert(p); // checked: bool| { if ui
// .add(egui::Checkbox::new(&mut checked, format!("{:?}", fan)))
// .changed()
// {
// dbus.proxies()
// .profile()
// .set_fan_curves_enabled(profile, checked)
// .map_err(|err| {
// *do_error = Some(err.to_string());
// })
// .ok();
// changed = true;
// }
// };
// if let Some(curves) = curves.curves.get_mut(&profiles.current) {
// for curve in curves.iter_mut() {
// fan_curve_enable(profiles.current, curve.fan, curve.enabled);
// }
// }
// });
ui.horizontal(|ui| {
ui.label("Enabled fan-curves: ");
let mut checked = false;
let mut label = String::default();
if let Some(curves) = curves.curves.get_mut(&profiles.current) {
for curve in curves.iter() {
label.push_str(&<&str>::from(curve.fan).to_ascii_uppercase());
label.push(' ');
if curve.enabled {
// TODO: it's possible to set just one fan to active
checked = true;
} }
changed = true;
} }
}; }
profiles.list.sort(); if ui
for f in &profiles.list { .add(egui::Checkbox::new(
item(*f, curves, curves.enabled.contains(f)); &mut checked,
RichText::new(label).strong(),
))
.changed()
{
dbus.proxies()
.profile()
.set_fan_curves_enabled(profiles.current, checked)
.map_err(|err| {
*do_error = Some(err.to_string());
})
.ok();
changed = true;
} }
}); });
+15 -29
View File
@@ -12,7 +12,7 @@ use rog_aura::usb::AuraPowerDev;
use rog_aura::{AuraEffect, AuraModeNum}; use rog_aura::{AuraEffect, AuraModeNum};
use rog_platform::platform::GpuMode; use rog_platform::platform::GpuMode;
use rog_platform::supported::SupportedFunctions; use rog_platform::supported::SupportedFunctions;
use rog_profiles::fan_curve_set::FanCurveSet; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::{FanCurvePU, Profile}; use rog_profiles::{FanCurvePU, Profile};
use supergfxctl::pci_device::{GfxMode, GfxPower}; use supergfxctl::pci_device::{GfxMode, GfxPower};
#[cfg(not(feature = "mocking"))] #[cfg(not(feature = "mocking"))]
@@ -96,8 +96,8 @@ impl ProfilesState {
pub struct FanCurvesState { pub struct FanCurvesState {
pub show_curve: Profile, pub show_curve: Profile,
pub show_graph: FanCurvePU, pub show_graph: FanCurvePU,
pub enabled: HashSet<Profile>, pub curves: BTreeMap<Profile, Vec<CurveData>>,
pub curves: BTreeMap<Profile, FanCurveSet>, pub available_fans: HashSet<FanCurvePU>,
pub drag_delta: Vec2, pub drag_delta: Vec2,
} }
@@ -108,34 +108,24 @@ impl FanCurvesState {
} else { } else {
vec![Profile::Balanced, Profile::Quiet, Profile::Performance] vec![Profile::Balanced, Profile::Quiet, Profile::Performance]
}; };
let enabled = if supported.platform_profile.fan_curves {
dbus.proxies()
.profile()
.enabled_fan_profiles()?
.iter()
.cloned()
.collect::<HashSet<_>>()
} else {
HashSet::from([Profile::Balanced, Profile::Quiet, Profile::Performance])
};
let mut curves: BTreeMap<Profile, FanCurveSet> = BTreeMap::new(); let mut curves: BTreeMap<Profile, Vec<CurveData>> = BTreeMap::new();
for p in &profiles { for p in &profiles {
if supported.platform_profile.fan_curves { if !supported.platform_profile.fans.is_empty() {
if let Ok(curve) = dbus.proxies().profile().fan_curve_data(*p) { if let Ok(curve) = dbus.proxies().profile().fan_curve_data(*p) {
curves.insert(*p, curve); curves.insert(*p, curve);
} }
} else { } else {
let mut curve = FanCurveSet::default(); curves.insert(*p, Vec::default());
curve.cpu.pwm = [30, 40, 60, 100, 140, 180, 200, 250];
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];
curves.insert(*p, curve);
} }
} }
let show_curve = if supported.platform_profile.fan_curves { let mut available_fans = HashSet::new();
for fan in supported.platform_profile.fans.iter() {
available_fans.insert(*fan);
}
let show_curve = if !supported.platform_profile.fans.is_empty() {
dbus.proxies().profile().active_profile()? dbus.proxies().profile().active_profile()?
} else { } else {
Profile::Balanced Profile::Balanced
@@ -144,8 +134,8 @@ impl FanCurvesState {
Ok(Self { Ok(Self {
show_curve, show_curve,
show_graph: FanCurvePU::CPU, show_graph: FanCurvePU::CPU,
enabled,
curves, curves,
available_fans,
drag_delta: Vec2::default(), drag_delta: Vec2::default(),
}) })
} }
@@ -177,7 +167,7 @@ impl AuraState {
} else { } else {
BTreeMap::new() BTreeMap::new()
}, },
enabled: dbus.proxies().led().led_powered().unwrap_or_default(), enabled: dbus.proxies().led().led_power().unwrap_or_default(),
bright: dbus.proxies().led().led_brightness().unwrap_or_default(), bright: dbus.proxies().led().led_brightness().unwrap_or_default(),
wave_red: [0u8; 22], wave_red: [0u8; 22],
wave_green: [0u8; 22], wave_green: [0u8; 22],
@@ -427,11 +417,7 @@ impl Default for SystemState {
aura: AuraState { aura: AuraState {
current_mode: AuraModeNum::Static, current_mode: AuraModeNum::Static,
modes: Default::default(), modes: Default::default(),
enabled: AuraPowerDev { enabled: AuraPowerDev::default(),
tuf: vec![],
x1866: vec![],
x19b6: vec![],
},
..Default::default() ..Default::default()
}, },
anime: AnimeState::default(), anime: AnimeState::default(),
+33 -4
View File
@@ -274,19 +274,48 @@ pub fn start_notifications(
let conn = zbus::Connection::system() let conn = zbus::Connection::system()
.await .await
.map_err(|e| { .map_err(|e| {
error!("zbus signal: receive_power_states: {e}"); error!("zbus signal: receive_device_state: {e}");
e
})
.unwrap();
let proxy = LedProxy::new(&conn)
.await
.map_err(|e| {
error!("zbus signal: receive_device_state: {e}");
e
})
.unwrap();
if let Ok(mut p) = proxy.receive_notify_power_states().await {
info!("Started zbus signal thread: receive_notify_power_states");
while let Some(e) = p.next().await {
if let Ok(out) = e.args() {
if let Ok(mut lock) = page_states1.lock() {
lock.aura.enabled = out.data;
lock.set_notified();
}
}
}
};
});
let page_states1 = page_states.clone();
tokio::spawn(async move {
let conn = zbus::Connection::system()
.await
.map_err(|e| {
error!("zbus signal: receive_device_state: {e}");
e e
}) })
.unwrap(); .unwrap();
let proxy = AnimeProxy::new(&conn) let proxy = AnimeProxy::new(&conn)
.await .await
.map_err(|e| { .map_err(|e| {
error!("zbus signal: receive_power_states: {e}"); error!("zbus signal: receive_device_state: {e}");
e e
}) })
.unwrap(); .unwrap();
if let Ok(p) = proxy.receive_device_state().await { if let Ok(p) = proxy.receive_device_state().await {
info!("Started zbus signal thread: receive_power_states"); info!("Started zbus signal thread: receive_device_state");
p.for_each(|_| { p.for_each(|_| {
if let Ok(_lock) = page_states1.lock() { if let Ok(_lock) = page_states1.lock() {
// TODO: lock.anime. // TODO: lock.anime.
@@ -320,7 +349,7 @@ pub fn start_notifications(
} }
if let Ok(mut p) = proxy.receive_notify_gpu_mux_mode().await { if let Ok(mut p) = proxy.receive_notify_gpu_mux_mode().await {
info!("Started zbus signal thread: receive_power_states"); info!("Started zbus signal thread: receive_notify_gpu_mux_mode");
while let Some(e) = p.next().await { while let Some(e) = p.next().await {
if let Ok(out) = e.args() { if let Ok(out) = e.args() {
if out.mode == actual_mux_mode { if out.mode == actual_mux_mode {
+59 -116
View File
@@ -1,12 +1,12 @@
use egui::{RichText, Ui}; use egui::{RichText, Ui};
use rog_aura::usb::{AuraDevRog1, AuraDevRog2, AuraDevTuf, AuraDevice, AuraPowerDev}; use rog_aura::power::{AuraPower, KbAuraPowerState};
use rog_aura::AuraZone; use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev};
use rog_platform::supported::SupportedFunctions; use rog_platform::supported::SupportedFunctions;
use crate::system_state::SystemState; use crate::system_state::SystemState;
pub fn aura_power_group(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) { pub fn aura_power_group(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) {
ui.heading("LED settings"); ui.heading("Keyboard LED power settings");
match supported.keyboard_led.dev_id { match supported.keyboard_led.dev_id {
AuraDevice::X1854 | AuraDevice::X1869 | AuraDevice::X1866 => { AuraDevice::X1854 | AuraDevice::X1869 | AuraDevice::X1866 => {
@@ -22,10 +22,10 @@ pub fn aura_power_group(supported: &SupportedFunctions, states: &mut SystemState
fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) { fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) {
let enabled_states = &mut states.aura.enabled; let enabled_states = &mut states.aura.enabled;
let mut boot = enabled_states.x1866.contains(&AuraDevRog1::Boot); let mut boot = enabled_states.old_rog.contains(&AuraDevRog1::Boot);
let mut sleep = enabled_states.x1866.contains(&AuraDevRog1::Sleep); let mut sleep = enabled_states.old_rog.contains(&AuraDevRog1::Sleep);
let mut keyboard = enabled_states.x1866.contains(&AuraDevRog1::Keyboard); let mut keyboard = enabled_states.old_rog.contains(&AuraDevRog1::Keyboard);
let mut lightbar = enabled_states.x1866.contains(&AuraDevRog1::Lightbar); let mut lightbar = enabled_states.old_rog.contains(&AuraDevRog1::Lightbar);
if supported.keyboard_led.dev_id == AuraDevice::Tuf { if supported.keyboard_led.dev_id == AuraDevice::Tuf {
boot = enabled_states.tuf.contains(&AuraDevTuf::Boot); boot = enabled_states.tuf.contains(&AuraDevTuf::Boot);
sleep = enabled_states.tuf.contains(&AuraDevTuf::Sleep); sleep = enabled_states.tuf.contains(&AuraDevTuf::Sleep);
@@ -130,8 +130,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
let mut send = |enable: bool, data: Vec<AuraDevTuf>| { let mut send = |enable: bool, data: Vec<AuraDevTuf>| {
let options = AuraPowerDev { let options = AuraPowerDev {
tuf: data, tuf: data,
x1866: vec![], ..Default::default()
x19b6: vec![],
}; };
// build data to send // build data to send
states states
@@ -153,21 +152,21 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
let mut modify_x1866 = |b: bool, a: AuraDevRog1| { let mut modify_x1866 = |b: bool, a: AuraDevRog1| {
if b { if b {
enabled.push(a); enabled.push(a);
if !enabled_states.x1866.contains(&a) { if !enabled_states.old_rog.contains(&a) {
enabled_states.x1866.push(a); enabled_states.old_rog.push(a);
} }
} else { } else {
disabled.push(a); disabled.push(a);
// This would be so much better as a hashset // This would be so much better as a hashset
if enabled_states.x1866.contains(&a) { if enabled_states.old_rog.contains(&a) {
let mut idx = 0; let mut idx = 0;
for (i, n) in enabled_states.x1866.iter().enumerate() { for (i, n) in enabled_states.old_rog.iter().enumerate() {
if *n == a { if *n == a {
idx = i; idx = i;
break; break;
} }
} }
enabled_states.x1866.remove(idx); enabled_states.old_rog.remove(idx);
} }
} }
}; };
@@ -180,9 +179,8 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
let mut send = |enable: bool, data: Vec<AuraDevRog1>| { let mut send = |enable: bool, data: Vec<AuraDevRog1>| {
let options = AuraPowerDev { let options = AuraPowerDev {
tuf: vec![], old_rog: data,
x1866: data, ..Default::default()
x19b6: vec![],
}; };
// build data to send // build data to send
states states
@@ -202,115 +200,52 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
} }
fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) { fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) {
let enabled_states = &mut states.aura.enabled; let AuraPower {
let has_logo = supported.keyboard_led.basic_zones.contains(&AuraZone::Logo); keyboard,
let has_lightbar = supported logo,
.keyboard_led lightbar,
.basic_zones lid,
.contains(&AuraZone::BarLeft) rear_glow,
|| supported } = &mut states.aura.enabled.rog;
.keyboard_led
.basic_zones
.contains(&AuraZone::BarRight);
let boot_bar = &mut enabled_states.x19b6.contains(&AuraDevRog2::AwakeBar); const LABELS: [&str; 4] = ["Boot", "Awake", "Sleep", "Shutdown"];
let boot_logo = &mut enabled_states.x19b6.contains(&AuraDevRog2::BootLogo);
let boot_keyb = &mut enabled_states.x19b6.contains(&AuraDevRog2::BootKeyb);
let awake_bar = &mut enabled_states.x19b6.contains(&AuraDevRog2::BootBar);
let awake_logo = &mut enabled_states.x19b6.contains(&AuraDevRog2::AwakeLogo);
let awake_keyb = &mut enabled_states.x19b6.contains(&AuraDevRog2::AwakeKeyb);
let sleep_bar = &mut enabled_states.x19b6.contains(&AuraDevRog2::SleepBar);
let sleep_logo = &mut enabled_states.x19b6.contains(&AuraDevRog2::SleepLogo);
let sleep_keyb = &mut enabled_states.x19b6.contains(&AuraDevRog2::SleepKeyb);
let mut changed = false; let mut changed = false;
let mut item = |power: &mut KbAuraPowerState, ui: &mut Ui| {
let mut item = |keyboard: &mut bool, logo: &mut bool, lightbar: &mut bool, ui: &mut Ui| { ui.vertical(|ui| {
ui.horizontal_wrapped(|ui| { if supported.keyboard_led.power_zones.contains(&power.zone) {
if ui.checkbox(keyboard, "Keyboard").changed() { ui.horizontal_wrapped(|ui| {
changed = true; ui.label(RichText::new(format!("{:?}", power.zone)).size(14.0));
} });
if has_logo && ui.checkbox(logo, "Logo").changed() { if ui.checkbox(&mut power.boot, LABELS[0]).changed() {
changed = true; changed = true;
} }
if has_lightbar && ui.checkbox(lightbar, "Lightbar").changed() { if ui.checkbox(&mut power.awake, LABELS[1]).changed() {
changed = true; changed = true;
}
if ui.checkbox(&mut power.sleep, LABELS[2]).changed() {
changed = true;
}
if ui.checkbox(&mut power.shutdown, LABELS[3]).changed() {
changed = true;
}
} }
}); });
}; };
ui.horizontal_wrapped(|ui| { ui.horizontal_wrapped(|ui| {
ui.vertical(|ui| { item(lid, ui);
let h = 16.0; item(logo, ui);
ui.set_row_height(22.0); item(keyboard, ui);
ui.horizontal_wrapped(|ui| { item(lightbar, ui);
ui.label(RichText::new("Boot").size(h)); item(rear_glow, ui);
});
ui.horizontal_wrapped(|ui| {
ui.label(RichText::new("Awake").size(h));
});
ui.horizontal_wrapped(|ui| {
ui.label(RichText::new("Sleep").size(h));
});
});
ui.vertical(|ui| {
ui.set_row_height(22.0);
item(boot_keyb, boot_logo, boot_bar, ui);
item(awake_keyb, awake_logo, awake_bar, ui);
item(sleep_keyb, sleep_logo, sleep_bar, ui);
});
}); });
if changed { if changed {
let mut enabled = Vec::new(); let mut send = |enable: bool, data: AuraPower| {
let mut disabled = Vec::new();
let mut modify = |b: bool, a: AuraDevRog2| {
if b {
enabled.push(a);
if !enabled_states.x19b6.contains(&a) {
enabled_states.x19b6.push(a);
}
} else {
disabled.push(a);
// This would be so much better as a hashset
if enabled_states.x19b6.contains(&a) {
let mut idx = 0;
for (i, n) in enabled_states.x19b6.iter().enumerate() {
if *n == a {
idx = i;
break;
}
}
enabled_states.x19b6.remove(idx);
}
}
};
modify(*boot_keyb, AuraDevRog2::BootKeyb);
modify(*sleep_keyb, AuraDevRog2::SleepKeyb);
modify(*awake_keyb, AuraDevRog2::AwakeKeyb);
if supported.keyboard_led.basic_zones.contains(&AuraZone::Logo) {
modify(*boot_logo, AuraDevRog2::BootLogo);
modify(*sleep_logo, AuraDevRog2::SleepLogo);
modify(*awake_logo, AuraDevRog2::AwakeLogo);
}
if supported
.keyboard_led
.basic_zones
.contains(&AuraZone::BarLeft)
{
modify(*boot_bar, AuraDevRog2::AwakeBar);
modify(*sleep_bar, AuraDevRog2::SleepBar);
modify(*awake_bar, AuraDevRog2::BootBar);
}
let mut send = |enable: bool, data: Vec<AuraDevRog2>| {
let options = AuraPowerDev { let options = AuraPowerDev {
tuf: vec![], rog: data,
x1866: vec![], ..Default::default()
x19b6: data,
}; };
// build data to send // build data to send
states states
@@ -323,7 +258,15 @@ fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
}) })
.ok(); .ok();
}; };
send(true, enabled); send(
send(false, disabled); true,
AuraPower {
keyboard: *keyboard,
logo: *logo,
lightbar: *lightbar,
lid: *lid,
rear_glow: *rear_glow,
},
);
} }
} }
+37 -18
View File
@@ -1,6 +1,7 @@
use egui::plot::Points; use egui::plot::Points;
use egui::Ui; use egui::Ui;
use rog_platform::supported::SupportedFunctions; use rog_platform::supported::SupportedFunctions;
use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::{FanCurvePU, Profile}; use rog_profiles::{FanCurvePU, Profile};
use crate::system_state::FanCurvesState; use crate::system_state::FanCurvesState;
@@ -15,20 +16,36 @@ pub fn fan_graphs(
) { ) {
ui.separator(); ui.separator();
let mut item = |p: Profile, ui: &mut Ui| { let mut item = |profile: Profile, ui: &mut Ui| {
ui.group(|ui| { ui.group(|ui| {
ui.selectable_value(&mut curves.show_curve, p, format!("{p:?}")); if ui
ui.add_enabled_ui(curves.show_curve == p, |ui| { .selectable_value(&mut curves.show_curve, profile, format!("{profile:?}"))
ui.selectable_value( .clicked()
&mut curves.show_graph, {
FanCurvePU::CPU, dbus.proxies().profile().set_active_profile(profile).ok();
format!("{:?}", FanCurvePU::CPU), }
); ui.add_enabled_ui(curves.show_curve == profile, |ui| {
ui.selectable_value( if curves.available_fans.contains(&FanCurvePU::CPU) {
&mut curves.show_graph, ui.selectable_value(
FanCurvePU::GPU, &mut curves.show_graph,
format!("{:?}", FanCurvePU::GPU), FanCurvePU::CPU,
); format!("{:?}", FanCurvePU::CPU),
);
}
if curves.available_fans.contains(&FanCurvePU::GPU) {
ui.selectable_value(
&mut curves.show_graph,
FanCurvePU::GPU,
format!("{:?}", FanCurvePU::GPU),
);
}
if curves.available_fans.contains(&FanCurvePU::MID) {
ui.selectable_value(
&mut curves.show_graph,
FanCurvePU::MID,
format!("{:?}", FanCurvePU::MID),
);
}
}); });
}); });
}; };
@@ -43,11 +60,13 @@ pub fn fan_graphs(
use egui::plot::{Line, Plot}; use egui::plot::{Line, Plot};
let data = if curves.show_graph == FanCurvePU::CPU { let mut data = &mut CurveData::default();
&mut curve.cpu for c in curve {
} else { if c.fan == curves.show_graph {
&mut curve.gpu data = c;
}; break;
}
}
let mut points: Vec<[f64; 2]> = data let mut points: Vec<[f64; 2]> = data
.temp .temp
+1 -1
View File
@@ -18,7 +18,7 @@ impl RogApp {
*page = Page::System; *page = Page::System;
} }
if self.supported.platform_profile.fan_curves { if !self.supported.platform_profile.fans.is_empty() {
ui.separator(); ui.separator();
if ui if ui
.selectable_value(page, Page::FanCurves, "Fan Curves") .selectable_value(page, Page::FanCurves, "Fan Curves")
+1 -1
View File
@@ -79,7 +79,7 @@ trait Led {
// As property doesn't work for AuraPowerDev (complexity of serialization?) // As property doesn't work for AuraPowerDev (complexity of serialization?)
// #[dbus_proxy(property)] // #[dbus_proxy(property)]
fn led_powered(&self) -> zbus::Result<AuraPowerDev>; fn led_power(&self) -> zbus::Result<AuraPowerDev>;
} }
pub struct LedProxyPerkey<'a>(LedProxyBlocking<'a>); pub struct LedProxyPerkey<'a>(LedProxyBlocking<'a>);
+13 -7
View File
@@ -20,8 +20,8 @@
//! //!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces. //! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use rog_profiles::fan_curve_set::{CurveData, FanCurveSet}; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::Profile; use rog_profiles::{FanCurvePU, Profile};
use zbus::dbus_proxy; use zbus::dbus_proxy;
#[dbus_proxy( #[dbus_proxy(
@@ -30,14 +30,11 @@ use zbus::dbus_proxy;
)] )]
trait Profile { trait Profile {
/// Get the fan-curve data for the currently active Profile /// Get the fan-curve data for the currently active Profile
fn fan_curve_data(&self, profile: Profile) -> zbus::Result<FanCurveSet>; fn fan_curve_data(&self, profile: Profile) -> zbus::Result<Vec<CurveData>>;
/// Fetch the active profile name /// Fetch the active profile name
fn active_profile(&self) -> zbus::Result<Profile>; fn active_profile(&self) -> zbus::Result<Profile>;
/// Get a list of profiles that have fan-curves enabled.
fn enabled_fan_profiles(&self) -> zbus::Result<Vec<Profile>>;
/// Toggle to next platform_profile. Names provided by `Profiles`. /// Toggle to next platform_profile. Names provided by `Profiles`.
/// If fan-curves are supported will also activate a fan curve for profile. /// If fan-curves are supported will also activate a fan curve for profile.
fn next_profile(&self) -> zbus::Result<()>; fn next_profile(&self) -> zbus::Result<()>;
@@ -49,7 +46,16 @@ trait Profile {
fn set_active_profile(&self, profile: Profile) -> zbus::Result<()>; fn set_active_profile(&self, profile: Profile) -> 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_curve_enabled(&self, profile: Profile, enabled: bool) -> zbus::Result<()>; fn set_fan_curves_enabled(&self, profile: Profile, enabled: bool) -> zbus::Result<()>;
/// Set a single fan curve for a profile to enabled status. Will also
/// activate a fan curve.
async fn set_profile_fan_curve_enabled(
&mut self,
profile: Profile,
fan: FanCurvePU,
enabled: bool,
) -> 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.
+1
View File
@@ -7,6 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
log.workspace = true log.workspace = true
rog_aura = { path = "../rog-aura" } rog_aura = { path = "../rog-aura" }
rog_profiles = { path = "../rog-profiles" }
serde.workspace = true serde.workspace = true
serde_derive.workspace = true serde_derive.workspace = true
zbus.workspace = true zbus.workspace = true
+3 -2
View File
@@ -3,6 +3,7 @@ use std::fmt;
use rog_aura::aura_detection::PowerZones; use rog_aura::aura_detection::PowerZones;
use rog_aura::usb::AuraDevice; use rog_aura::usb::AuraDevice;
use rog_aura::{AdvancedAuraType, AuraModeNum, AuraZone}; use rog_aura::{AdvancedAuraType, AuraModeNum, AuraZone};
use rog_profiles::FanCurvePU;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use typeshare::typeshare; use typeshare::typeshare;
use zbus::zvariant::Type; use zbus::zvariant::Type;
@@ -31,7 +32,7 @@ pub struct ChargeSupportedFunctions {
#[derive(Serialize, Deserialize, Type, Debug, Default, Clone)] #[derive(Serialize, Deserialize, Type, Debug, Default, Clone)]
pub struct PlatformProfileFunctions { pub struct PlatformProfileFunctions {
pub platform_profile: bool, pub platform_profile: bool,
pub fan_curves: bool, pub fans: Vec<FanCurvePU>,
} }
#[typeshare] #[typeshare]
@@ -106,7 +107,7 @@ impl fmt::Display for PlatformProfileFunctions {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "Platform profiles:")?; writeln!(f, "Platform profiles:")?;
writeln!(f, "\tplatform: {}", self.platform_profile)?; writeln!(f, "\tplatform: {}", self.platform_profile)?;
writeln!(f, "\tfan curves: {}", self.fan_curves) writeln!(f, "\tfan curves: {:?}", self.fans)
} }
} }
impl fmt::Display for LedSupportedFunctions { impl fmt::Display for LedSupportedFunctions {
+1
View File
@@ -10,6 +10,7 @@ default = ["dbus"]
dbus = ["zbus"] dbus = ["zbus"]
[dependencies] [dependencies]
log.workspace = true
udev.workspace = true udev.workspace = true
serde.workspace = true serde.workspace = true
serde_derive.workspace = true serde_derive.workspace = true
+29 -99
View File
@@ -1,3 +1,4 @@
use log::trace;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use typeshare::typeshare; use typeshare::typeshare;
use udev::Device; use udev::Device;
@@ -8,7 +9,8 @@ use crate::error::ProfileError;
use crate::FanCurvePU; use crate::FanCurvePU;
pub(crate) fn pwm_str(fan: char, index: usize) -> String { pub(crate) fn pwm_str(fan: char, index: usize) -> String {
let mut buf = "pwm1_auto_point1_pwm".to_owned(); // The char 'X' is replaced via indexing
let mut buf = "pwmX_auto_pointX_pwm".to_owned();
unsafe { unsafe {
let tmp = buf.as_bytes_mut(); let tmp = buf.as_bytes_mut();
tmp[3] = fan as u8; tmp[3] = fan as u8;
@@ -18,7 +20,8 @@ pub(crate) fn pwm_str(fan: char, index: usize) -> String {
} }
pub(crate) fn temp_str(fan: char, index: usize) -> String { pub(crate) fn temp_str(fan: char, index: usize) -> String {
let mut buf = "pwm1_auto_point1_temp".to_owned(); // The char 'X' is replaced via indexing
let mut buf = "pwmX_auto_pointX_temp".to_owned();
unsafe { unsafe {
let tmp = buf.as_bytes_mut(); let tmp = buf.as_bytes_mut();
tmp[3] = fan as u8; tmp[3] = fan as u8;
@@ -34,6 +37,7 @@ pub struct CurveData {
pub fan: FanCurvePU, pub fan: FanCurvePU,
pub pwm: [u8; 8], pub pwm: [u8; 8],
pub temp: [u8; 8], pub temp: [u8; 8],
pub enabled: bool,
} }
impl From<&CurveData> for String { impl From<&CurveData> for String {
@@ -65,7 +69,7 @@ impl std::str::FromStr for CurveData {
type Err = ProfileError; type Err = ProfileError;
/// Parse a string to the correct values that the fan curve kernel driver /// Parse a string to the correct values that the fan curve kernel driver
/// expects /// expects. The returned `CurveData` is not enabled by default.
/// ///
/// If the fan curve is given with percentage char '%' then the fan power /// If the fan curve is given with percentage char '%' then the fan power
/// values are converted otherwise the expected fan power range is /// values are converted otherwise the expected fan power range is
@@ -126,6 +130,7 @@ impl std::str::FromStr for CurveData {
fan: FanCurvePU::CPU, fan: FanCurvePU::CPU,
pwm, pwm,
temp, temp,
enabled: false,
}) })
} }
} }
@@ -144,114 +149,39 @@ impl CurveData {
} }
} }
fn read_from_device(&mut self, device: &Device) { pub fn read_from_device(&mut self, device: &Device) {
for attr in device.attributes() { for attr in device.attributes() {
let tmp = attr.name().to_string_lossy(); let tmp = attr.name().to_string_lossy();
if tmp.starts_with("pwm1") && tmp.ends_with("_temp") { let pwm_num: char = self.fan.into();
let pwm = format!("pwm{pwm_num}");
if tmp.starts_with(&pwm) && tmp.ends_with("_temp") {
Self::set_val_from_attr(tmp.as_ref(), device, &mut self.temp); Self::set_val_from_attr(tmp.as_ref(), device, &mut self.temp);
} }
if tmp.starts_with("pwm1") && tmp.ends_with("_pwm") { if tmp.starts_with(&pwm) && tmp.ends_with("_pwm") {
Self::set_val_from_attr(tmp.as_ref(), device, &mut self.pwm); Self::set_val_from_attr(tmp.as_ref(), device, &mut self.pwm);
} }
} }
} }
fn init_if_zeroed(&mut self, device: &mut Device) -> std::io::Result<()> {
if self.pwm == [0u8; 8] && self.temp == [0u8; 8] {
// Need to reset the device to defaults to get the proper profile defaults
match self.fan {
FanCurvePU::CPU => device.set_attribute_value("pwm1_enable", "3")?,
FanCurvePU::GPU => device.set_attribute_value("pwm2_enable", "3")?,
};
self.read_from_device(device);
}
Ok(())
}
/// Write this curve to the device fan specified by `self.fan` /// Write this curve to the device fan specified by `self.fan`
fn write_to_device(&self, device: &mut Device, enable: bool) -> std::io::Result<()> { pub fn write_to_device(&self, device: &mut Device) -> std::io::Result<()> {
let pwm_num = match self.fan { let pwm_num: char = self.fan.into();
FanCurvePU::CPU => '1', let enable = if self.enabled { "1" } else { "2" };
FanCurvePU::GPU => '2',
};
let enable = if enable { "1" } else { "2" };
for (index, out) in self.pwm.iter().enumerate() { for (index, out) in self.pwm.iter().enumerate() {
let pwm = pwm_str(pwm_num, index); let pwm = pwm_str(pwm_num, index);
trace!("writing {pwm}");
device.set_attribute_value(&pwm, &out.to_string())?; device.set_attribute_value(&pwm, &out.to_string())?;
} }
for (index, out) in self.temp.iter().enumerate() { for (index, out) in self.temp.iter().enumerate() {
let temp = temp_str(pwm_num, index); let temp = temp_str(pwm_num, index);
trace!("writing {temp}");
device.set_attribute_value(&temp, &out.to_string())?; device.set_attribute_value(&temp, &out.to_string())?;
} }
// Enable must be done *after* all points are written // Enable must be done *after* all points are written
match self.fan { device.set_attribute_value(format!("pwm{pwm_num}_enable"), enable)
FanCurvePU::CPU => device.set_attribute_value("pwm1_enable", enable)?,
FanCurvePU::GPU => device.set_attribute_value("pwm2_enable", enable)?,
};
Ok(())
}
}
/// A `FanCurveSet` contains both CPU and GPU fan curve data
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct FanCurveSet {
pub enabled: bool,
pub cpu: CurveData,
pub gpu: CurveData,
}
impl Default for FanCurveSet {
fn default() -> Self {
Self {
enabled: false,
cpu: CurveData {
fan: FanCurvePU::CPU,
pwm: [0u8; 8],
temp: [0u8; 8],
},
gpu: CurveData {
fan: FanCurvePU::GPU,
pwm: [0u8; 8],
temp: [0u8; 8],
},
}
}
}
impl From<&FanCurveSet> for String {
fn from(s: &FanCurveSet) -> Self {
format!(
"Enabled: {}, {}, {}",
s.enabled,
String::from(&s.cpu),
String::from(&s.gpu),
)
}
}
impl FanCurveSet {
pub(crate) fn read_cpu_from_device(&mut self, device: &Device) {
self.cpu.read_from_device(device);
}
pub(crate) fn read_gpu_from_device(&mut self, device: &Device) {
self.gpu.read_from_device(device);
}
pub(crate) fn write_cpu_fan(&mut self, device: &mut Device) -> std::io::Result<()> {
self.cpu.init_if_zeroed(device)?;
self.cpu.write_to_device(device, self.enabled)
}
pub(crate) fn write_gpu_fan(&mut self, device: &mut Device) -> std::io::Result<()> {
self.gpu.init_if_zeroed(device)?;
self.gpu.write_to_device(device, self.enabled)
} }
} }
@@ -315,14 +245,14 @@ mod tests {
assert_eq!(temp_str('1', 7), "pwm1_auto_point8_temp"); assert_eq!(temp_str('1', 7), "pwm1_auto_point8_temp");
} }
#[test] // #[test]
fn set_to_string() { // fn set_to_string() {
let set = FanCurveSet::default(); // let set = FanCurveSet::default();
let string = String::from(&set); // let string = String::from(&set);
assert_eq!( // assert_eq!(
string.as_str(), // string.as_str(),
"Enabled: false, CPU: 0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%, GPU: \ // "Enabled: false, CPU:
0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%" // 0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%, GPU: \ 0c:
); // 0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%" );
} // }
} }
+175 -92
View File
@@ -7,7 +7,8 @@ use std::io::Write;
use std::path::Path; use std::path::Path;
use error::ProfileError; use error::ProfileError;
use fan_curve_set::{CurveData, FanCurveSet}; use fan_curve_set::CurveData;
use log::debug;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use typeshare::typeshare; use typeshare::typeshare;
use udev::Device; use udev::Device;
@@ -131,10 +132,30 @@ impl Display for Profile {
#[typeshare] #[typeshare]
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))] #[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone, Copy)] #[derive(Deserialize, Serialize, Debug, Hash, PartialEq, Eq, Clone, Copy)]
pub enum FanCurvePU { pub enum FanCurvePU {
CPU, CPU,
GPU, GPU,
MID,
}
impl FanCurvePU {
fn which_fans(device: &Device) -> Vec<Self> {
let mut fans = Vec::with_capacity(3);
for fan in [Self::CPU, Self::GPU, Self::MID] {
let pwm_num: char = fan.into();
let pwm_enable = format!("pwm{pwm_num}_enable");
debug!("Looking for {pwm_enable}");
for attr in device.attributes() {
let tmp = attr.name().to_string_lossy();
if tmp.contains(&pwm_enable) {
debug!("Found {pwm_enable}");
fans.push(fan);
}
}
}
fans
}
} }
impl From<FanCurvePU> for &str { impl From<FanCurvePU> for &str {
@@ -142,6 +163,17 @@ impl From<FanCurvePU> for &str {
match pu { match pu {
FanCurvePU::CPU => "cpu", FanCurvePU::CPU => "cpu",
FanCurvePU::GPU => "gpu", FanCurvePU::GPU => "gpu",
FanCurvePU::MID => "mid",
}
}
}
impl From<FanCurvePU> for char {
fn from(pu: FanCurvePU) -> char {
match pu {
FanCurvePU::CPU => '1',
FanCurvePU::GPU => '2',
FanCurvePU::MID => '3',
} }
} }
} }
@@ -153,6 +185,7 @@ impl std::str::FromStr for FanCurvePU {
match fan.to_ascii_lowercase().trim() { match fan.to_ascii_lowercase().trim() {
"cpu" => Ok(FanCurvePU::CPU), "cpu" => Ok(FanCurvePU::CPU),
"gpu" => Ok(FanCurvePU::GPU), "gpu" => Ok(FanCurvePU::GPU),
"mid" => Ok(FanCurvePU::MID),
_ => Err(ProfileError::ParseProfileName), _ => Err(ProfileError::ParseProfileName),
} }
} }
@@ -169,9 +202,9 @@ impl Default for FanCurvePU {
#[cfg_attr(feature = "dbus", derive(Type))] #[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Deserialize, Serialize, Debug, Default)] #[derive(Deserialize, Serialize, Debug, Default)]
pub struct FanCurveProfiles { pub struct FanCurveProfiles {
pub balanced: FanCurveSet, pub balanced: Vec<CurveData>,
pub performance: FanCurveSet, pub performance: Vec<CurveData>,
pub quiet: FanCurveSet, pub quiet: Vec<CurveData>,
} }
impl FanCurveProfiles { impl FanCurveProfiles {
@@ -180,35 +213,49 @@ impl FanCurveProfiles {
enumerator.match_subsystem("hwmon")?; enumerator.match_subsystem("hwmon")?;
for device in enumerator.scan_devices()? { for device in enumerator.scan_devices()? {
// if device.parent_with_subsystem("platform")?.is_some() {
if let Some(name) = device.attribute_value("name") { if let Some(name) = device.attribute_value("name") {
if name == "asus_custom_fan_curve" { if name == "asus_custom_fan_curve" {
debug!("asus_custom_fan_curve found");
return Ok(device); return Ok(device);
} }
} }
// }
} }
Err(ProfileError::NotSupported) Err(ProfileError::NotSupported)
} }
pub fn is_supported() -> Result<bool, ProfileError> { /// Return an array of `FanCurvePU`. An empty array indicates no support for
if Self::get_device().is_ok() { /// Curves.
return Ok(true); pub fn supported_fans() -> Result<Vec<FanCurvePU>, ProfileError> {
} let device = Self::get_device()?;
Ok(FanCurvePU::which_fans(&device))
Ok(false)
} }
/// ///
pub fn read_from_dev_profile(&mut self, profile: Profile, device: &Device) { pub fn read_from_dev_profile(
let mut tmp = FanCurveSet::default(); &mut self,
tmp.read_cpu_from_device(device); profile: Profile,
tmp.read_gpu_from_device(device); device: &Device,
match profile { ) -> Result<(), ProfileError> {
Profile::Balanced => self.balanced = tmp, let fans = Self::supported_fans()?;
Profile::Performance => self.performance = tmp, let mut curves = Vec::with_capacity(3);
Profile::Quiet => self.quiet = tmp,
for fan in fans {
let mut curve = CurveData {
fan,
..Default::default()
};
debug!("Reading curve for {fan:?}");
curve.read_from_device(device);
debug!("Curve: {curve:?}");
curves.push(curve);
} }
match profile {
Profile::Balanced => self.balanced = curves,
Profile::Performance => self.performance = curves,
Profile::Quiet => self.quiet = curves,
}
Ok(())
} }
/// Reset the stored (self) and device curve to the defaults of the /// Reset the stored (self) and device curve to the defaults of the
@@ -220,19 +267,15 @@ impl FanCurveProfiles {
&mut self, &mut self,
profile: Profile, profile: Profile,
device: &mut Device, device: &mut Device,
) -> std::io::Result<()> { ) -> Result<(), ProfileError> {
// Do reset let fans = Self::supported_fans()?;
device.set_attribute_value("pwm1_enable", "3")?; // Do reset for all
device.set_attribute_value("pwm2_enable", "3")?; for fan in fans {
// Then read let pwm_num: char = fan.into();
let mut tmp = FanCurveSet::default(); let pwm = format!("pwm{pwm_num}_enable");
tmp.read_cpu_from_device(device); device.set_attribute_value(&pwm, "3")?;
tmp.read_gpu_from_device(device);
match profile {
Profile::Balanced => self.balanced = tmp,
Profile::Performance => self.performance = tmp,
Profile::Quiet => self.quiet = tmp,
} }
self.read_from_dev_profile(profile, device)?;
Ok(()) Ok(())
} }
@@ -250,50 +293,68 @@ impl FanCurveProfiles {
Profile::Performance => &mut self.performance, Profile::Performance => &mut self.performance,
Profile::Quiet => &mut self.quiet, Profile::Quiet => &mut self.quiet,
}; };
fans.write_cpu_fan(device)?; for fan in fans {
fans.write_gpu_fan(device)?; debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
fan.write_to_device(device)?;
}
Ok(()) Ok(())
} }
pub fn get_enabled_curve_profiles(&self) -> Vec<Profile> { pub fn set_profile_curves_enabled(&mut self, profile: Profile, enabled: bool) {
let mut tmp = Vec::new();
if self.balanced.enabled {
tmp.push(Profile::Balanced);
}
if self.performance.enabled {
tmp.push(Profile::Performance);
}
if self.quiet.enabled {
tmp.push(Profile::Quiet);
}
tmp
}
pub fn set_profile_curve_enabled(&mut self, profile: Profile, enabled: bool) {
match profile { match profile {
Profile::Balanced => self.balanced.enabled = enabled, Profile::Balanced => {
Profile::Performance => self.performance.enabled = enabled, for curve in self.balanced.iter_mut() {
Profile::Quiet => self.quiet.enabled = enabled, curve.enabled = enabled;
}
}
Profile::Performance => {
for curve in self.performance.iter_mut() {
curve.enabled = enabled;
}
}
Profile::Quiet => {
for curve in self.quiet.iter_mut() {
curve.enabled = enabled;
}
}
} }
} }
pub fn get_all_fan_curves(&self) -> Vec<FanCurveSet> { pub fn set_profile_fan_curve_enabled(
vec![ &mut self,
self.balanced.clone(), profile: Profile,
self.performance.clone(), fan: FanCurvePU,
self.quiet.clone(), enabled: bool,
] ) {
} match profile {
Profile::Balanced => {
pub fn get_active_fan_curves(&self) -> Result<&FanCurveSet, ProfileError> { for curve in self.balanced.iter_mut() {
match Profile::get_active_profile()? { if curve.fan == fan {
Profile::Balanced => Ok(&self.balanced), curve.enabled = enabled;
Profile::Performance => Ok(&self.performance), break;
Profile::Quiet => Ok(&self.quiet), }
}
}
Profile::Performance => {
for curve in self.performance.iter_mut() {
if curve.fan == fan {
curve.enabled = enabled;
break;
}
}
}
Profile::Quiet => {
for curve in self.quiet.iter_mut() {
if curve.fan == fan {
curve.enabled = enabled;
break;
}
}
}
} }
} }
pub fn get_fan_curves_for(&self, name: Profile) -> &FanCurveSet { pub fn get_fan_curves_for(&self, name: Profile) -> &[CurveData] {
match name { match name {
Profile::Balanced => &self.balanced, Profile::Balanced => &self.balanced,
Profile::Performance => &self.performance, Profile::Performance => &self.performance,
@@ -301,37 +362,59 @@ impl FanCurveProfiles {
} }
} }
pub fn get_fan_curve_for(&self, name: &Profile, pu: &FanCurvePU) -> &CurveData { pub fn get_fan_curve_for(&self, name: &Profile, pu: FanCurvePU) -> Option<&CurveData> {
match name { match name {
Profile::Balanced => match pu { Profile::Balanced => {
FanCurvePU::CPU => &self.balanced.cpu, for this_curve in self.balanced.iter() {
FanCurvePU::GPU => &self.balanced.gpu, if this_curve.fan == pu {
}, return Some(this_curve);
Profile::Performance => match pu { }
FanCurvePU::CPU => &self.performance.cpu, }
FanCurvePU::GPU => &self.performance.gpu, }
}, Profile::Performance => {
Profile::Quiet => match pu { for this_curve in self.performance.iter() {
FanCurvePU::CPU => &self.quiet.cpu, if this_curve.fan == pu {
FanCurvePU::GPU => &self.quiet.gpu, return Some(this_curve);
}, }
}
}
Profile::Quiet => {
for this_curve in self.quiet.iter() {
if this_curve.fan == pu {
return Some(this_curve);
}
}
}
} }
None
} }
pub fn save_fan_curve(&mut self, curve: CurveData, profile: Profile) -> std::io::Result<()> { pub fn save_fan_curve(&mut self, curve: CurveData, profile: Profile) -> std::io::Result<()> {
match profile { match profile {
Profile::Balanced => match curve.fan { Profile::Balanced => {
FanCurvePU::CPU => self.balanced.cpu = curve, for this_curve in self.balanced.iter_mut() {
FanCurvePU::GPU => self.balanced.gpu = curve, if this_curve.fan == curve.fan {
}, *this_curve = curve;
Profile::Performance => match curve.fan { break;
FanCurvePU::CPU => self.performance.cpu = curve, }
FanCurvePU::GPU => self.performance.gpu = curve, }
}, }
Profile::Quiet => match curve.fan { Profile::Performance => {
FanCurvePU::CPU => self.quiet.cpu = curve, for this_curve in self.performance.iter_mut() {
FanCurvePU::GPU => self.quiet.gpu = curve, if this_curve.fan == curve.fan {
}, *this_curve = curve;
break;
}
}
}
Profile::Quiet => {
for this_curve in self.quiet.iter_mut() {
if this_curve.fan == curve.fan {
*this_curve = curve;
break;
}
}
}
} }
Ok(()) Ok(())
} }