Compare commits

..

33 Commits

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

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

See merge request asus-linux/asusctl!210
2024-12-28 04:32:17 +00:00
Luke D. Jones
fd3384decc Minor test of platform attributes 2024-12-28 10:56:34 +13:00
Luke D. Jones
a1a9c7077a Rename dbus. Add asus_armoury client source 2024-12-26 21:36:07 +13:00
Luke D. Jones
62aa1fe04f Add initial dbus draft of asus_armoury attrs 2024-12-26 16:41:17 +13:00
kamack38
72c0b24ead feat(rog-aura): 🎸 Add G533QS aura support 2024-12-23 00:18:46 +01:00
146 changed files with 4284 additions and 3468 deletions

View File

@@ -2,6 +2,42 @@
## [Unreleased]
## [v6.1.0-rc6]
### Changed
- Two small fixes, one for `low-power` profile name, and one for base gpu tdp
- Move to using platform_profile api only (no throttle_thermal_policy)
## [v6.1.0-rc5]
### Changed
- Per-AC/DC, per-profile tunings enabled (Battery vs AC power + platform profile)
- Add ability to restore PPT defaults
- Add PPT help dialogue to UI
- Bug fix: correctly set charge limit from UI
## [v6.1.0-rc4]
### Changed
- Bug fix: UI was setting incorrect value for FPPT
- Bug fix: Re-add callbacks for the throttle and epp settings in UI
- Bug fix: Fix UI settigns for AniMe Matrix display
- Bug fix: better handle missing tray (for example gnome)
- Strip out all outdated and unsafe tuning stuff
- Allow each performance profile to have different PPT settings
## [v6.1.0-rc3]
### Changed
- Bug fixes
- Partial support for per-profile CPU tunings (WIP)
## [v6.1.0-rc2]
### Added
- asus-armoury driver support. WIP, will be adjusted/changed further
- More "Slash" display controls
## [v6.1.0-rc1]
### Added

262
Cargo.lock generated
View File

@@ -135,7 +135,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -176,10 +176,12 @@ dependencies = [
[[package]]
name = "asusctl"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"dmi_id",
"env_logger",
"gumdrop",
"log",
"rog_anime",
"rog_aura",
"rog_dbus",
@@ -193,7 +195,7 @@ dependencies = [
[[package]]
name = "asusd"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"cargo-husky",
"concat-idents",
@@ -219,7 +221,7 @@ dependencies = [
[[package]]
name = "asusd-user"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"config-traits",
"dirs",
@@ -350,7 +352,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -390,7 +392,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -407,7 +409,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -425,7 +427,7 @@ dependencies = [
"derive_utils",
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -550,7 +552,7 @@ dependencies = [
"regex",
"rustc-hash 1.1.0",
"shlex",
"syn 2.0.91",
"syn 2.0.93",
"which",
]
@@ -571,7 +573,7 @@ dependencies = [
"regex",
"rustc-hash 2.1.0",
"shlex",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -682,7 +684,7 @@ checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -750,9 +752,9 @@ checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad"
[[package]]
name = "cc"
version = "1.2.5"
version = "1.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e"
checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333"
dependencies = [
"jobserver",
"libc",
@@ -885,7 +887,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f76990911f2267d837d9d0ad060aa63aaad170af40904b29461734c339030d4d"
dependencies = [
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -899,7 +901,7 @@ dependencies = [
[[package]]
name = "config-traits"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"log",
"ron",
@@ -948,7 +950,7 @@ dependencies = [
[[package]]
name = "const-field-offset"
version = "0.1.5"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"const-field-offset-macro",
"field-offset",
@@ -957,11 +959,11 @@ dependencies = [
[[package]]
name = "const-field-offset-macro"
version = "0.1.5"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -1079,10 +1081,6 @@ version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636"
[[package]]
name = "cpuctl"
version = "6.1.0-rc1"
[[package]]
name = "cpufeatures"
version = "0.2.16"
@@ -1201,7 +1199,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
"unicode-xid",
]
@@ -1213,7 +1211,7 @@ checksum = "65f152f4b8559c4da5d574bafc7af85454d706b4c5fe8b530d508cacbb6807ea"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -1281,7 +1279,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -1295,7 +1293,7 @@ dependencies = [
[[package]]
name = "dmi_id"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"log",
"udev 0.8.0",
@@ -1397,7 +1395,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -1491,9 +1489,9 @@ dependencies = [
[[package]]
name = "femtovg"
version = "0.11.2"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eafc3dd3c956423a6669e1f6f9ab23261dbe45cdb24ce23dba38b0389b8a8ff8"
checksum = "36d63bc3ab69493186eefc2568dddc21d2fe5f3c552edc64def6c42297ec9bbd"
dependencies = [
"bitflags 2.6.0",
"bytemuck",
@@ -1608,7 +1606,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -1695,7 +1693,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -1849,9 +1847,9 @@ dependencies = [
[[package]]
name = "glob"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
[[package]]
name = "glow"
@@ -2168,8 +2166,8 @@ dependencies = [
[[package]]
name = "i-slint-backend-linuxkms"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"calloop 0.14.2",
"drm",
@@ -2186,8 +2184,8 @@ dependencies = [
[[package]]
name = "i-slint-backend-selector"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"cfg-if",
"i-slint-backend-linuxkms",
@@ -2199,8 +2197,8 @@ dependencies = [
[[package]]
name = "i-slint-backend-winit"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"ashpd",
"cfg-if",
@@ -2230,8 +2228,8 @@ dependencies = [
[[package]]
name = "i-slint-common"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"cfg-if",
"derive_more",
@@ -2242,8 +2240,8 @@ dependencies = [
[[package]]
name = "i-slint-compiler"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"by_address",
"codemap",
@@ -2272,8 +2270,8 @@ dependencies = [
[[package]]
name = "i-slint-core"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"auto_enums",
"bitflags 2.6.0",
@@ -2317,18 +2315,18 @@ dependencies = [
[[package]]
name = "i-slint-core-macros"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"quote",
"serde_json",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
name = "i-slint-renderer-femtovg"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"cfg-if",
"const-field-offset",
@@ -2357,8 +2355,8 @@ dependencies = [
[[package]]
name = "i-slint-renderer-skia"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"bytemuck",
"cfg-if",
@@ -2526,7 +2524,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -2691,7 +2689,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -3269,7 +3267,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -3320,7 +3318,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -3643,7 +3641,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -3765,7 +3763,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033"
dependencies = [
"proc-macro2",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -3802,7 +3800,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30"
dependencies = [
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -3825,7 +3823,7 @@ dependencies = [
"itertools 0.13.0",
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -3872,9 +3870,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.37"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
dependencies = [
"proc-macro2",
]
@@ -4094,7 +4092,7 @@ dependencies = [
[[package]]
name = "rog-control-center"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"asusd",
"concat-idents",
@@ -4124,7 +4122,7 @@ dependencies = [
[[package]]
name = "rog_anime"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"dmi_id",
"gif 0.12.0",
@@ -4133,25 +4131,23 @@ dependencies = [
"pix",
"png_pong",
"serde",
"typeshare",
"zbus 5.2.0",
]
[[package]]
name = "rog_aura"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"dmi_id",
"log",
"ron",
"serde",
"typeshare",
"zbus 5.2.0",
]
[[package]]
name = "rog_dbus"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"asusd",
"rog_anime",
@@ -4165,44 +4161,41 @@ dependencies = [
[[package]]
name = "rog_platform"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"concat-idents",
"inotify",
"log",
"rusb",
"serde",
"typeshare",
"udev 0.8.0",
"zbus 5.2.0",
]
[[package]]
name = "rog_profiles"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"log",
"rog_platform",
"serde",
"typeshare",
"udev 0.8.0",
"zbus 5.2.0",
]
[[package]]
name = "rog_scsi"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"ron",
"serde",
"sg",
"typeshare",
"zbus 5.2.0",
]
[[package]]
name = "rog_simulators"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"log",
"rog_anime",
@@ -4212,11 +4205,10 @@ dependencies = [
[[package]]
name = "rog_slash"
version = "6.1.0-rc1"
version = "6.1.0-rc6"
dependencies = [
"dmi_id",
"serde",
"typeshare",
"zbus 5.2.0",
]
@@ -4302,9 +4294,9 @@ dependencies = [
[[package]]
name = "rustversion"
version = "1.0.18"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248"
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
[[package]]
name = "rustybuzz"
@@ -4419,22 +4411,22 @@ checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba"
[[package]]
name = "serde"
version = "1.0.216"
version = "1.0.217"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e"
checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.216"
version = "1.0.217"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e"
checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -4457,7 +4449,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -4584,8 +4576,8 @@ dependencies = [
[[package]]
name = "slint"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"const-field-offset",
"i-slint-backend-selector",
@@ -4601,8 +4593,8 @@ dependencies = [
[[package]]
name = "slint-build"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"i-slint-compiler",
"i-slint-core-macros",
@@ -4613,8 +4605,8 @@ dependencies = [
[[package]]
name = "slint-macros"
version = "1.9.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"i-slint-compiler",
"proc-macro2",
@@ -4799,7 +4791,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -4840,9 +4832,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.91"
version = "2.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d53cbcb5a243bd33b7858b1d7f4aca2153490815872d86d955d6ea29f743c035"
checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058"
dependencies = [
"proc-macro2",
"quote",
@@ -4863,7 +4855,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -4967,7 +4959,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -5099,7 +5091,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -5256,7 +5248,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -5320,28 +5312,6 @@ version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "typeshare"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19be0f411120091e76e13e5a0186d8e2bcc3e7e244afdb70152197f1a8486ceb"
dependencies = [
"chrono",
"serde",
"serde_json",
"typeshare-annotation",
]
[[package]]
name = "typeshare-annotation"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a615d6c2764852a2e88a4f16e9ce1ea49bb776b5872956309e170d63a042a34f"
dependencies = [
"quote",
"syn 2.0.91",
]
[[package]]
name = "udev"
version = "0.8.0"
@@ -5380,9 +5350,9 @@ dependencies = [
[[package]]
name = "uhid-virt"
version = "0.0.7"
version = "0.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f70f1f603b96df07624cdd31be4496a983a3f7f079cf2606aa289719114249f"
checksum = "fad50862a51d693d984b07f6f6263a571554d415f5d1e16f4cbad2c266448e1b"
dependencies = [
"enumflags2",
"libc",
@@ -5391,11 +5361,11 @@ dependencies = [
[[package]]
name = "uhidrs-sys"
version = "1.0.3"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e24880fbcee511571ed9104b9a5273d1563d11ccaaf54b7c05cc6c100b652f9f"
checksum = "aec7103e0167479f230f6baae49dbf714074d91b2ff141983524d7417c0b98a8"
dependencies = [
"bindgen 0.69.5",
"bindgen 0.71.1",
]
[[package]]
@@ -5575,7 +5545,7 @@ dependencies = [
[[package]]
name = "vtable"
version = "0.2.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"const-field-offset",
"portable-atomic",
@@ -5586,11 +5556,11 @@ dependencies = [
[[package]]
name = "vtable-macro"
version = "0.2.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d"
source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -5639,7 +5609,7 @@ dependencies = [
"log",
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
"wasm-bindgen-shared",
]
@@ -5674,7 +5644,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -5925,7 +5895,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -5936,7 +5906,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -5947,7 +5917,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -5958,7 +5928,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -6266,9 +6236,9 @@ dependencies = [
[[package]]
name = "winnow"
version = "0.6.20"
version = "0.6.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"
checksum = "e6f5bb5257f2407a5425c6e749bfd9692192a73e70a6060516ac04f889087d68"
dependencies = [
"memchr",
]
@@ -6425,7 +6395,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
"synstructure",
]
@@ -6512,7 +6482,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
"zvariant_utils 2.1.0",
]
@@ -6525,7 +6495,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
"zbus_names 4.1.0",
"zvariant 5.1.0",
"zvariant_utils 3.0.2",
@@ -6572,7 +6542,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -6592,7 +6562,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
"synstructure",
]
@@ -6615,7 +6585,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -6680,7 +6650,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
"zvariant_utils 2.1.0",
]
@@ -6693,7 +6663,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
"zvariant_utils 3.0.2",
]
@@ -6705,7 +6675,7 @@ checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.91",
"syn 2.0.93",
]
[[package]]
@@ -6718,6 +6688,6 @@ dependencies = [
"quote",
"serde",
"static_assertions",
"syn 2.0.91",
"syn 2.0.93",
"winnow",
]

View File

@@ -1,5 +1,5 @@
[workspace.package]
version = "6.1.0-rc1"
version = "6.1.0-rc6"
rust-version = "1.82"
license = "MPL-2.0"
readme = "README.md"
@@ -12,36 +12,31 @@ edition = "2021"
[workspace]
resolver = "2"
members = [
"asusctl",
"asusd",
"asusd-user",
"config-traits",
"cpuctl",
"dmi-id",
"rog-platform",
"rog-dbus",
"rog-anime",
"rog-aura",
"rog-profiles",
"rog-control-center",
"rog-slash",
"simulators", "rog-scsi",
]
default-members = [
"asusctl",
"asusd",
"asusd-user",
"cpuctl",
"rog-control-center",
"asusctl",
"asusd",
"asusd-user",
"config-traits",
"dmi-id",
"rog-platform",
"rog-dbus",
"rog-anime",
"rog-aura",
"rog-profiles",
"rog-control-center",
"rog-slash",
"simulators",
"rog-scsi",
]
default-members = ["asusctl", "asusd", "asusd-user", "rog-control-center"]
[workspace.dependencies]
tokio = { version = "^1.39.0", default-features = false, features = [
"macros",
"sync",
"time",
"rt",
"rt-multi-thread",
"macros",
"sync",
"time",
"rt",
"rt-multi-thread",
] }
concat-idents = "^1.1"
dirs = "^4.0"
@@ -53,7 +48,6 @@ logind-zbus = { version = "5.0.0" } #, default-features = false, features = ["no
serde = { version = "^1.0", features = ["serde_derive"] }
ron = "*"
typeshare = "1.0.0"
log = "^0.4"
env_logger = "^0.10.0"
@@ -73,7 +67,7 @@ versions = "6.2"
notify-rust = { version = "4.11.0", features = ["z", "async"] }
sg = {git = "https://github.com/flukejones/sg-rs.git"}
sg = { git = "https://github.com/flukejones/sg-rs.git" }
[profile.release]
# thin = 57s, asusd = 9.0M

View File

@@ -1,4 +1,4 @@
VERSION := $(shell /usr/bin/grep -Pm1 'version = "(\d+.\d+.\d+)"' Cargo.toml | cut -d'"' -f2)
VERSION := $(shell /usr/bin/grep -Pm1 'version = "(\d+.\d+.\d+.*)"' Cargo.toml | cut -d'"' -f2)
INSTALL = install
INSTALL_PROGRAM = ${INSTALL} -D -m 0755
@@ -19,7 +19,7 @@ LEDCFG := aura_support.ron
SRC := Cargo.toml Cargo.lock Makefile $(shell find -type f -wholename '**/src/*.rs')
STRIP_BINARIES ?= 1
STRIP_BINARIES ?= 0
DEBUG ?= 0
ifeq ($(DEBUG),0)
@@ -122,12 +122,6 @@ vendor:
tar pcfJ vendor_asusctl_$(VERSION).tar.xz vendor
rm -rf vendor
bindings:
typeshare ./rog-anime/src/ --lang=typescript --output-file=bindings/ts/anime.ts
typeshare ./rog-aura/src/ --lang=typescript --output-file=bindings/ts/aura.ts
typeshare ./rog-profiles/src/ --lang=typescript --output-file=bindings/ts/profiles.ts
typeshare ./rog-platform/src/ --lang=typescript --output-file=bindings/ts/platform.ts
translate:
find -name \*.slint | xargs slint-tr-extractor -o rog-control-center/translations/en/rog-control-center.po

View File

@@ -1,6 +1,6 @@
# `asusctl` for ASUS ROG
[Become a Patron!](https://www.patreon.com/bePatron?u=7602281) - [Asus Linux Website](https://asus-linux.org/)
[![Become a Patron!](https://github.com/codebard/patron-button-and-widgets-by-codebard/blob/master/images/become_a_patron_button.png?raw=true)](https://www.patreon.com/bePatron?u=7602281) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/V7V5CLU67) - [Asus Linux Website](https://asus-linux.org/)
**WARNING:** Many features are developed in tandem with kernel patches. If you see a feature is missing you either need a patched kernel or latest release.
@@ -11,7 +11,9 @@ Now includes a GUI, `rog-control-center`.
## Kernel support
**The minimum supported kernel version is 6.10**, which will contain the patches from [here](https://lore.kernel.org/platform-driver-x86/20240404001652.86207-1-luke@ljones.dev/). This is especially required for 2023+ devices and possibly some late 2022 devices.
Due to on-going driver work the minimum suggested kernel version is always **the latest*, as improvements and fixes are continuous.
Support for some new features is not avilable unless you run a patched kernel with the work I am doing [in this github repo](https://github.com/flukejones/linux/tree/wip/ally-6.13). Use the linked branch, or `wip/ally-6.12`. Everything that is done here is upstreamed eventually (a long process).
Z13 devices will need [these](https://lore.kernel.org/linux-input/20240416090402.31057-1-luke@ljones.dev/T/#t)

View File

@@ -18,10 +18,12 @@ rog_profiles = { path = "../rog-profiles" }
rog_platform = { path = "../rog-platform" }
dmi_id = { path = "../dmi-id" }
log.workspace = true
env_logger.workspace = true
ron.workspace = true
gumdrop.workspace = true
zbus.workspace = true
[dev-dependencies]
rog_dbus = { path = "../rog-dbus" }

View File

@@ -23,7 +23,7 @@ fn main() -> Result<(), Box<dyn Error>> {
Path::new(&args[1]),
None,
args[2].parse::<f32>().unwrap(),
AnimeType::GA401,
AnimeType::GA401
)?;
let anime_type = get_anime_type();

View File

@@ -21,14 +21,11 @@ fn main() {
let brightness = args[2].parse::<f32>().unwrap();
let anime_type = get_anime_type();
let mut seq = Sequences::new(anime_type);
seq.insert(
0,
&ActionLoader::AsusAnimation {
file: path.into(),
time: rog_anime::AnimTime::Infinite,
brightness,
},
)
seq.insert(0, &ActionLoader::AsusAnimation {
file: path.into(),
time: rog_anime::AnimTime::Infinite,
brightness
})
.unwrap();
loop {

View File

@@ -27,10 +27,10 @@ fn main() -> Result<(), Box<dyn Error>> {
args[3].parse::<f32>().unwrap(),
Vec2::new(
args[4].parse::<f32>().unwrap(),
args[5].parse::<f32>().unwrap(),
args[5].parse::<f32>().unwrap()
),
args[6].parse::<f32>().unwrap(),
anime_type,
anime_type
)?;
proxy.write(<AnimeDataBuffer>::try_from(&matrix)?).unwrap();

View File

@@ -30,10 +30,10 @@ fn main() -> Result<(), Box<dyn Error>> {
args[3].parse::<f32>().unwrap(),
Vec2::new(
args[4].parse::<f32>().unwrap(),
args[5].parse::<f32>().unwrap(),
args[5].parse::<f32>().unwrap()
),
args[6].parse::<f32>().unwrap(),
anime_type,
anime_type
)?;
loop {

View File

@@ -36,10 +36,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Colour {
r: 200,
g: 110,
b: 0,
b: 0
},
100,
10,
10
));
seq.push(zone);

View File

@@ -40,7 +40,7 @@ pub struct AnimeCommand {
#[options(no_short, meta = "", help = "Off with his head!!!")]
pub off_with_his_head: Option<bool>,
#[options(command)]
pub command: Option<AnimeActions>,
pub command: Option<AnimeActions>
}
#[derive(Options)]
@@ -54,7 +54,7 @@ pub enum AnimeActions {
#[options(help = "display an animated diagonal/pixel-perfect GIF")]
PixelGif(AnimeGifDiagonal),
#[options(help = "change which builtin animations are shown")]
SetBuiltins(Builtins),
SetBuiltins(Builtins)
}
#[derive(Options)]
@@ -82,7 +82,7 @@ pub struct Builtins {
)]
pub shutdown: AnimShutdown,
#[options(meta = "", help = "set/apply the animations <true/false>")]
pub set: Option<bool>,
pub set: Option<bool>
}
#[derive(Options)]
@@ -100,7 +100,7 @@ pub struct AnimeImage {
#[options(meta = "", default = "0.0", help = "the angle in radians")]
pub angle: f32,
#[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")]
pub bright: f32,
pub bright: f32
}
#[derive(Options)]
@@ -110,7 +110,7 @@ pub struct AnimeImageDiagonal {
#[options(meta = "", help = "full path to the png to display")]
pub path: String,
#[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")]
pub bright: f32,
pub bright: f32
}
#[derive(Options)]
@@ -134,7 +134,7 @@ pub struct AnimeGif {
default = "1",
help = "how many loops to play - 0 is infinite"
)]
pub loops: u32,
pub loops: u32
}
#[derive(Options)]
@@ -150,5 +150,5 @@ pub struct AnimeGifDiagonal {
default = "1",
help = "how many loops to play - 0 is infinite"
)]
pub loops: u32,
pub loops: u32
}

View File

@@ -17,7 +17,7 @@ pub struct LedPowerCommand1 {
#[options(meta = "", help = "Control boot animations <true/false>")]
pub boot: Option<bool>,
#[options(meta = "", help = "Control suspend animations <true/false>")]
pub sleep: Option<bool>,
pub sleep: Option<bool>
}
#[derive(Options, Debug)]
@@ -25,7 +25,7 @@ pub struct LedPowerCommand2 {
#[options(help = "print help message")]
pub help: bool,
#[options(command)]
pub command: Option<SetAuraZoneEnabled>,
pub command: Option<SetAuraZoneEnabled>
}
#[derive(Options, Debug)]
@@ -42,7 +42,7 @@ pub enum SetAuraZoneEnabled {
#[options(help = "")]
RearGlow(AuraPowerStates),
#[options(help = "")]
Ally(AuraPowerStates),
Ally(AuraPowerStates)
}
#[derive(Debug, Clone, Options)]
@@ -56,12 +56,12 @@ pub struct AuraPowerStates {
#[options(help = "defaults to false if option unused")]
pub sleep: bool,
#[options(help = "defaults to false if option unused")]
pub shutdown: bool,
pub shutdown: bool
}
#[derive(Options)]
pub struct LedBrightness {
level: Option<u8>,
level: Option<u8>
}
impl LedBrightness {
pub fn new(level: Option<u8>) -> Self {
@@ -96,7 +96,7 @@ impl ToString for LedBrightness {
Some(0x00) => "low",
Some(0x01) => "med",
Some(0x02) => "high",
_ => "unknown",
_ => "unknown"
};
s.to_owned()
}
@@ -113,7 +113,7 @@ pub struct SingleSpeed {
meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
)]
pub zone: AuraZone,
pub zone: AuraZone
}
#[derive(Debug, Clone, Options, Default)]
@@ -129,7 +129,7 @@ pub struct SingleSpeedDirection {
meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
)]
pub zone: AuraZone,
pub zone: AuraZone
}
#[derive(Debug, Clone, Default, Options)]
@@ -143,7 +143,7 @@ pub struct SingleColour {
meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
)]
pub zone: AuraZone,
pub zone: AuraZone
}
#[derive(Debug, Clone, Default, Options)]
@@ -159,7 +159,7 @@ pub struct SingleColourSpeed {
meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
)]
pub zone: AuraZone,
pub zone: AuraZone
}
#[derive(Debug, Clone, Options, Default)]
@@ -177,7 +177,7 @@ pub struct TwoColourSpeed {
meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
)]
pub zone: AuraZone,
pub zone: AuraZone
}
#[derive(Debug, Clone, Default, Options)]
@@ -191,7 +191,7 @@ pub struct MultiZone {
#[options(short = "c", meta = "", help = "set the RGB value e.g, ff00ff")]
pub colour3: Colour,
#[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")]
pub colour4: Colour,
pub colour4: Colour
}
#[derive(Debug, Clone, Default, Options)]
@@ -207,7 +207,7 @@ pub struct MultiColourSpeed {
#[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")]
pub colour4: Colour,
#[options(no_long, meta = "", help = "set the speed: low, med, high")]
pub speed: Speed,
pub speed: Speed
}
/// Byte value for setting the built-in mode.
@@ -239,7 +239,7 @@ pub enum SetAuraBuiltin {
#[options(help = "set a vertical line zooming from left")]
Comet(SingleColour), // 11
#[options(help = "set a wide vertical line zooming from left")]
Flash(SingleColour), // 12
Flash(SingleColour) // 12
}
impl Default for SetAuraBuiltin {

View File

@@ -1,5 +1,5 @@
use gumdrop::Options;
use rog_platform::platform::ThrottlePolicy;
use rog_platform::platform::PlatformProfile;
use crate::anime_cli::AnimeCommand;
use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin};
@@ -26,7 +26,7 @@ pub struct CliStart {
#[options(help = "Toggle one-shot battery charge to 100%")]
pub one_shot_chg: bool,
#[options(command)]
pub command: Option<CliCommand>,
pub command: Option<CliCommand>
}
#[derive(Options)]
@@ -49,8 +49,11 @@ pub enum CliCommand {
Slash(SlashCommand),
#[options(name = "scsi", help = "Manage SCSI external drive")]
Scsi(ScsiCommand),
#[options(help = "Change bios settings")]
Platform(PlatformCommand),
#[options(
help = "Change platform settings. This is a new interface exposed by the asus-armoury \
driver, some of the settings will be the same as the older platform interface"
)]
Armoury(ArmouryCommand)
}
#[derive(Debug, Clone, Options)]
@@ -68,7 +71,7 @@ pub struct ProfileCommand {
pub profile_get: bool,
#[options(meta = "", help = "set the active profile")]
pub profile_set: Option<ThrottlePolicy>,
pub profile_set: Option<PlatformProfile>
}
#[derive(Options)]
@@ -80,44 +83,22 @@ pub struct LedModeCommand {
#[options(help = "switch to previous aura mode")]
pub prev_mode: bool,
#[options(command)]
pub command: Option<SetAuraBuiltin>,
pub command: Option<SetAuraBuiltin>
}
#[derive(Options)]
pub struct GraphicsCommand {
#[options(help = "print help message")]
pub help: bool,
pub help: bool
}
#[derive(Options, Debug)]
pub struct PlatformCommand {
pub struct ArmouryCommand {
#[options(help = "print help message")]
pub help: bool,
#[options(
meta = "",
short = "S",
no_long,
help = "set bios POST sound: asusctl -S <true/false>"
free,
help = "append each value name followed by the value to set. `-1` sets to default"
)]
pub post_sound_set: Option<bool>,
#[options(no_long, short = "s", help = "read bios POST sound")]
pub post_sound_get: bool,
#[options(
meta = "",
short = "D",
no_long,
help = "Switch GPU MUX mode: 0 = Discrete, 1 = Optimus, reboot required"
)]
pub gpu_mux_mode_set: Option<u8>,
#[options(no_long, short = "d", help = "get GPU mode")]
pub gpu_mux_mode_get: bool,
#[options(
meta = "",
short = "O",
no_long,
help = "Set device panel overdrive <true/false>"
)]
pub panel_overdrive_set: Option<bool>,
#[options(no_long, short = "o", help = "get panel overdrive")]
pub panel_overdrive_get: bool,
pub free: Vec<String>
}

View File

@@ -1,5 +1,5 @@
use gumdrop::Options;
use rog_platform::platform::ThrottlePolicy;
use rog_platform::platform::PlatformProfile;
use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU;
@@ -18,7 +18,7 @@ pub struct FanCurveCommand {
meta = "",
help = "profile to modify fan-curve for. Shows data if no options provided"
)]
pub mod_profile: Option<ThrottlePolicy>,
pub mod_profile: Option<PlatformProfile>,
#[options(
meta = "",
@@ -45,5 +45,5 @@ pub struct FanCurveCommand {
help = "data format = 30c:1%,49c:2%,59c:3%,69c:4%,79c:31%,89c:49%,99c:56%,109c:58%. \
`--mod-profile` required. If '%' is omitted the fan range is 0-255"
)]
pub data: Option<CurveData>,
pub data: Option<CurveData>
}

View File

@@ -9,10 +9,12 @@ use aura_cli::{LedPowerCommand1, LedPowerCommand2};
use dmi_id::DMIID;
use fan_curve_cli::FanCurveCommand;
use gumdrop::{Opt, Options};
use log::{error, info};
use rog_anime::usb::get_anime_type;
use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2};
use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower};
use rog_aura::{self, AuraDeviceType, AuraEffect, PowerZones};
use rog_dbus::asus_armoury::AsusArmouryProxyBlocking;
use rog_dbus::list_iface_blocking;
use rog_dbus::scsi_aura::ScsiAuraProxyBlocking;
use rog_dbus::zbus_anime::AnimeProxyBlocking;
@@ -20,7 +22,7 @@ use rog_dbus::zbus_aura::AuraProxyBlocking;
use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking;
use rog_dbus::zbus_platform::PlatformProxyBlocking;
use rog_dbus::zbus_slash::SlashProxyBlocking;
use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy};
use rog_platform::platform::{PlatformProfile, Properties};
use rog_profiles::error::ProfileError;
use rog_scsi::AuraMode;
use rog_slash::SlashMode;
@@ -41,6 +43,14 @@ mod scsi_cli;
mod slash_cli;
fn main() {
let mut logger = env_logger::Builder::new();
logger
.parse_default_env()
.target(env_logger::Target::Stdout)
.format_timestamp(None)
.filter_level(log::LevelFilter::Debug)
.init();
let self_version = env!("CARGO_PKG_VERSION");
println!("Starting version {self_version}");
let args: Vec<String> = args().skip(1).collect();
@@ -88,7 +98,7 @@ fn main() {
fn print_error_help(
err: &dyn std::error::Error,
supported_interfaces: &[String],
supported_properties: &[Properties],
supported_properties: &[Properties]
) {
check_service("asusd");
println!("\nError: {}\n", err);
@@ -129,11 +139,10 @@ fn check_service(name: &str) -> bool {
fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>,
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>
{
let conn = zbus::blocking::Connection::system().unwrap();
let f =
zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").unwrap();
let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
let interfaces = f.get_managed_objects().unwrap();
let mut paths = Vec::new();
for v in interfaces.iter() {
@@ -141,35 +150,36 @@ where
// e.to_owned()).collect(); println!("{}, {:?}", v.0, o);
for k in v.1.keys() {
if k.as_str() == iface_name {
println!("Found {iface_name} device at {}, {}", v.0, k);
// println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone());
}
}
}
if paths.len() > 1 {
println!("Multiple aura devices found: {paths:?}");
println!("Multiple asusd interfaces devices found");
}
if !paths.is_empty() {
let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(b));
for path in paths {
ctrl.push(
T::builder(&conn)
.path(path.clone())?
.destination("org.asuslinux.Daemon")?
.build()?,
.destination("xyz.ljones.Asusd")?
.build()?
);
}
return Ok(ctrl);
}
Err("No Aura interface".into())
Err(format!("Did not find {iface_name}").into())
}
fn do_parsed(
parsed: &CliStart,
supported_interfaces: &[String],
supported_properties: &[Properties],
conn: Connection,
conn: Connection
) -> Result<(), Box<dyn std::error::Error>> {
match &parsed.command {
Some(CliCommand::Aura(mode)) => handle_led_mode(mode)?,
@@ -185,9 +195,7 @@ fn do_parsed(
Some(CliCommand::Anime(cmd)) => handle_anime(cmd)?,
Some(CliCommand::Slash(cmd)) => handle_slash(cmd)?,
Some(CliCommand::Scsi(cmd)) => handle_scsi(cmd)?,
Some(CliCommand::Platform(cmd)) => {
handle_platform_properties(&conn, supported_properties, cmd)?
}
Some(CliCommand::Armoury(cmd)) => handle_armoury_command(cmd)?,
None => {
if (!parsed.show_supported
&& parsed.kbd_bright.is_none()
@@ -201,7 +209,7 @@ fn do_parsed(
println!();
if let Some(cmdlist) = CliStart::command_list() {
let dev_type =
if let Ok(proxy) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") {
if let Ok(proxy) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
// TODO: commands on all?
proxy
.first()
@@ -214,32 +222,37 @@ fn do_parsed(
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
for command in commands.iter().filter(|command| {
if command.trim().starts_with("fan-curve")
&& !supported_interfaces
.contains(&"org.asuslinux.FanCurves".to_string())
&& !supported_interfaces.contains(&"xyz.ljones.FanCurves".to_string())
{
return false;
}
if command.trim().starts_with("aura")
&& !supported_interfaces.contains(&"org.asuslinux.Aura".to_string())
&& !supported_interfaces.contains(&"xyz.ljones.Aura".to_string())
{
return false;
}
if command.trim().starts_with("anime")
&& !supported_interfaces.contains(&"org.asuslinux.Anime".to_string())
&& !supported_interfaces.contains(&"xyz.ljones.Anime".to_string())
{
return false;
}
if command.trim().starts_with("slash")
&& !supported_interfaces.contains(&"org.asuslinux.Slash".to_string())
&& !supported_interfaces.contains(&"xyz.ljones.Slash".to_string())
{
return false;
}
if command.trim().starts_with("platform")
&& !supported_interfaces.contains(&"org.asuslinux.Platform".to_string())
&& !supported_interfaces.contains(&"xyz.ljones.Platform".to_string())
{
return false;
}
if command.trim().starts_with("platform")
&& !supported_interfaces.contains(&"xyz.ljones.AsusArmoury".to_string())
{
return false;
}
@@ -267,14 +280,14 @@ fn do_parsed(
}
if let Some(brightness) = &parsed.kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() {
match brightness.level() {
None => {
let level = aura.brightness()?;
println!("Current keyboard led brightness: {level:?}");
}
Some(level) => aura.set_brightness(rog_aura::LedBrightness::from(level))?,
Some(level) => aura.set_brightness(rog_aura::LedBrightness::from(level))?
}
}
} else {
@@ -283,7 +296,7 @@ fn do_parsed(
}
if parsed.next_kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() {
let brightness = aura.brightness()?;
aura.set_brightness(brightness.next())?;
@@ -294,7 +307,7 @@ fn do_parsed(
}
if parsed.prev_kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() {
let brightness = aura.brightness()?;
aura.set_brightness(brightness.prev())?;
@@ -310,7 +323,7 @@ fn do_parsed(
"Supported Platform Properties:\n{:#?}",
supported_properties
);
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
// TODO: multiple RGB check
let bright = aura.first().unwrap().supported_brightness()?;
let modes = aura.first().unwrap().supported_basic_modes()?;
@@ -363,7 +376,12 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
println!("\n{}", lst);
}
}
let animes = find_iface::<AnimeProxyBlocking>("org.asuslinux.Anime")?;
let animes = find_iface::<AnimeProxyBlocking>("xyz.ljones.Anime").map_err(|e| {
error!("Did not find any interface for xyz.ljones.Anime: {e:?}");
e
})?;
for proxy in animes {
if let Some(enable) = cmd.enable_display {
proxy.set_enable_display(enable)?;
@@ -418,7 +436,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
image.angle,
Vec2::new(image.x_pos, image.y_pos),
image.bright,
anime_type,
anime_type
)?;
proxy.write(<AnimeDataBuffer>::try_from(&matrix)?)?;
@@ -437,7 +455,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
Path::new(&image.path),
None,
image.bright,
anime_type,
anime_type
)?;
proxy.write(matrix.into_data_buffer(anime_type)?)?;
@@ -459,7 +477,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
Vec2::new(gif.x_pos, gif.y_pos),
AnimTime::Count(1),
gif.bright,
anime_type,
anime_type
)?;
let mut loops = gif.loops as i32;
@@ -490,7 +508,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
Path::new(&gif.path),
AnimTime::Count(1),
gif.bright,
anime_type,
anime_type
)?;
let mut loops = gif.loops as i32;
@@ -523,7 +541,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
boot: builtins.boot,
awake: builtins.awake,
sleep: builtins.sleep,
shutdown: builtins.shutdown,
shutdown: builtins.shutdown
})?;
}
}
@@ -544,7 +562,12 @@ fn verify_brightness(brightness: f32) {
fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
if (cmd.brightness.is_none()
&& cmd.interval.is_none()
&& cmd.slash_mode.is_none()
&& cmd.show_on_boot.is_none()
&& cmd.show_on_shutdown.is_none()
&& cmd.show_on_sleep.is_none()
&& cmd.show_on_battery.is_none()
&& cmd.show_battery_warning.is_none()
&& cmd.mode.is_none()
&& !cmd.list
&& !cmd.enable
&& !cmd.disable)
@@ -556,7 +579,7 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
}
}
let slashes = find_iface::<SlashProxyBlocking>("org.asuslinux.Slash")?;
let slashes = find_iface::<SlashProxyBlocking>("xyz.ljones.Slash")?;
for proxy in slashes {
if cmd.enable {
proxy.set_enabled(true)?;
@@ -570,8 +593,24 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
if let Some(interval) = cmd.interval {
proxy.set_interval(interval)?;
}
if let Some(slash_mode) = cmd.slash_mode {
proxy.set_slash_mode(slash_mode)?;
if let Some(slash_mode) = cmd.mode {
proxy.set_mode(slash_mode)?;
}
if let Some(show) = cmd.show_on_boot {
proxy.set_show_on_boot(show)?;
}
if let Some(show) = cmd.show_on_shutdown {
proxy.set_show_on_shutdown(show)?;
}
if let Some(show) = cmd.show_on_sleep {
proxy.set_show_on_sleep(show)?;
}
if let Some(show) = cmd.show_on_battery {
proxy.set_show_on_battery(show)?;
}
if let Some(show) = cmd.show_battery_warning {
proxy.set_show_battery_warning(show)?;
}
}
if cmd.list {
@@ -594,7 +633,7 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box<dyn std::error::Error>> {
}
}
let scsis = find_iface::<ScsiAuraProxyBlocking>("org.asuslinux.ScsiAura")?;
let scsis = find_iface::<ScsiAuraProxyBlocking>("xyz.ljones.ScsiAura")?;
for scsi in scsis {
if let Some(enable) = cmd.enable {
@@ -609,8 +648,7 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box<dyn std::error::Error>> {
let mut mode = scsi.led_mode_data()?;
let mut do_update = false;
if !cmd.colours.is_empty() {
let mut count = 0;
for c in &cmd.colours {
for (count, c) in cmd.colours.iter().enumerate() {
if count == 0 {
mode.colour1 = *c;
}
@@ -623,7 +661,6 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box<dyn std::error::Error>> {
if count == 3 {
mode.colour4 = *c;
}
count += 1;
}
do_update = true;
}
@@ -668,7 +705,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
if let Some(cmdlist) = LedModeCommand::command_list() {
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
// TODO: multiple rgb check
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?;
let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
let modes = aura.first().unwrap().supported_basic_modes()?;
for command in commands.iter().filter(|command| {
for mode in &modes {
@@ -698,7 +735,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
println!("Please specify either next or previous");
return Ok(());
}
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?;
let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
if mode.next_mode {
for aura in aura {
let mode = aura.led_mode()?;
@@ -735,7 +772,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
}
fn handle_led_power1(power: &LedPowerCommand1) -> Result<(), Box<dyn std::error::Error>> {
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?;
let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
for aura in aura {
let dev_type = aura.device_type()?;
if !dev_type.is_old_laptop() && !dev_type.is_tuf_laptop() {
@@ -767,7 +804,7 @@ fn handle_led_power1(power: &LedPowerCommand1) -> Result<(), Box<dyn std::error:
fn handle_led_power_1_do_1866(
aura: &AuraProxyBlocking,
power: &LedPowerCommand1,
power: &LedPowerCommand1
) -> Result<(), Box<dyn std::error::Error>> {
let mut states = Vec::new();
if power.keyboard {
@@ -776,7 +813,7 @@ fn handle_led_power_1_do_1866(
boot: power.boot.unwrap_or_default(),
awake: power.awake.unwrap_or_default(),
sleep: power.sleep.unwrap_or_default(),
shutdown: false,
shutdown: false
});
}
if power.lightbar {
@@ -785,7 +822,7 @@ fn handle_led_power_1_do_1866(
boot: power.boot.unwrap_or_default(),
awake: power.awake.unwrap_or_default(),
sleep: power.sleep.unwrap_or_default(),
shutdown: false,
shutdown: false
});
}
@@ -795,7 +832,7 @@ fn handle_led_power_1_do_1866(
}
fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error::Error>> {
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?;
let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
for aura in aura {
let dev_type = aura.device_type()?;
if !dev_type.is_new_laptop() {
@@ -847,7 +884,7 @@ fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error:
aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(PowerZones::Lightbar, l),
aura_cli::SetAuraZoneEnabled::Lid(l) => set(PowerZones::Lid, l),
aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(PowerZones::RearGlow, r),
aura_cli::SetAuraZoneEnabled::Ally(r) => set(PowerZones::Ally, r),
aura_cli::SetAuraZoneEnabled::Ally(r) => set(PowerZones::Ally, r)
}
}
@@ -861,7 +898,7 @@ fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error:
fn handle_throttle_profile(
conn: &Connection,
supported: &[Properties],
cmd: &ProfileCommand,
cmd: &ProfileCommand
) -> Result<(), Box<dyn std::error::Error>> {
if !supported.contains(&Properties::ThrottlePolicy) {
println!("Profiles not supported by either this kernel or by the laptop.");
@@ -881,16 +918,16 @@ fn handle_throttle_profile(
}
let proxy = PlatformProxyBlocking::new(conn)?;
let current = proxy.throttle_thermal_policy()?;
let current = proxy.platform_profile()?;
if cmd.next {
proxy.set_throttle_thermal_policy(current.next())?;
proxy.set_platform_profile(current.next())?;
} else if let Some(profile) = cmd.profile_set {
proxy.set_throttle_thermal_policy(profile)?;
proxy.set_platform_profile(profile)?;
}
if cmd.list {
let res = ThrottlePolicy::list();
let res = PlatformProfile::list();
for p in &res {
println!("{:?}", p);
}
@@ -905,7 +942,7 @@ fn handle_throttle_profile(
fn handle_fan_curve(
conn: &Connection,
cmd: &FanCurveCommand,
cmd: &FanCurveCommand
) -> Result<(), Box<dyn std::error::Error>> {
let Ok(fan_proxy) = FanCurvesProxyBlocking::new(conn).map_err(|e| {
println!("Fan-curves not supported by either this kernel or by the laptop: {e:?}");
@@ -937,7 +974,7 @@ fn handle_fan_curve(
let plat_proxy = PlatformProxyBlocking::new(conn)?;
if cmd.get_enabled {
let profile = plat_proxy.throttle_thermal_policy()?;
let profile = plat_proxy.platform_profile()?;
let curves = fan_proxy.fan_curve_data(profile)?;
for curve in curves.iter() {
println!("{}", String::from(curve));
@@ -945,7 +982,7 @@ fn handle_fan_curve(
}
if cmd.default {
let active = plat_proxy.throttle_thermal_policy()?;
let active = plat_proxy.platform_profile()?;
fan_proxy.set_curves_to_defaults(active)?;
}
@@ -981,70 +1018,6 @@ fn handle_fan_curve(
Ok(())
}
fn handle_platform_properties(
conn: &Connection,
supported: &[Properties],
cmd: &PlatformCommand,
) -> Result<(), Box<dyn std::error::Error>> {
{
if (cmd.gpu_mux_mode_set.is_none()
&& !cmd.gpu_mux_mode_get
&& cmd.post_sound_set.is_none()
&& !cmd.post_sound_get
&& cmd.panel_overdrive_set.is_none()
&& !cmd.panel_overdrive_get)
|| cmd.help
{
println!("Missing arg or command\n");
let usage: Vec<String> = PlatformCommand::usage()
.lines()
.map(|s| s.to_owned())
.collect();
for line in usage.iter().filter(|line| {
line.contains("sound") && supported.contains(&Properties::PostAnimationSound)
|| line.contains("GPU") && supported.contains(&Properties::GpuMuxMode)
|| line.contains("panel") && supported.contains(&Properties::PanelOd)
}) {
println!("{}", line);
}
}
let proxy = PlatformProxyBlocking::new(conn)?;
if let Some(opt) = cmd.post_sound_set {
proxy.set_boot_sound(opt)?;
}
if cmd.post_sound_get {
let res = proxy.boot_sound()?;
println!("Bios POST sound on: {}", res);
}
if let Some(opt) = cmd.gpu_mux_mode_set {
println!("Rebuilding initrd to include drivers");
proxy.set_gpu_mux_mode(GpuMode::from_mux(opt))?;
println!(
"The mode change is not active until you reboot, on boot the bios will make the \
required change"
);
}
if cmd.gpu_mux_mode_get {
let res = proxy.gpu_mux_mode()?;
println!("Bios GPU MUX: {:?}", res);
}
if let Some(opt) = cmd.panel_overdrive_set {
proxy.set_panel_od(opt)?;
}
if cmd.panel_overdrive_get {
let res = proxy.panel_od()?;
println!("Panel overdrive on: {}", res);
}
}
Ok(())
}
fn check_systemd_unit_active(name: &str) -> bool {
if let Ok(out) = Command::new("systemctl")
.arg("is-active")
@@ -1068,3 +1041,98 @@ fn check_systemd_unit_enabled(name: &str) -> bool {
}
false
}
fn print_firmware_attr(attr: &AsusArmouryProxyBlocking) -> Result<(), Box<dyn std::error::Error>> {
let name = attr.name()?;
println!("{}:", <&str>::from(name));
let attrs = attr.available_attrs()?;
if attrs.contains(&"min_value".to_string())
&& attrs.contains(&"max_value".to_string())
&& attrs.contains(&"current_value".to_string())
{
let c = attr.current_value()?;
let min = attr.min_value()?;
let max = attr.max_value()?;
println!(" current: {min}..[{c}]..{max}");
if attrs.contains(&"default_value".to_string()) {
println!(" default: {}\n", attr.default_value()?);
} else {
println!();
}
} else if attrs.contains(&"possible_values".to_string())
&& attrs.contains(&"current_value".to_string())
{
let c = attr.current_value()?;
let v = attr.possible_values()?;
for p in v.iter().enumerate() {
if p.0 == 0 {
print!(" current: [");
}
if *p.1 == c {
print!("({c})");
} else {
print!("{}", p.1);
}
if p.0 < v.len() - 1 {
print!(",");
}
if p.0 == v.len() - 1 {
print!("]");
}
}
if attrs.contains(&"default_value".to_string()) {
println!(" default: {}\n", attr.default_value()?);
} else {
println!("\n");
}
} else if attrs.contains(&"current_value".to_string()) {
let c = attr.current_value()?;
println!(" current: {c}\n");
} else {
println!();
}
Ok(())
}
fn handle_armoury_command(cmd: &ArmouryCommand) -> Result<(), Box<dyn std::error::Error>> {
{
if cmd.free.is_empty() || cmd.free.len() % 2 != 0 || cmd.help {
const USAGE: &str = "Usage: asusctl platform panel_overdrive 1 nv_dynamic_boost 5";
if cmd.free.len() % 2 != 0 {
println!(
"Incorrect number of args, each attribute label must be paired with a setting:"
);
println!("{USAGE}");
return Ok(());
}
if let Ok(attr) = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury") {
println!("\n{USAGE}\n");
println!("Available firmware attributes: ");
for attr in attr.iter() {
print_firmware_attr(attr)?;
}
}
return Ok(());
}
if let Ok(attr) = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury") {
for cmd in cmd.free.chunks(2) {
for attr in attr.iter() {
let name = attr.name()?;
if <&str>::from(name) == cmd[0] {
let mut value: i32 = cmd[1].parse()?;
if value == -1 {
info!("Setting to default");
value = attr.default_value()?;
}
attr.set_current_value(value)?;
print_firmware_attr(attr)?;
}
}
}
}
}
Ok(())
}

View File

@@ -31,5 +31,5 @@ pub struct ScsiCommand {
pub colours: Vec<Colour>,
#[options(help = "list available animations")]
pub list: bool,
pub list: bool
}

View File

@@ -9,12 +9,27 @@ pub struct SlashCommand {
pub enable: bool,
#[options(help = "Ddisable the Slash Ledbar")]
pub disable: bool,
#[options(meta = "", help = "Set brightness value <0-255>")]
#[options(short = "l", meta = "", help = "Set brightness value <0-255>")]
pub brightness: Option<u8>,
#[options(meta = "", help = "Set interval value <0-5>")]
pub interval: Option<u8>,
#[options(meta = "", help = "Set SlashMode (so 'list' for all options)")]
pub slash_mode: Option<SlashMode>,
pub mode: Option<SlashMode>,
#[options(help = "list available animations")]
pub list: bool,
#[options(short = "B", meta = "", help = "Show the animation on boot")]
pub show_on_boot: Option<bool>,
#[options(short = "S", meta = "", help = "Show the animation on shutdown")]
pub show_on_shutdown: Option<bool>,
#[options(short = "s", meta = "", help = "Show the animation on sleep")]
pub show_on_sleep: Option<bool>,
#[options(short = "b", meta = "", help = "Show the animation on battery")]
pub show_on_battery: Option<bool>,
#[options(
short = "w",
meta = "",
help = "Show the low-battery warning animation"
)]
pub show_battery_warning: Option<bool>
}

View File

@@ -21,7 +21,7 @@ fn root_conf_dir() -> PathBuf {
#[derive(Debug, Deserialize, Serialize)]
pub struct ConfigAnime {
pub name: String,
pub anime: Vec<ActionLoader>,
pub anime: Vec<ActionLoader>
}
impl ConfigAnime {
@@ -52,8 +52,8 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new(
Duration::from_secs(2),
None,
Duration::from_secs(2),
)),
Duration::from_secs(2)
))
},
ActionLoader::AsusAnimation {
file: "/usr/share/asusd/anime/asus/rog/Sunset.gif".into(),
@@ -61,8 +61,8 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new(
Duration::from_secs(6),
None,
Duration::from_secs(3),
)),
Duration::from_secs(3)
))
},
ActionLoader::ImageAnimation {
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
@@ -73,8 +73,8 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new(
Duration::from_secs(2),
Some(Duration::from_secs(2)),
Duration::from_secs(2),
)),
Duration::from_secs(2)
))
},
ActionLoader::Image {
file: "/usr/share/asusd/anime/custom/rust.png".into(),
@@ -84,9 +84,9 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new(
Duration::from_secs(2),
Some(Duration::from_secs(1)),
Duration::from_secs(2),
Duration::from_secs(2)
)),
brightness: 0.6,
brightness: 0.6
},
ActionLoader::Pause(Duration::from_secs(1)),
ActionLoader::ImageAnimation {
@@ -95,9 +95,9 @@ impl Default for ConfigAnime {
angle: 0.0,
translation: Vec2::new(3.0, 2.0),
brightness: 0.5,
time: AnimTime::Count(2),
time: AnimTime::Count(2)
},
],
]
}
}
}
@@ -121,7 +121,7 @@ impl StdConfigLoad for ConfigAnime {}
#[derive(Debug, Deserialize, Serialize)]
pub struct ConfigAura {
pub name: String,
pub aura: AuraSequences,
pub aura: AuraSequences
}
impl ConfigAura {
@@ -139,14 +139,14 @@ impl Default for ConfigAura {
Colour {
r: 255,
g: 0,
b: 20,
b: 20
},
Colour {
r: 20,
g: 255,
b: 0,
b: 0
},
Speed::Low,
Speed::Low
));
seq.push(key.clone());
@@ -161,7 +161,7 @@ impl Default for ConfigAura {
LedCode::F,
Colour { r: 255, g: 0, b: 0 },
Colour { r: 255, g: 0, b: 0 },
Speed::High,
Speed::High
));
seq.push(key);
@@ -176,13 +176,13 @@ impl Default for ConfigAura {
LedCode::N9,
Colour { r: 0, g: 0, b: 255 },
80,
40,
40
));
seq.push(key);
Self {
name: "aura-default".to_owned(),
aura: seq,
aura: seq
}
}
}
@@ -209,14 +209,14 @@ pub struct ConfigBase {
/// Name of active anime config file in the user config directory
pub active_anime: Option<String>,
/// Name of active aura config file in the user config directory
pub active_aura: Option<String>,
pub active_aura: Option<String>
}
impl StdConfig for ConfigBase {
fn new() -> Self {
Self {
active_anime: Some("anime-default".to_owned()),
active_aura: Some("aura-default".to_owned()),
active_aura: Some("aura-default".to_owned())
}
}

View File

@@ -25,7 +25,7 @@ pub struct Timer {
/// Used only for `TimeType::Timer`, milliseonds to fade the image in for
fade_in: u64,
/// Used only for `TimeType::Timer`, milliseonds to fade the image out for
fade_out: u64,
fade_out: u64
}
impl From<Timer> for AnimTime {
@@ -46,7 +46,7 @@ impl From<Timer> for AnimTime {
}
}
TimeType::Count => AnimTime::Count(time.count as u32),
TimeType::Infinite => AnimTime::Infinite,
TimeType::Infinite => AnimTime::Infinite
}
}
}
@@ -55,7 +55,7 @@ impl From<Timer> for AnimTime {
pub enum TimeType {
Timer,
Count,
Infinite,
Infinite
}
/// The inner object exists to allow the zbus proxy to share it with a runner
@@ -63,19 +63,19 @@ pub enum TimeType {
pub struct CtrlAnimeInner<'a> {
sequences: Sequences,
client: AnimeProxyBlocking<'a>,
do_early_return: Arc<AtomicBool>,
do_early_return: Arc<AtomicBool>
}
impl CtrlAnimeInner<'static> {
pub fn new(
sequences: Sequences,
client: AnimeProxyBlocking<'static>,
do_early_return: Arc<AtomicBool>,
do_early_return: Arc<AtomicBool>
) -> Result<Self, Error> {
Ok(Self {
sequences,
client,
do_early_return,
do_early_return
})
}
@@ -130,7 +130,7 @@ pub struct CtrlAnime<'a> {
client: AnimeProxyBlocking<'a>,
inner: Arc<Mutex<CtrlAnimeInner<'a>>>,
/// Must be the same Atomic as in CtrlAnimeInner
inner_early_return: Arc<AtomicBool>,
inner_early_return: Arc<AtomicBool>
}
impl CtrlAnime<'static> {
@@ -138,23 +138,20 @@ impl CtrlAnime<'static> {
config: Arc<Mutex<ConfigAnime>>,
inner: Arc<Mutex<CtrlAnimeInner<'static>>>,
client: AnimeProxyBlocking<'static>,
inner_early_return: Arc<AtomicBool>,
inner_early_return: Arc<AtomicBool>
) -> Result<Self, Error> {
Ok(CtrlAnime {
config,
client,
inner,
inner_early_return,
inner_early_return
})
}
pub async fn add_to_server(self, server: &mut zbus::Connection) {
server
.object_server()
.at(
&ObjectPath::from_str_unchecked("/org/asuslinux/Anime"),
self,
)
.at(&ObjectPath::from_str_unchecked("/xyz/ljones/Anime"), self)
.await
.map_err(|err| {
println!("CtrlAnime: add_to_server {}", err);
@@ -170,14 +167,14 @@ impl CtrlAnime<'static> {
// - Do actions
// - Write config if required
// - Unset inner_early_return
#[interface(name = "org.asuslinux.Daemon")]
#[interface(name = "xyz.ljones.Asusd")]
impl CtrlAnime<'static> {
pub fn insert_asus_gif(
&mut self,
index: u32,
file: &str,
time: Timer,
brightness: f32,
brightness: f32
) -> zbus::fdo::Result<String> {
if let Ok(mut config) = self.config.try_lock() {
let time: AnimTime = time.into();
@@ -185,7 +182,7 @@ impl CtrlAnime<'static> {
let action = ActionLoader::AsusAnimation {
file: file.into(),
brightness,
time,
time
};
// Must make the inner run loop return early
@@ -219,7 +216,7 @@ impl CtrlAnime<'static> {
angle: f32,
xy: (f32, f32),
time: Timer,
brightness: f32,
brightness: f32
) -> zbus::fdo::Result<String> {
if let Ok(mut config) = self.config.try_lock() {
let time: AnimTime = time.into();
@@ -231,7 +228,7 @@ impl CtrlAnime<'static> {
angle,
translation,
brightness,
time,
time
};
// Must make the inner run loop return early
@@ -264,7 +261,7 @@ impl CtrlAnime<'static> {
angle: f32,
xy: (f32, f32),
time: Timer,
brightness: f32,
brightness: f32
) -> zbus::fdo::Result<String> {
if let Ok(mut config) = self.config.try_lock() {
let file = Path::new(&file);
@@ -275,7 +272,7 @@ impl CtrlAnime<'static> {
angle,
translation: Vec2::new(xy.0, xy.1),
brightness,
time,
time
};
// Must make the inner run loop return early

View File

@@ -42,7 +42,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let early_return = Arc::new(AtomicBool::new(false));
// Set up the anime data and run loop/thread
if supported.contains(&"org.asuslinux.Anime".to_string()) {
if supported.contains(&"xyz.ljones.Anime".to_string()) {
if let Some(cfg) = config.active_anime {
let anime_type = get_anime_type();
let anime_config = ConfigAnime::new().set_name(cfg).load();
@@ -61,16 +61,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
CtrlAnimeInner::new(
anime,
anime_proxy_blocking.clone(),
early_return.clone(),
early_return.clone()
)
.unwrap(),
.unwrap()
));
// Need new client object for dbus control part
let anime_control = CtrlAnime::new(
anime_config,
inner.clone(),
anime_proxy_blocking,
early_return,
early_return
)
.unwrap();
anime_control.add_to_server(&mut connection).await;

View File

@@ -8,7 +8,7 @@ pub enum Error {
ConfigLoadFail,
ConfigLockFail,
XdgVars,
Anime(AnimeError),
Anime(AnimeError)
}
impl fmt::Display for Error {
@@ -19,7 +19,7 @@ impl fmt::Display for Error {
Error::ConfigLoadFail => write!(f, "Failed to load user config"),
Error::ConfigLockFail => write!(f, "Failed to lock user config"),
Error::XdgVars => write!(f, "XDG environment vars appear unset"),
Error::Anime(err) => write!(f, "Anime error: {}", err),
Error::Anime(err) => write!(f, "Anime error: {}", err)
}
}
}

View File

@@ -1,8 +1,8 @@
//! # `DBus` interface proxy for: `org.asuslinux.Daemon`
//! # `DBus` interface proxy for: `xyz.ljones.Asusd`
//!
//! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection
//! data. Source: `Interface '/org/asuslinux/Anime' from service
//! 'org.asuslinux.Daemon' on session bus`.
//! data. Source: `Interface '/xyz/ljones/Anime' from service
//! 'xyz.ljones.Asusd' on session bus`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
//!
@@ -23,10 +23,7 @@
use zbus::proxy;
#[proxy(
interface = "org.asuslinux.Daemon",
default_path = "/org/asuslinux/Anime"
)]
#[proxy(interface = "xyz.ljones.Asusd", default_path = "/xyz/ljones/Anime")]
trait Daemon {
/// InsertAsusGif method
fn insert_asus_gif(
@@ -35,7 +32,7 @@ trait Daemon {
file: &str,
time: u32,
count: u32,
brightness: f64,
brightness: f64
) -> zbus::Result<String>;
/// InsertImage method
@@ -46,7 +43,7 @@ trait Daemon {
scale: f64,
angle: f64,
xy: &(f64, f64),
brightness: f64,
brightness: f64
) -> zbus::Result<String>;
/// InsertImageGif method
@@ -59,7 +56,7 @@ trait Daemon {
xy: &(f64, f64),
time: u32,
count: u32,
brightness: f64,
brightness: f64
) -> zbus::Result<String>;
/// InsertPause method

368
asusd/src/asus_armoury.rs Normal file
View File

@@ -0,0 +1,368 @@
use std::sync::Arc;
use ::zbus::export::futures_util::lock::Mutex;
use config_traits::StdConfig;
use log::{debug, error, info};
use rog_platform::asus_armoury::{AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes};
use rog_platform::platform::{PlatformProfile, RogPlatform};
use rog_platform::power::AsusPower;
use serde::{Deserialize, Serialize};
use zbus::object_server::SignalEmitter;
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
use zbus::{fdo, interface, Connection};
use crate::config::Config;
use crate::error::RogError;
use crate::{Reloadable, ASUS_ZBUS_PATH};
const MOD_NAME: &str = "asus_armoury";
#[derive(Debug, Default, Clone, Deserialize, Serialize, Type, Value, OwnedValue)]
pub struct PossibleValues {
strings: Vec<String>,
nums: Vec<i32>
}
fn dbus_path_for_attr(attr_name: &str) -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{attr_name}")).into()
}
#[derive(Clone)]
pub struct AsusArmouryAttribute {
attr: Attribute,
config: Arc<Mutex<Config>>,
/// platform control required here for access to PPD or Throttle profile
platform: RogPlatform,
power: AsusPower
}
impl AsusArmouryAttribute {
pub fn new(
attr: Attribute,
platform: RogPlatform,
power: AsusPower,
config: Arc<Mutex<Config>>
) -> Self {
Self {
attr,
config,
platform,
power
}
}
pub async fn move_to_zbus(self, connection: &Connection) -> Result<(), RogError> {
let path = dbus_path_for_attr(self.attr.name());
connection
.object_server()
.at(path.clone(), self)
.await
.map_err(|e| error!("Couldn't add server at path: {path}, {e:?}"))
.ok();
Ok(())
}
async fn watch_and_notify(
&mut self,
signal_ctxt: SignalEmitter<'static>
) -> Result<(), RogError> {
use zbus::export::futures_util::StreamExt;
let ctrl = self.clone();
let name = self.name();
match self.attr.get_watcher() {
Ok(watch) => {
let name = <&str>::from(name);
tokio::spawn(async move {
let mut buffer = [0; 32];
watch
.into_event_stream(&mut buffer)
.unwrap()
.for_each(|_| async {
debug!("{} changed", name);
ctrl.current_value_changed(&signal_ctxt).await.ok();
})
.await;
});
}
Err(e) => info!(
"inotify watch failed: {}. You can ignore this if your device does not support \
the feature",
e
)
}
Ok(())
}
}
impl crate::Reloadable for AsusArmouryAttribute {
async fn reload(&mut self) -> Result<(), RogError> {
info!("Reloading {}", self.attr.name());
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let config = if power_plugged == 1 {
&self.config.lock().await.ac_profile_tunings
} else {
&self.config.lock().await.dc_profile_tunings
};
if let Some(tunings) = config.get(&profile) {
if let Some(tune) = tunings.get(&self.name()) {
self.attr
.set_current_value(&AttrValue::Integer(*tune))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
info!("Set {} to {:?}", self.attr.name(), tune);
}
}
Ok(())
}
}
/// If return is `-1` on a property then there is avilable value for that
/// property
#[interface(name = "xyz.ljones.AsusArmoury")]
impl AsusArmouryAttribute {
#[zbus(property)]
fn name(&self) -> FirmwareAttribute {
self.attr.name().into()
}
#[zbus(property)]
async fn available_attrs(&self) -> Vec<String> {
let mut attrs = Vec::new();
if !matches!(self.attr.default_value(), AttrValue::None) {
attrs.push("default_value".to_string());
}
if !matches!(self.attr.min_value(), AttrValue::None) {
attrs.push("min_value".to_string());
}
if !matches!(self.attr.max_value(), AttrValue::None) {
attrs.push("max_value".to_string());
}
if !matches!(self.attr.scalar_increment(), AttrValue::None) {
attrs.push("scalar_increment".to_string());
}
if !matches!(self.attr.possible_values(), AttrValue::None) {
attrs.push("possible_values".to_string());
}
// TODO: Don't unwrap, use error
if let Ok(value) = self.attr.current_value().map_err(|e| {
error!("Failed to read: {e:?}");
e
}) {
if !matches!(value, AttrValue::None) {
attrs.push("current_value".to_string());
}
}
attrs
}
/// If return is `-1` then there is no default value
#[zbus(property)]
async fn default_value(&self) -> i32 {
match self.attr.default_value() {
AttrValue::Integer(i) => *i,
_ => -1
}
}
async fn restore_default(&self) -> fdo::Result<()> {
self.attr.restore_default()?;
if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tunings = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tunings.get_mut(&self.name()) {
if let AttrValue::Integer(i) = self.attr.default_value() {
*tune = *i;
}
}
config.write();
}
Ok(())
}
#[zbus(property)]
async fn min_value(&self) -> i32 {
match self.attr.min_value() {
AttrValue::Integer(i) => *i,
_ => -1
}
}
#[zbus(property)]
async fn max_value(&self) -> i32 {
match self.attr.max_value() {
AttrValue::Integer(i) => *i,
_ => -1
}
}
#[zbus(property)]
async fn scalar_increment(&self) -> i32 {
match self.attr.scalar_increment() {
AttrValue::Integer(i) => *i,
_ => -1
}
}
#[zbus(property)]
async fn possible_values(&self) -> Vec<i32> {
match self.attr.possible_values() {
AttrValue::EnumInt(i) => i.clone(),
_ => Vec::default()
}
}
#[zbus(property)]
async fn current_value(&self) -> fdo::Result<i32> {
if let Ok(AttrValue::Integer(i)) = self.attr.current_value() {
return Ok(i);
}
Err(fdo::Error::Failed(
"Could not read current value".to_string()
))
}
#[zbus(property)]
async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tunings = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tunings.get_mut(&self.name()) {
*tune = value;
} else {
tunings.insert(self.name(), value);
debug!("Set tuning config for {} = {:?}", self.attr.name(), value);
}
} else {
let has_attr = self
.config
.lock()
.await
.armoury_settings
.contains_key(&self.name());
if has_attr {
if let Some(setting) = self
.config
.lock()
.await
.armoury_settings
.get_mut(&self.name())
{
*setting = value
}
} else {
debug!("Adding config for {}", self.attr.name());
self.config
.lock()
.await
.armoury_settings
.insert(self.name(), value);
debug!("Set config for {} = {:?}", self.attr.name(), value);
}
}
self.config.lock().await.write();
Ok(())
}
}
pub async fn start_attributes_zbus(
conn: &Connection,
platform: RogPlatform,
power: AsusPower,
config: Arc<Mutex<Config>>
) -> Result<(), RogError> {
for attr in FirmwareAttributes::new().attributes() {
let mut attr = AsusArmouryAttribute::new(
attr.clone(),
platform.clone(),
power.clone(),
config.clone()
);
attr.reload().await?;
let path = dbus_path_for_attr(attr.attr.name());
let sig = zbus::object_server::SignalEmitter::new(conn, path)?;
attr.watch_and_notify(sig).await?;
attr.move_to_zbus(conn).await?;
}
Ok(())
}
pub async fn set_config_or_default(
attrs: &FirmwareAttributes,
config: &mut Config,
power_plugged: bool,
profile: PlatformProfile
) {
for attr in attrs.attributes().iter() {
let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() {
let tunings = config.select_tunings(power_plugged, profile);
if let Some(tune) = tunings.get(&name) {
attr.set_current_value(&AttrValue::Integer(*tune))
.map_err(|e| {
error!("Failed to set {}: {e}", <&str>::from(name));
})
.ok();
} else {
let default = attr.default_value();
attr.set_current_value(default)
.map_err(|e| {
error!("Failed to set {}: {e}", <&str>::from(name));
})
.ok();
if let AttrValue::Integer(i) = default {
tunings.insert(name, *i);
info!(
"Set default tuning config for {} = {:?}",
<&str>::from(name),
i
);
config.write();
}
}
}
}
}

View File

@@ -4,7 +4,7 @@ use config_traits::{StdConfig, StdConfigLoad};
use rog_anime::error::AnimeError;
use rog_anime::usb::Brightness;
use rog_anime::{
ActionData, ActionLoader, AnimTime, Animations, AnimeType, DeviceState, Fade, Vec2,
ActionData, ActionLoader, AnimTime, Animations, AnimeType, DeviceState, Fade, Vec2
};
use serde::{Deserialize, Serialize};
@@ -15,14 +15,14 @@ pub struct AniMeConfigCached {
pub system: Vec<ActionData>,
pub boot: Vec<ActionData>,
pub wake: Vec<ActionData>,
pub shutdown: Vec<ActionData>,
pub shutdown: Vec<ActionData>
}
impl AniMeConfigCached {
pub fn init_from_config(
&mut self,
config: &AniMeConfig,
anime_type: AnimeType,
anime_type: AnimeType
) -> Result<(), AnimeError> {
let mut sys = Vec::with_capacity(config.system.len());
for ani in &config.system {
@@ -68,7 +68,7 @@ pub struct AniMeConfig {
pub off_when_suspended: bool,
pub off_when_lid_closed: bool,
pub brightness_on_battery: Brightness,
pub builtin_anims: Animations,
pub builtin_anims: Animations
}
impl Default for AniMeConfig {
@@ -87,7 +87,7 @@ impl Default for AniMeConfig {
off_when_suspended: true,
off_when_lid_closed: true,
brightness_on_battery: Brightness::Low,
builtin_anims: Animations::default(),
builtin_anims: Animations::default()
}
}
}
@@ -118,7 +118,7 @@ impl From<&AniMeConfig> for DeviceState {
off_when_unplugged: config.off_when_unplugged,
off_when_suspended: config.off_when_suspended,
off_when_lid_closed: config.off_when_lid_closed,
brightness_on_battery: config.brightness_on_battery,
brightness_on_battery: config.brightness_on_battery
}
}
}
@@ -138,38 +138,44 @@ impl AniMeConfig {
// create a default config here
AniMeConfig {
system: vec![],
boot: vec![ActionLoader::ImageAnimation {
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
scale: 0.9,
angle: 0.65,
translation: Vec2::default(),
brightness: 1.0,
time: AnimTime::Fade(Fade::new(
Duration::from_secs(2),
Some(Duration::from_secs(2)),
Duration::from_secs(2),
)),
}],
wake: vec![ActionLoader::ImageAnimation {
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
scale: 0.9,
angle: 0.65,
translation: Vec2::default(),
brightness: 1.0,
time: AnimTime::Fade(Fade::new(
Duration::from_secs(2),
Some(Duration::from_secs(2)),
Duration::from_secs(2),
)),
}],
shutdown: vec![ActionLoader::ImageAnimation {
file: "/usr/share/asusd/anime/custom/sonic-wait.gif".into(),
scale: 0.9,
angle: 0.0,
translation: Vec2::new(3.0, 2.0),
brightness: 1.0,
time: AnimTime::Infinite,
}],
boot: vec![
ActionLoader::ImageAnimation {
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
scale: 0.9,
angle: 0.65,
translation: Vec2::default(),
brightness: 1.0,
time: AnimTime::Fade(Fade::new(
Duration::from_secs(2),
Some(Duration::from_secs(2)),
Duration::from_secs(2)
))
},
],
wake: vec![
ActionLoader::ImageAnimation {
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
scale: 0.9,
angle: 0.65,
translation: Vec2::default(),
brightness: 1.0,
time: AnimTime::Fade(Fade::new(
Duration::from_secs(2),
Some(Duration::from_secs(2)),
Duration::from_secs(2)
))
},
],
shutdown: vec![
ActionLoader::ImageAnimation {
file: "/usr/share/asusd/anime/custom/sonic-wait.gif".into(),
scale: 0.9,
angle: 0.0,
translation: Vec2::new(3.0, 2.0),
brightness: 1.0,
time: AnimTime::Infinite
},
],
..Default::default()
}
}

View File

@@ -11,7 +11,7 @@ use config_traits::StdConfig;
use log::{error, info, warn};
use rog_anime::usb::{
pkt_flush, pkt_set_brightness, pkt_set_enable_display, pkt_set_enable_powersave_anim,
pkts_for_init, Brightness,
pkts_for_init, Brightness
};
use rog_anime::{ActionData, AnimeDataBuffer, AnimePacketType};
use rog_platform::hid_raw::HidRaw;
@@ -30,14 +30,14 @@ pub struct AniMe {
// set to force thread to exit
thread_exit: Arc<AtomicBool>,
// Set to false when the thread exits
thread_running: Arc<AtomicBool>,
thread_running: Arc<AtomicBool>
}
impl AniMe {
pub fn new(
hid: Option<Arc<Mutex<HidRaw>>>,
usb: Option<Arc<Mutex<USBRaw>>>,
config: Arc<Mutex<AniMeConfig>>,
config: Arc<Mutex<AniMeConfig>>
) -> Self {
Self {
hid,
@@ -45,7 +45,7 @@ impl AniMe {
config,
cache: AniMeConfigCached::default(),
thread_exit: Arc::new(AtomicBool::new(false)),
thread_running: Arc::new(AtomicBool::new(false)),
thread_running: Arc::new(AtomicBool::new(false))
}
}
@@ -106,7 +106,7 @@ impl AniMe {
pub async fn set_builtins_enabled(
&self,
enabled: bool,
bright: Brightness,
bright: Brightness
) -> Result<(), RogError> {
self.write_bytes(&pkt_set_enable_powersave_anim(enabled))
.await?;
@@ -229,7 +229,7 @@ impl AniMe {
}
inner
.write_bytes(&pkt_set_enable_powersave_anim(
inner.config.lock().await.builtin_anims_enabled,
inner.config.lock().await.builtin_anims_enabled
))
.await
.map_err(|err| {

View File

@@ -5,7 +5,7 @@ use log::{error, warn};
use logind_zbus::manager::ManagerProxy;
use rog_anime::usb::{
pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display,
pkt_set_enable_powersave_anim, Brightness,
pkt_set_enable_powersave_anim, Brightness
};
use rog_anime::{Animations, AnimeDataBuffer, DeviceState};
use zbus::object_server::SignalEmitter;
@@ -41,7 +41,7 @@ impl AniMeZbus {
pub async fn start_tasks(
mut self,
connection: &Connection,
path: OwnedObjectPath,
path: OwnedObjectPath
) -> Result<(), RogError> {
// let task = zbus.clone();
self.reload()
@@ -60,7 +60,7 @@ impl AniMeZbus {
// None of these calls can be guarnateed to succeed unless we loop until okay
// If the try_lock *does* succeed then any other thread trying to lock will not
// grab it until we finish.
#[interface(name = "org.asuslinux.Anime")]
#[interface(name = "xyz.ljones.Anime")]
impl AniMeZbus {
/// Writes a data stream of length. Will force system thread to exit until
/// it is restarted
@@ -166,10 +166,7 @@ impl AniMeZbus {
async fn set_builtin_animations(&self, settings: Animations) {
self.0
.write_bytes(&pkt_set_builtin_animations(
settings.boot,
settings.awake,
settings.sleep,
settings.shutdown,
settings.boot, settings.awake, settings.sleep, settings.shutdown
))
.await
.map_err(|err| {
@@ -319,7 +316,7 @@ impl crate::CtrlTask for AniMeZbus {
inner
.write_bytes(&pkt_set_enable_display(
!(sleeping && config.off_when_suspended),
!(sleeping && config.off_when_suspended)
))
.await
.map_err(|err| {
@@ -330,7 +327,7 @@ impl crate::CtrlTask for AniMeZbus {
if config.builtin_anims_enabled {
inner
.write_bytes(&pkt_set_enable_powersave_anim(
!(sleeping && config.off_when_suspended),
!(sleeping && config.off_when_suspended)
))
.await
.map_err(|err| {
@@ -433,7 +430,7 @@ impl crate::CtrlTask for AniMeZbus {
.ok();
}
}
},
}
)
.await;
@@ -449,10 +446,7 @@ impl crate::Reloadable for AniMeZbus {
if config.builtin_anims_enabled {
self.0
.write_bytes(&pkt_set_builtin_animations(
anim.boot,
anim.awake,
anim.sleep,
anim.shutdown,
anim.boot, anim.awake, anim.sleep, anim.shutdown
))
.await?;
}

View File

@@ -5,7 +5,7 @@ use log::{debug, info, warn};
use rog_aura::aura_detection::LedSupportData;
use rog_aura::keyboard::LaptopAuraPower;
use rog_aura::{
AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT,
AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT
};
use serde::{Deserialize, Serialize};
@@ -29,7 +29,7 @@ pub struct AuraConfig {
pub multizone_on: bool,
pub enabled: LaptopAuraPower,
#[serde(skip)]
pub per_key_mode_active: bool,
pub per_key_mode_active: bool
}
impl StdConfig for AuraConfig {
@@ -74,7 +74,7 @@ impl AuraConfig {
multizone: None,
multizone_on: false,
enabled,
per_key_mode_active: false,
per_key_mode_active: false
};
for n in &config.support_data.basic_modes {
@@ -92,7 +92,7 @@ impl AuraConfig {
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
speed: Speed::Med,
direction: Direction::Left,
direction: Direction::Left
});
}
if let Some(m) = config.multizone.as_mut() {
@@ -156,7 +156,7 @@ impl AuraConfig {
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
speed: Speed::Med,
direction: Direction::Left,
direction: Direction::Left
});
}
if default.is_empty() {
@@ -232,7 +232,7 @@ impl AuraConfig {
mod tests {
use rog_aura::keyboard::AuraPowerState;
use rog_aura::{
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed,
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed
};
use super::AuraConfig;
@@ -246,7 +246,7 @@ mod tests {
colour1: Colour {
r: 0xff,
g: 0x00,
b: 0xff,
b: 0xff
},
zone: AuraZone::Key1,
..Default::default()
@@ -259,7 +259,7 @@ mod tests {
colour1: Colour {
r: 0x00,
g: 0xff,
b: 0xff,
b: 0xff
},
zone: AuraZone::Key2,
..Default::default()
@@ -270,7 +270,7 @@ mod tests {
colour1: Colour {
r: 0xff,
g: 0xff,
b: 0x00,
b: 0x00
},
zone: AuraZone::Key3,
..Default::default()
@@ -281,7 +281,7 @@ mod tests {
colour1: Colour {
r: 0x00,
g: 0xff,
b: 0x00,
b: 0x00
},
zone: AuraZone::Key4,
..Default::default()
@@ -294,38 +294,26 @@ mod tests {
let res = config.multizone.unwrap();
let sta = res.get(&AuraModeNum::Static).unwrap();
assert_eq!(sta.len(), 4);
assert_eq!(
sta[0].colour1,
Colour {
r: 0xff,
g: 0x00,
b: 0xff
}
);
assert_eq!(
sta[1].colour1,
Colour {
r: 0x00,
g: 0xff,
b: 0xff
}
);
assert_eq!(
sta[2].colour1,
Colour {
r: 0xff,
g: 0xff,
b: 0x00
}
);
assert_eq!(
sta[3].colour1,
Colour {
r: 0x00,
g: 0xff,
b: 0x00
}
);
assert_eq!(sta[0].colour1, Colour {
r: 0xff,
g: 0x00,
b: 0xff
});
assert_eq!(sta[1].colour1, Colour {
r: 0x00,
g: 0xff,
b: 0xff
});
assert_eq!(sta[2].colour1, Colour {
r: 0xff,
g: 0xff,
b: 0x00
});
assert_eq!(sta[3].colour1, Colour {
r: 0x00,
g: 0xff,
b: 0x00
});
}
#[test]
@@ -383,28 +371,22 @@ mod tests {
assert_eq!(config.brightness, LedBrightness::Med);
assert_eq!(config.builtins.len(), 5);
assert_eq!(
config.builtins.first_entry().unwrap().get(),
&AuraEffect {
mode: AuraModeNum::Static,
zone: AuraZone::None,
colour1: Colour { r: 166, g: 0, b: 0 },
colour2: Colour { r: 0, g: 0, b: 0 },
speed: Speed::Med,
direction: Direction::Right
}
);
assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
mode: AuraModeNum::Static,
zone: AuraZone::None,
colour1: Colour { r: 166, g: 0, b: 0 },
colour2: Colour { r: 0, g: 0, b: 0 },
speed: Speed::Med,
direction: Direction::Right
});
assert_eq!(config.enabled.states.len(), 1);
assert_eq!(
config.enabled.states[0],
AuraPowerState {
zone: PowerZones::KeyboardAndLightbar,
boot: true,
awake: true,
sleep: true,
shutdown: true
}
);
assert_eq!(config.enabled.states[0], AuraPowerState {
zone: PowerZones::KeyboardAndLightbar,
boot: true,
awake: true,
sleep: true,
shutdown: true
});
}
#[test]
@@ -414,27 +396,21 @@ mod tests {
assert_eq!(config.brightness, LedBrightness::Med);
assert_eq!(config.builtins.len(), 12);
assert_eq!(
config.builtins.first_entry().unwrap().get(),
&AuraEffect {
mode: AuraModeNum::Static,
zone: AuraZone::None,
colour1: Colour { r: 166, g: 0, b: 0 },
colour2: Colour { r: 0, g: 0, b: 0 },
speed: Speed::Med,
direction: Direction::Right
}
);
assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
mode: AuraModeNum::Static,
zone: AuraZone::None,
colour1: Colour { r: 166, g: 0, b: 0 },
colour2: Colour { r: 0, g: 0, b: 0 },
speed: Speed::Med,
direction: Direction::Right
});
assert_eq!(config.enabled.states.len(), 4);
assert_eq!(
config.enabled.states[0],
AuraPowerState {
zone: PowerZones::Keyboard,
boot: true,
awake: true,
sleep: true,
shutdown: true
}
);
assert_eq!(config.enabled.states[0], AuraPowerState {
zone: PowerZones::Keyboard,
boot: true,
awake: true,
sleep: true,
shutdown: true
});
}
}

View File

@@ -19,7 +19,7 @@ pub mod trait_impls;
pub struct Aura {
pub hid: Option<Arc<Mutex<HidRaw>>>,
pub backlight: Option<Arc<Mutex<KeyboardBacklight>>>,
pub config: Arc<Mutex<AuraConfig>>,
pub config: Arc<Mutex<AuraConfig>>
}
impl Aura {
@@ -91,17 +91,13 @@ impl Aura {
pub async fn write_effect_and_apply(
&self,
dev_type: AuraDeviceType,
mode: &AuraEffect,
mode: &AuraEffect
) -> Result<(), RogError> {
if matches!(dev_type, AuraDeviceType::LaptopKeyboardTuf) {
if let Some(platform) = &self.backlight {
let buf = [
1,
mode.mode as u8,
mode.colour1.r,
mode.colour1.g,
mode.colour1.b,
mode.speed as u8,
1, mode.mode as u8, mode.colour1.r, mode.colour1.g, mode.colour1.b,
mode.speed as u8
];
platform.lock().await.set_kbd_rgb_mode(&buf)?;
}
@@ -125,7 +121,7 @@ impl Aura {
return Ok(());
}
Err(RogError::MissingFunction(
"No LED backlight control available".to_string(),
"No LED backlight control available".to_string()
))
}
@@ -142,14 +138,24 @@ impl Aura {
let hid_raw = hid_raw.lock().await;
if let Some(p) = config.enabled.states.first() {
if p.zone == PowerZones::Ally {
let msg = [0x5d, 0xd1, 0x09, 0x01, p.new_to_byte() as u8, 0x0, 0x0];
let msg = [
0x5d,
0xd1,
0x09,
0x01,
p.new_to_byte() as u8,
0x0,
0x0
];
hid_raw.write_bytes(&msg)?;
return Ok(());
}
}
let bytes = config.enabled.to_bytes(config.led_type);
let msg = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]];
let msg = [
0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]
];
hid_raw.write_bytes(&msg)?;
}
Ok(())
@@ -161,7 +167,7 @@ impl Aura {
pub async fn write_effect_block(
&self,
config: &mut AuraConfig,
effect: &AuraLaptopUsbPackets,
effect: &AuraLaptopUsbPackets
) -> Result<(), RogError> {
if config.brightness == LedBrightness::Off {
config.brightness = LedBrightness::Med;
@@ -194,7 +200,9 @@ impl Aura {
let r = row[9];
let g = row[10];
let b = row[11];
tuf.lock().await.set_kbd_rgb_mode(&[0, 0, r, g, b, 0])?;
tuf.lock().await.set_kbd_rgb_mode(&[
0, 0, r, g, b, 0
])?;
}
}
}
@@ -206,7 +214,9 @@ impl Aura {
if let Some(hid_raw) = &self.hid {
let mut config = self.config.lock().await;
if config.ally_fix.is_none() {
let msg = [0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff];
let msg = [
0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff
];
hid_raw.lock().await.write_bytes(&msg)?;
info!("Reset Ally power settings to base");
config.ally_fix = Some(true);

View File

@@ -14,7 +14,7 @@ use crate::error::RogError;
use crate::{CtrlTask, Reloadable};
pub const AURA_ZBUS_NAME: &str = "Aura";
pub const AURA_ZBUS_PATH: &str = "/org/asuslinux";
pub const AURA_ZBUS_PATH: &str = "/xyz/ljones";
#[derive(Clone)]
pub struct AuraZbus(Aura);
@@ -28,7 +28,7 @@ impl AuraZbus {
mut self,
connection: &Connection,
// _signal_ctx: SignalEmitter<'static>,
path: OwnedObjectPath,
path: OwnedObjectPath
) -> Result<(), RogError> {
// let task = zbus.clone();
// let signal_ctx = signal_ctx.clone();
@@ -50,7 +50,7 @@ impl AuraZbus {
/// The main interface for changing, reading, or notfying
///
/// LED commands are split between Brightness, Modes, Per-Key
#[interface(name = "org.asuslinux.Aura")]
#[interface(name = "xyz.ljones.Aura")]
impl AuraZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
@@ -144,7 +144,7 @@ impl AuraZbus {
let mode = config.current_mode;
match config.builtins.get(&mode) {
Some(effect) => Ok(effect.clone()),
None => Err(ZbErr::Failed("Could not get the current effect".into())),
None => Err(ZbErr::Failed("Could not get the current effect".into()))
}
} else {
Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
@@ -227,7 +227,7 @@ impl AuraZbus {
impl CtrlTask for AuraZbus {
fn zbus_path() -> &'static str {
"/org/asuslinux"
"/xyz/ljones"
}
async fn create_tasks(&self, _: SignalEmitter<'static>) -> Result<(), RogError> {
@@ -297,7 +297,7 @@ impl CtrlTask for AuraZbus {
move |_power_plugged| {
// power change
async move {}
},
}
)
.await;

View File

@@ -23,8 +23,9 @@ use crate::aura_scsi::trait_impls::ScsiZbus;
use crate::aura_slash::trait_impls::SlashZbus;
use crate::aura_types::DeviceHandle;
use crate::error::RogError;
use crate::ASUS_ZBUS_PATH;
pub const ASUS_ZBUS_PATH: &str = "/org/asuslinux";
const MOD_NAME: &str = "aura";
/// Returns only the Device details concatenated in a form usable for
/// adding/appending to a filename
@@ -54,26 +55,27 @@ pub fn filename_partial(parent: &Device) -> Option<OwnedObjectPath> {
fn dbus_path_for_dev(parent: &Device) -> Option<OwnedObjectPath> {
if let Some(filename) = filename_partial(parent) {
return Some(
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{filename}")).into(),
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{filename}"))
.into()
);
}
None
}
fn dbus_path_for_tuf() -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/tuf")).into()
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/tuf")).into()
}
fn dbus_path_for_slash() -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/slash")).into()
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/slash")).into()
}
fn dbus_path_for_anime() -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/anime")).into()
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/anime")).into()
}
fn dbus_path_for_scsi(prod_id: &str) -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{prod_id}_scsi")).into()
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{prod_id}_scsi")).into()
}
fn dev_prop_matches(dev: &Device, prop: &str, value: &str) -> bool {
@@ -83,32 +85,23 @@ fn dev_prop_matches(dev: &Device, prop: &str, value: &str) -> bool {
false
}
// TODO:
// - make this the HID manager (and universal)
// - *really* need to make most of this actual kernel drivers
// - LED class
// - RGB modes (how, attribute?)
// - power features (how, attribute?)
// - what about per-key stuff?
// - how would the AniMe be exposed? Just a series of LEDs?
/// A device.
///
/// Each controller within should track its dbus path so it can be removed if
/// required.
pub struct AsusDevice {
device: DeviceHandle,
dbus_path: OwnedObjectPath,
dbus_path: OwnedObjectPath
}
pub struct DeviceManager {
_dbus_connection: Connection,
_dbus_connection: Connection
}
impl DeviceManager {
async fn init_hid_devices(
connection: &Connection,
device: Device,
device: Device
) -> Result<Vec<AsusDevice>, RogError> {
let mut devices = Vec::new();
if let Some(usb_device) = device.parent_with_subsystem_devtype("usb", "usb_device")? {
@@ -129,7 +122,7 @@ impl DeviceManager {
// SLASH DEVICE
if let Ok(dev_type) = DeviceHandle::new_slash_hid(
dev.clone(),
usb_id.to_str().unwrap_or_default(),
usb_id.to_str().unwrap_or_default()
)
.await
{
@@ -140,14 +133,14 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice {
device: dev_type,
dbus_path: path,
dbus_path: path
});
}
}
// ANIME MATRIX DEVICE
if let Ok(dev_type) = DeviceHandle::maybe_anime_hid(
dev.clone(),
usb_id.to_str().unwrap_or_default(),
usb_id.to_str().unwrap_or_default()
)
.await
{
@@ -158,14 +151,14 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice {
device: dev_type,
dbus_path: path,
dbus_path: path
});
}
}
// AURA LAPTOP DEVICE
if let Ok(dev_type) = DeviceHandle::maybe_laptop_aura(
Some(dev),
usb_id.to_str().unwrap_or_default(),
usb_id.to_str().unwrap_or_default()
)
.await
{
@@ -176,7 +169,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice {
device: dev_type,
dbus_path: path,
dbus_path: path
});
}
}
@@ -216,11 +209,11 @@ impl DeviceManager {
async fn init_scsi(
connection: &Connection,
device: &Device,
path: OwnedObjectPath,
path: OwnedObjectPath
) -> Option<AsusDevice> {
// "ID_MODEL_ID" "1932"
// "ID_VENDOR_ID" "0b05"
if dev_prop_matches(&device, "ID_VENDOR_ID", "0b05") {
if dev_prop_matches(device, "ID_VENDOR_ID", "0b05") {
if let Some(dev_node) = device.devnode() {
let prod_id = device
.property_value("ID_MODEL_ID")
@@ -234,7 +227,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap();
return Some(AsusDevice {
device: dev_type,
dbus_path: path,
dbus_path: path
});
}
}
@@ -275,7 +268,7 @@ impl DeviceManager {
found.push(path);
}
} else {
warn!("No serial for SCSI device");
debug!("No serial for SCSI device: {:?}", device.devpath());
}
}
@@ -312,7 +305,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice {
device: dev_type,
dbus_path: path,
dbus_path: path
});
}
} else {
@@ -329,7 +322,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice {
device: dev_type,
dbus_path: path,
dbus_path: path
});
}
} else {
@@ -355,7 +348,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice {
device: dev_type,
dbus_path: path,
dbus_path: path
});
}
}
@@ -373,7 +366,7 @@ impl DeviceManager {
let conn_copy = connection.clone();
let devices = Arc::new(Mutex::new(Self::find_all_devices(&conn_copy).await));
let manager = Self {
_dbus_connection: connection,
_dbus_connection: connection
};
// TODO: The /sysfs/ LEDs don't cause events, so they need to be manually
@@ -433,14 +426,11 @@ impl DeviceManager {
info!("removing: {path:?}");
let dev = devices.lock().await.remove(index);
let path = path.clone();
match dev.device {
DeviceHandle::Scsi(_) => {
conn_copy
.object_server()
.remove::<ScsiZbus, _>(&path)
.await?;
}
_ => {}
if let DeviceHandle::Scsi(_) = dev.device {
conn_copy
.object_server()
.remove::<ScsiZbus, _>(&path)
.await?;
}
}
} else if action == "add" {
@@ -510,7 +500,7 @@ impl DeviceManager {
.remove::<ScsiZbus, _>(&path)
.await?
}
_ => todo!(),
_ => todo!()
};
info!("AuraManager removed: {path:?}, {res}");
}

View File

@@ -14,7 +14,7 @@ pub struct ScsiConfig {
pub dev_type: AuraDeviceType,
pub enabled: bool,
pub current_mode: AuraMode,
pub modes: BTreeMap<AuraMode, AuraEffect>,
pub modes: BTreeMap<AuraMode, AuraEffect>
}
impl ScsiConfig {
@@ -38,61 +38,61 @@ impl Default for ScsiConfig {
(AuraMode::Off, AuraEffect::default_with_mode(AuraMode::Off)),
(
AuraMode::Static,
AuraEffect::default_with_mode(AuraMode::Static),
AuraEffect::default_with_mode(AuraMode::Static)
),
(
AuraMode::Breathe,
AuraEffect::default_with_mode(AuraMode::Breathe),
AuraEffect::default_with_mode(AuraMode::Breathe)
),
(
AuraMode::Flashing,
AuraEffect::default_with_mode(AuraMode::Flashing),
AuraEffect::default_with_mode(AuraMode::Flashing)
),
(
AuraMode::RainbowCycle,
AuraEffect::default_with_mode(AuraMode::RainbowCycle),
AuraEffect::default_with_mode(AuraMode::RainbowCycle)
),
(
AuraMode::RainbowWave,
AuraEffect::default_with_mode(AuraMode::RainbowWave),
AuraEffect::default_with_mode(AuraMode::RainbowWave)
),
(
AuraMode::RainbowCycleBreathe,
AuraEffect::default_with_mode(AuraMode::RainbowCycleBreathe),
AuraEffect::default_with_mode(AuraMode::RainbowCycleBreathe)
),
(
AuraMode::ChaseFade,
AuraEffect::default_with_mode(AuraMode::ChaseFade),
AuraEffect::default_with_mode(AuraMode::ChaseFade)
),
(
AuraMode::RainbowCycleChaseFade,
AuraEffect::default_with_mode(AuraMode::RainbowCycleChaseFade),
AuraEffect::default_with_mode(AuraMode::RainbowCycleChaseFade)
),
(
AuraMode::Chase,
AuraEffect::default_with_mode(AuraMode::Chase),
AuraEffect::default_with_mode(AuraMode::Chase)
),
(
AuraMode::RainbowCycleChase,
AuraEffect::default_with_mode(AuraMode::RainbowCycleChase),
AuraEffect::default_with_mode(AuraMode::RainbowCycleChase)
),
(
AuraMode::RainbowCycleWave,
AuraEffect::default_with_mode(AuraMode::RainbowCycleWave),
AuraEffect::default_with_mode(AuraMode::RainbowCycleWave)
),
(
AuraMode::RainbowPulseChase,
AuraEffect::default_with_mode(AuraMode::RainbowPulseChase),
AuraEffect::default_with_mode(AuraMode::RainbowPulseChase)
),
(
AuraMode::RandomFlicker,
AuraEffect::default_with_mode(AuraMode::RandomFlicker),
AuraEffect::default_with_mode(AuraMode::RandomFlicker)
),
(
AuraMode::DoubleFade,
AuraEffect::default_with_mode(AuraMode::DoubleFade),
),
]),
AuraEffect::default_with_mode(AuraMode::DoubleFade)
)
])
}
}
}

View File

@@ -12,7 +12,7 @@ pub mod trait_impls;
#[derive(Clone)]
pub struct ScsiAura {
device: Arc<Mutex<Device>>,
config: Arc<Mutex<ScsiConfig>>,
config: Arc<Mutex<ScsiConfig>>
}
impl ScsiAura {

View File

@@ -22,7 +22,7 @@ impl ScsiZbus {
pub async fn start_tasks(
self,
connection: &Connection,
path: OwnedObjectPath,
path: OwnedObjectPath
) -> Result<(), RogError> {
connection
.object_server()
@@ -34,7 +34,7 @@ impl ScsiZbus {
}
}
#[interface(name = "org.asuslinux.ScsiAura")]
#[interface(name = "xyz.ljones.ScsiAura")]
impl ScsiZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
@@ -87,7 +87,7 @@ impl ScsiZbus {
let mode = config.current_mode;
match config.modes.get(&mode) {
Some(effect) => Ok(effect.clone()),
None => Err(ZbErr::Failed("Could not get the current effect".into())),
None => Err(ZbErr::Failed("Could not get the current effect".into()))
}
} else {
Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))

View File

@@ -9,20 +9,30 @@ const CONFIG_FILE: &str = "slash.ron";
pub struct SlashConfig {
#[serde(skip)]
pub slash_type: SlashType,
pub slash_enabled: bool,
pub slash_brightness: u8,
pub slash_interval: u8,
pub slash_mode: SlashMode,
pub enabled: bool,
pub brightness: u8,
pub display_interval: u8,
pub display_mode: SlashMode,
pub show_on_boot: bool,
pub show_on_shutdown: bool,
pub show_on_sleep: bool,
pub show_on_battery: bool,
pub show_battery_warning: bool
}
impl Default for SlashConfig {
fn default() -> Self {
SlashConfig {
slash_enabled: true,
slash_brightness: 255,
slash_interval: 0,
slash_mode: SlashMode::Bounce,
enabled: true,
brightness: 255,
display_interval: 0,
display_mode: SlashMode::Bounce,
slash_type: SlashType::Unsupported,
show_on_boot: true,
show_on_shutdown: true,
show_on_sleep: true,
show_on_battery: true,
show_battery_warning: true
}
}
}
@@ -45,10 +55,10 @@ impl StdConfigLoad for SlashConfig {}
impl From<&SlashConfig> for DeviceState {
fn from(config: &SlashConfig) -> Self {
DeviceState {
slash_enabled: config.slash_enabled,
slash_brightness: config.slash_brightness,
slash_interval: config.slash_interval,
slash_mode: config.slash_mode,
slash_enabled: config.enabled,
slash_brightness: config.brightness,
slash_interval: config.display_interval,
slash_mode: config.display_mode
}
}
}

View File

@@ -3,7 +3,7 @@ use std::sync::Arc;
use config::SlashConfig;
use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw;
use rog_slash::usb::{pkt_set_mode, pkt_set_options, pkts_for_init};
use rog_slash::usb::{get_options_packet, pkt_set_mode, pkts_for_init};
use rog_slash::SlashType;
use tokio::sync::{Mutex, MutexGuard};
@@ -16,14 +16,14 @@ pub mod trait_impls;
pub struct Slash {
hid: Option<Arc<Mutex<HidRaw>>>,
usb: Option<Arc<Mutex<USBRaw>>>,
config: Arc<Mutex<SlashConfig>>,
config: Arc<Mutex<SlashConfig>>
}
impl Slash {
pub fn new(
hid: Option<Arc<Mutex<HidRaw>>>,
usb: Option<Arc<Mutex<USBRaw>>>,
config: Arc<Mutex<SlashConfig>>,
config: Arc<Mutex<SlashConfig>>
) -> Self {
Self { hid, usb, config }
}
@@ -53,15 +53,15 @@ impl Slash {
}
// Apply config upon initialization
let option_packets = pkt_set_options(
let option_packets = get_options_packet(
config.slash_type,
config.slash_enabled,
config.slash_brightness,
config.slash_interval,
config.enabled,
config.brightness,
config.display_interval
);
self.write_bytes(&option_packets).await?;
let mode_packets = pkt_set_mode(config.slash_type, config.slash_mode);
let mode_packets = pkt_set_mode(config.slash_type, config.display_mode);
// self.node.write_bytes(&mode_packets[0])?;
self.write_bytes(&mode_packets[1]).await?;

View File

@@ -1,6 +1,9 @@
use config_traits::StdConfig;
use log::{debug, error, warn};
use rog_slash::usb::{pkt_save, pkt_set_mode, pkt_set_options};
use rog_slash::usb::{
get_battery_saver_packet, get_boot_packet, get_low_battery_packet, get_options_packet,
get_shutdown_packet, get_sleep_packet, pkt_save, pkt_set_mode
};
use rog_slash::{DeviceState, SlashMode};
use zbus::zvariant::OwnedObjectPath;
use zbus::{interface, Connection};
@@ -20,7 +23,7 @@ impl SlashZbus {
pub async fn start_tasks(
mut self,
connection: &Connection,
path: OwnedObjectPath,
path: OwnedObjectPath
) -> Result<(), RogError> {
// let task = zbus.clone();
self.reload()
@@ -36,30 +39,30 @@ impl SlashZbus {
}
}
#[interface(name = "org.asuslinux.Slash")]
#[interface(name = "xyz.ljones.Slash")]
impl SlashZbus {
/// Get enabled or not
#[zbus(property)]
async fn enabled(&self) -> bool {
let lock = self.0.lock_config().await;
lock.slash_enabled
lock.enabled
}
/// Set enabled true or false
#[zbus(property)]
async fn set_enabled(&self, enabled: bool) {
let mut config = self.0.lock_config().await;
let brightness = if enabled && config.slash_brightness == 0 {
let brightness = if enabled && config.brightness == 0 {
0x88
} else {
config.slash_brightness
config.brightness
};
self.0
.write_bytes(&pkt_set_options(
.write_bytes(&get_options_packet(
config.slash_type,
enabled,
brightness,
config.slash_interval,
config.display_interval
))
.await
.map_err(|err| {
@@ -67,8 +70,8 @@ impl SlashZbus {
})
.ok();
config.slash_enabled = enabled;
config.slash_brightness = brightness;
config.enabled = enabled;
config.brightness = brightness;
config.write();
}
@@ -76,7 +79,7 @@ impl SlashZbus {
#[zbus(property)]
async fn brightness(&self) -> u8 {
let config = self.0.lock_config().await;
config.slash_brightness
config.brightness
}
/// Set brightness level
@@ -85,11 +88,11 @@ impl SlashZbus {
let mut config = self.0.lock_config().await;
let enabled = brightness > 0;
self.0
.write_bytes(&pkt_set_options(
.write_bytes(&get_options_packet(
config.slash_type,
enabled,
brightness,
config.slash_interval,
config.display_interval
))
.await
.map_err(|err| {
@@ -97,15 +100,15 @@ impl SlashZbus {
})
.ok();
config.slash_enabled = enabled;
config.slash_brightness = brightness;
config.enabled = enabled;
config.brightness = brightness;
config.write();
}
#[zbus(property)]
async fn interval(&self) -> u8 {
let config = self.0.lock_config().await;
config.slash_interval
config.display_interval
}
/// Set interval between slash animations (0-255)
@@ -113,11 +116,8 @@ impl SlashZbus {
async fn set_interval(&self, interval: u8) {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&pkt_set_options(
config.slash_type,
config.slash_enabled,
config.slash_brightness,
interval,
.write_bytes(&get_options_packet(
config.slash_type, config.enabled, config.brightness, interval
))
.await
.map_err(|err| {
@@ -125,40 +125,29 @@ impl SlashZbus {
})
.ok();
config.slash_interval = interval;
config.display_interval = interval;
config.write();
}
#[zbus(property)]
async fn slash_mode(&self) -> u8 {
async fn mode(&self) -> zbus::fdo::Result<u8> {
let config = self.0.lock_config().await;
config.slash_interval
Ok(config.display_interval)
}
/// Set interval between slash animations (0-255)
#[zbus(property)]
async fn set_slash_mode(&self, slash_mode: SlashMode) {
async fn set_mode(&self, mode: SlashMode) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
let command_packets = pkt_set_mode(config.slash_type, slash_mode);
let command_packets = pkt_set_mode(config.slash_type, mode);
// self.node.write_bytes(&command_packets[0])?;
self.0
.write_bytes(&command_packets[1])
.await
.map_err(|err| {
warn!("ctrl_slash::set_options {}", err);
})
.ok();
self.0
.write_bytes(&pkt_save(config.slash_type))
.await
.map_err(|err| {
warn!("ctrl_slash::set_options {}", err);
})
.ok();
self.0.write_bytes(&command_packets[1]).await?;
self.0.write_bytes(&pkt_save(config.slash_type)).await?;
config.slash_mode = slash_mode;
config.display_mode = mode;
config.write();
Ok(())
}
/// Get the device state as stored by asusd
@@ -167,6 +156,91 @@ impl SlashZbus {
let config = self.0.lock_config().await;
DeviceState::from(&*config)
}
#[zbus(property)]
async fn show_on_boot(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_boot)
}
#[zbus(property)]
async fn set_show_on_boot(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_boot_packet(config.slash_type, enable))
.await?;
config.show_on_boot = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_on_sleep(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_sleep)
}
#[zbus(property)]
async fn set_show_on_sleep(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_sleep_packet(config.slash_type, enable))
.await?;
config.show_on_sleep = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_on_shutdown(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_shutdown)
}
#[zbus(property)]
async fn set_show_on_shutdown(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_shutdown_packet(config.slash_type, enable))
.await?;
config.show_on_shutdown = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_on_battery(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_battery)
}
#[zbus(property)]
async fn set_show_on_battery(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_battery_saver_packet(config.slash_type, enable))
.await?;
config.show_on_battery = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_battery_warning(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_battery_warning)
}
#[zbus(property)]
async fn set_show_battery_warning(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_low_battery_packet(config.slash_type, enable))
.await?;
config.show_battery_warning = enable;
config.write();
Ok(())
}
}
impl Reloadable for SlashZbus {
@@ -174,17 +248,40 @@ impl Reloadable for SlashZbus {
debug!("reloading slash settings");
let config = self.0.lock_config().await;
self.0
.write_bytes(&pkt_set_options(
.write_bytes(&get_options_packet(
config.slash_type,
config.slash_enabled,
config.slash_brightness,
config.slash_interval,
config.enabled,
config.brightness,
config.display_interval
))
.await
.map_err(|err| {
warn!("ctrl_slash::set_options {}", err);
warn!("set_options {}", err);
})
.ok();
macro_rules! write_bytes_with_warning {
($packet_fn:expr, $cfg:ident, $warn_msg:expr) => {
self.0
.write_bytes(&$packet_fn(config.slash_type, config.$cfg))
.await
.map_err(|err| {
warn!("{} {}", $warn_msg, err);
})
.ok();
};
}
write_bytes_with_warning!(get_boot_packet, show_on_boot, "show_on_boot");
write_bytes_with_warning!(get_sleep_packet, show_on_sleep, "show_on_sleep");
write_bytes_with_warning!(get_shutdown_packet, show_on_shutdown, "show_on_shutdown");
write_bytes_with_warning!(get_battery_saver_packet, show_on_battery, "show_on_battery");
write_bytes_with_warning!(
get_low_battery_packet,
show_battery_warning,
"show_battery_warning"
);
Ok(())
}
}

View File

@@ -31,7 +31,7 @@ pub enum _DeviceHandle {
LedClass(KeyboardBacklight),
/// TODO
MulticolourLed,
None,
None
}
#[derive(Clone)]
@@ -47,14 +47,14 @@ pub enum DeviceHandle {
TufLedClass(Arc<Mutex<HidRaw>>),
/// TODO
MulticolourLed,
None,
None
}
impl DeviceHandle {
/// Try Slash HID. If one exists it is initialsed and returned.
pub async fn new_slash_hid(
device: Arc<Mutex<HidRaw>>,
prod_id: &str,
prod_id: &str
) -> Result<Self, RogError> {
debug!("Testing for HIDRAW Slash");
let slash_type = SlashType::from_dmi();
@@ -93,7 +93,7 @@ impl DeviceHandle {
let slash = Slash::new(
None,
Some(Arc::new(Mutex::new(usb))),
Arc::new(Mutex::new(config)),
Arc::new(Mutex::new(config))
);
slash.do_initialization().await?;
Ok(Self::Slash(slash))
@@ -104,23 +104,28 @@ impl DeviceHandle {
/// Try AniMe Matrix HID. If one exists it is initialsed and returned.
pub async fn maybe_anime_hid(
device: Arc<Mutex<HidRaw>>,
prod_id: &str,
_device: Arc<Mutex<HidRaw>>,
_prod_id: &str
) -> Result<Self, RogError> {
debug!("Testing for HIDRAW AniMe");
let anime_type = AnimeType::from_dmi();
dbg!(prod_id);
if matches!(anime_type, AnimeType::Unsupported) || prod_id != "193b" {
log::info!("Unknown or invalid AniMe: {prod_id:?}, skipping");
return Err(RogError::NotFound("No anime-matrix device".to_string()));
}
info!("Found AniMe Matrix HIDRAW {anime_type:?}: {prod_id}");
// TODO: can't use HIDRAW for anime at the moment
Err(RogError::NotFound(
"Can't use anime over hidraw yet. Skip.".to_string()
))
let mut config = AniMeConfig::new().load();
config.anime_type = anime_type;
let mut anime = AniMe::new(Some(device), None, Arc::new(Mutex::new(config)));
anime.do_initialization().await?;
Ok(Self::AniMe(anime))
// debug!("Testing for HIDRAW AniMe");
// let anime_type = AnimeType::from_dmi();
// dbg!(prod_id);
// if matches!(anime_type, AnimeType::Unsupported) || prod_id != "193b"
// { log::info!("Unknown or invalid AniMe: {prod_id:?},
// skipping"); return Err(RogError::NotFound("No
// anime-matrix device".to_string())); }
// info!("Found AniMe Matrix HIDRAW {anime_type:?}: {prod_id}");
// let mut config = AniMeConfig::new().load();
// config.anime_type = anime_type;
// let mut anime = AniMe::new(Some(device), None,
// Arc::new(Mutex::new(config))); anime.do_initialization().
// await?; Ok(Self::AniMe(anime))
}
pub async fn maybe_anime_usb() -> Result<Self, RogError> {
@@ -139,13 +144,13 @@ impl DeviceHandle {
let mut anime = AniMe::new(
None,
Some(Arc::new(Mutex::new(usb))),
Arc::new(Mutex::new(config)),
Arc::new(Mutex::new(config))
);
anime.do_initialization().await?;
Ok(Self::AniMe(anime))
} else {
Err(RogError::NotFound(
"No AnimeMatrix device found".to_string(),
"No AnimeMatrix device found".to_string()
))
}
}
@@ -169,7 +174,7 @@ impl DeviceHandle {
pub async fn maybe_laptop_aura(
device: Option<Arc<Mutex<HidRaw>>>,
prod_id: &str,
prod_id: &str
) -> Result<Self, RogError> {
debug!("Testing for laptop aura");
let aura_type = AuraDeviceType::from(prod_id);
@@ -196,7 +201,7 @@ impl DeviceHandle {
let aura = Aura {
hid: device,
backlight,
config: Arc::new(Mutex::new(config)),
config: Arc::new(Mutex::new(config))
};
aura.do_initialization().await?;
Ok(Self::Aura(aura))

View File

@@ -1,66 +1,64 @@
use std::collections::HashMap;
use config_traits::{StdConfig, StdConfigLoad1};
use rog_platform::asus_armoury::FirmwareAttribute;
use rog_platform::cpu::CPUEPP;
use rog_platform::platform::ThrottlePolicy;
use rog_platform::platform::PlatformProfile;
use serde::{Deserialize, Serialize};
const CONFIG_FILE: &str = "asusd.ron";
type Tunings = HashMap<PlatformProfile, HashMap<FirmwareAttribute, i32>>;
#[derive(Deserialize, Serialize, Debug, PartialEq, PartialOrd)]
#[derive(Deserialize, Serialize, PartialEq)]
pub struct Config {
// The current charge limit applied
pub charge_control_end_threshold: u8,
/// Save charge limit for restoring
#[serde(skip)]
pub base_charge_control_end_threshold: u8,
pub panel_od: bool,
pub boot_sound: bool,
pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool,
/// An optional command/script to run when power is changed to AC
pub ac_command: String,
/// An optional command/script to run when power is changed to battery
pub bat_command: String,
/// Set true if energy_performance_preference should be set if the
/// throttle/platform profile is changed
pub throttle_policy_linked_epp: bool,
/// Which throttle/profile to use on battery power
pub throttle_policy_on_battery: ThrottlePolicy,
/// platform profile is changed
pub platform_profile_linked_epp: bool,
/// Which platform profile to use on battery power
pub platform_profile_on_battery: PlatformProfile,
/// Should the throttle policy be set on bat/ac change?
pub change_throttle_policy_on_battery: bool,
/// Which throttle/profile to use on AC power
pub throttle_policy_on_ac: ThrottlePolicy,
/// Should the throttle policy be set on bat/ac change?
pub change_throttle_policy_on_ac: bool,
/// The energy_performance_preference for this throttle/platform profile
pub throttle_quiet_epp: CPUEPP,
/// The energy_performance_preference for this throttle/platform profile
pub throttle_balanced_epp: CPUEPP,
/// The energy_performance_preference for this throttle/platform profile
pub throttle_performance_epp: CPUEPP,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl1_spl: Option<u8>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl2_sppt: Option<u8>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_fppt: Option<u8>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_apu_sppt: Option<u8>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_platform_sppt: Option<u8>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub nv_dynamic_boost: Option<u8>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub nv_temp_target: Option<u8>,
pub change_platform_profile_on_battery: bool,
/// Which platform profile to use on AC power
pub platform_profile_on_ac: PlatformProfile,
/// Should the platform profile be set on bat/ac change?
pub change_platform_profile_on_ac: bool,
/// The energy_performance_preference for this platform profile
pub profile_quiet_epp: CPUEPP,
/// The energy_performance_preference for this platform profile
pub profile_balanced_epp: CPUEPP,
/// The energy_performance_preference for this platform profile
pub profile_performance_epp: CPUEPP,
pub ac_profile_tunings: Tunings,
pub dc_profile_tunings: Tunings,
pub armoury_settings: HashMap<FirmwareAttribute, i32>,
/// Temporary state for AC/Batt
#[serde(skip)]
pub last_power_plugged: u8,
pub last_power_plugged: u8
}
impl Config {
pub fn select_tunings(
&mut self,
power_plugged: bool,
profile: PlatformProfile
) -> &mut HashMap<FirmwareAttribute, i32> {
let config = if power_plugged {
&mut self.ac_profile_tunings
} else {
&mut self.dc_profile_tunings
};
config.entry(profile).or_insert_with(HashMap::new)
}
}
impl Default for Config {
@@ -68,28 +66,21 @@ impl Default for Config {
Self {
charge_control_end_threshold: 100,
base_charge_control_end_threshold: 100,
panel_od: false,
boot_sound: false,
mini_led_mode: false,
disable_nvidia_powerd_on_battery: true,
ac_command: Default::default(),
bat_command: Default::default(),
throttle_policy_linked_epp: true,
throttle_policy_on_battery: ThrottlePolicy::Quiet,
change_throttle_policy_on_battery: true,
throttle_policy_on_ac: ThrottlePolicy::Performance,
change_throttle_policy_on_ac: true,
throttle_quiet_epp: CPUEPP::Power,
throttle_balanced_epp: CPUEPP::BalancePower,
throttle_performance_epp: CPUEPP::Performance,
ppt_pl1_spl: Default::default(),
ppt_pl2_sppt: Default::default(),
ppt_fppt: Default::default(),
ppt_apu_sppt: Default::default(),
ppt_platform_sppt: Default::default(),
nv_dynamic_boost: Default::default(),
nv_temp_target: Default::default(),
last_power_plugged: Default::default(),
platform_profile_linked_epp: true,
platform_profile_on_battery: PlatformProfile::Quiet,
change_platform_profile_on_battery: true,
platform_profile_on_ac: PlatformProfile::Performance,
change_platform_profile_on_ac: true,
profile_quiet_epp: CPUEPP::Power,
profile_balanced_epp: CPUEPP::BalancePower,
profile_performance_epp: CPUEPP::Performance,
ac_profile_tunings: HashMap::default(),
dc_profile_tunings: HashMap::default(),
armoury_settings: HashMap::default(),
last_power_plugged: Default::default()
}
}
}
@@ -99,8 +90,8 @@ impl StdConfig for Config {
Config {
charge_control_end_threshold: 100,
disable_nvidia_powerd_on_battery: true,
throttle_policy_on_battery: ThrottlePolicy::Quiet,
throttle_policy_on_ac: ThrottlePolicy::Performance,
platform_profile_on_battery: PlatformProfile::Quiet,
platform_profile_on_ac: PlatformProfile::Performance,
ac_command: String::new(),
bat_command: String::new(),
..Default::default()
@@ -116,58 +107,68 @@ impl StdConfig for Config {
}
}
impl StdConfigLoad1<Config507> for Config {}
impl StdConfigLoad1<Config601> for Config {}
#[derive(Deserialize, Serialize)]
pub struct Config507 {
// The current charge limit applied
pub struct Config601 {
pub charge_control_end_threshold: u8,
#[serde(skip)]
pub base_charge_control_end_threshold: u8,
pub panel_od: bool,
pub boot_sound: bool,
pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String,
pub bat_command: String,
pub platform_policy_linked_epp: bool,
pub platform_policy_on_battery: ThrottlePolicy,
pub platform_policy_on_ac: ThrottlePolicy,
//
pub platform_profile_linked_epp: bool,
pub platform_profile_on_battery: PlatformProfile,
pub change_platform_profile_on_battery: bool,
pub platform_profile_on_ac: PlatformProfile,
pub change_platform_profile_on_ac: bool,
pub profile_quiet_epp: CPUEPP,
pub profile_balanced_epp: CPUEPP,
pub profile_performance_epp: CPUEPP,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl1_spl: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl2_sppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl3_fppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_fppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_apu_sppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_platform_sppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub nv_dynamic_boost: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub nv_temp_target: Option<u8>,
#[serde(skip)]
pub last_power_plugged: u8
}
impl From<Config507> for Config {
fn from(c: Config507) -> Self {
impl From<Config601> for Config {
fn from(c: Config601) -> Self {
Self {
// Restore the base charge limit
charge_control_end_threshold: c.charge_control_end_threshold,
base_charge_control_end_threshold: c.charge_control_end_threshold,
panel_od: c.panel_od,
boot_sound: false,
disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
ac_command: c.ac_command,
bat_command: c.bat_command,
mini_led_mode: c.mini_led_mode,
throttle_policy_linked_epp: true,
throttle_policy_on_battery: c.platform_policy_on_battery,
change_throttle_policy_on_battery: true,
throttle_policy_on_ac: c.platform_policy_on_ac,
change_throttle_policy_on_ac: true,
throttle_quiet_epp: CPUEPP::Power,
throttle_balanced_epp: CPUEPP::BalancePower,
throttle_performance_epp: CPUEPP::Performance,
ppt_pl1_spl: c.ppt_pl1_spl,
ppt_pl2_sppt: c.ppt_pl2_sppt,
ppt_fppt: c.ppt_fppt,
ppt_apu_sppt: c.ppt_apu_sppt,
ppt_platform_sppt: c.ppt_platform_sppt,
nv_dynamic_boost: c.nv_dynamic_boost,
nv_temp_target: c.nv_temp_target,
last_power_plugged: 0,
platform_profile_linked_epp: c.platform_profile_linked_epp,
platform_profile_on_battery: c.platform_profile_on_battery,
change_platform_profile_on_battery: c.change_platform_profile_on_battery,
platform_profile_on_ac: c.platform_profile_on_ac,
change_platform_profile_on_ac: c.change_platform_profile_on_ac,
profile_quiet_epp: c.profile_quiet_epp,
profile_balanced_epp: c.profile_balanced_epp,
profile_performance_epp: c.profile_performance_epp,
last_power_plugged: c.last_power_plugged,
ac_profile_tunings: HashMap::default(),
dc_profile_tunings: HashMap::default(),
armoury_settings: HashMap::default()
}
}
}

View File

@@ -4,7 +4,7 @@ use std::sync::Arc;
use config_traits::{StdConfig, StdConfigLoad};
use futures_lite::StreamExt;
use log::{debug, error, info, warn};
use rog_platform::platform::{RogPlatform, ThrottlePolicy};
use rog_platform::platform::{PlatformProfile, RogPlatform};
use rog_profiles::error::ProfileError;
use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles};
@@ -17,13 +17,13 @@ use crate::error::RogError;
use crate::{CtrlTask, CONFIG_PATH_BASE};
pub const FAN_CURVE_ZBUS_NAME: &str = "FanCurves";
pub const FAN_CURVE_ZBUS_PATH: &str = "/org/asuslinux";
pub const FAN_CURVE_ZBUS_PATH: &str = "/xyz/ljones";
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct FanCurveConfig {
pub profiles: FanCurveProfiles,
#[serde(skip)]
pub current: u8,
pub current: PlatformProfile
}
impl StdConfig for FanCurveConfig {
@@ -47,14 +47,14 @@ impl StdConfigLoad for FanCurveConfig {}
#[derive(Debug, Clone)]
pub struct CtrlFanCurveZbus {
config: Arc<Mutex<FanCurveConfig>>,
platform: RogPlatform,
platform: RogPlatform
}
// Non-zbus-derive impl
impl CtrlFanCurveZbus {
pub fn new() -> Result<Self, RogError> {
let platform = RogPlatform::new()?;
if platform.has_throttle_thermal_policy() {
if platform.has_platform_profile() {
info!("Device has profile control available");
find_fan_curve_node()?;
info!("Device has fan curves available");
@@ -65,16 +65,16 @@ impl CtrlFanCurveZbus {
if config.profiles.balanced.is_empty() || !config.file_path().exists() {
info!("Fetching default fan curves");
let current = platform.get_throttle_thermal_policy()?;
let current = platform.get_platform_profile()?;
for this in [
ThrottlePolicy::Balanced,
ThrottlePolicy::Performance,
ThrottlePolicy::Quiet,
PlatformProfile::Balanced,
PlatformProfile::Performance,
PlatformProfile::Quiet
] {
// For each profile we need to switch to it before we
// can read the existing values from hardware. The ACPI method used
// for this is what limits us.
platform.set_throttle_thermal_policy(this.into())?;
platform.set_platform_profile(this.into())?;
let mut dev = find_fan_curve_node()?;
fan_curves.set_active_curve_to_defaults(this, &mut dev)?;
@@ -83,7 +83,7 @@ impl CtrlFanCurveZbus {
info!("{}", String::from(curve));
}
}
platform.set_throttle_thermal_policy(current)?;
platform.set_platform_profile(current.as_str())?;
config.profiles = fan_curves;
config.write();
} else {
@@ -93,7 +93,7 @@ impl CtrlFanCurveZbus {
return Ok(Self {
config: Arc::new(Mutex::new(config)),
platform,
platform
});
}
@@ -101,14 +101,14 @@ impl CtrlFanCurveZbus {
}
}
#[interface(name = "org.asuslinux.FanCurves")]
#[interface(name = "xyz.ljones.FanCurves")]
impl CtrlFanCurveZbus {
/// Set all fan curves for a profile to enabled status. Will also activate a
/// fan curve if in the same profile mode
async fn set_fan_curves_enabled(
&mut self,
profile: ThrottlePolicy,
enabled: bool,
profile: PlatformProfile,
enabled: bool
) -> zbus::fdo::Result<()> {
self.config
.lock()
@@ -128,9 +128,9 @@ impl CtrlFanCurveZbus {
/// activate a fan curve if in the same profile mode
async fn set_profile_fan_curve_enabled(
&mut self,
profile: ThrottlePolicy,
profile: PlatformProfile,
fan: FanCurvePU,
enabled: bool,
enabled: bool
) -> zbus::fdo::Result<()> {
self.config
.lock()
@@ -149,7 +149,7 @@ impl CtrlFanCurveZbus {
/// Get the fan-curve data for the currently active ThrottlePolicy
async fn fan_curve_data(
&mut self,
profile: ThrottlePolicy,
profile: PlatformProfile
) -> zbus::fdo::Result<Vec<CurveData>> {
let curve = self
.config
@@ -165,15 +165,15 @@ impl CtrlFanCurveZbus {
/// Will also activate the fan curve if the user is in the same mode.
async fn set_fan_curve(
&mut self,
profile: ThrottlePolicy,
curve: CurveData,
profile: PlatformProfile,
curve: CurveData
) -> zbus::fdo::Result<()> {
self.config
.lock()
.await
.profiles
.save_fan_curve(curve, profile)?;
let active: ThrottlePolicy = self.platform.get_throttle_thermal_policy()?.into();
let active: PlatformProfile = self.platform.get_platform_profile()?.into();
if active == profile {
self.config
.lock()
@@ -190,15 +190,15 @@ impl CtrlFanCurveZbus {
///
/// Each platform_profile has a different default and the default can be
/// read only for the currently active profile.
async fn set_curves_to_defaults(&mut self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> {
let active = self.platform.get_throttle_thermal_policy()?;
self.platform.set_throttle_thermal_policy(profile.into())?;
async fn set_curves_to_defaults(&mut self, profile: PlatformProfile) -> zbus::fdo::Result<()> {
let active = self.platform.get_platform_profile()?;
self.platform.set_platform_profile(profile.into())?;
self.config
.lock()
.await
.profiles
.set_active_curve_to_defaults(profile, &mut find_fan_curve_node()?)?;
self.platform.set_throttle_thermal_policy(active)?;
self.platform.set_platform_profile(active.as_str())?;
self.config.lock().await.write();
Ok(())
}
@@ -208,16 +208,16 @@ impl CtrlFanCurveZbus {
///
/// Each platform_profile has a different default and the defualt can be
/// read only for the currently active profile.
async fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> {
let active = self.platform.get_throttle_thermal_policy()?;
async fn reset_profile_curves(&self, profile: PlatformProfile) -> zbus::fdo::Result<()> {
let active = self.platform.get_platform_profile()?;
self.platform.set_throttle_thermal_policy(profile.into())?;
self.platform.set_platform_profile(profile.into())?;
self.config
.lock()
.await
.profiles
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
self.platform.set_throttle_thermal_policy(active)?;
.set_active_curve_to_defaults((&active).into(), &mut find_fan_curve_node()?)?;
self.platform.set_platform_profile(active.as_str())?;
self.config.lock().await.write();
Ok(())
@@ -236,27 +236,32 @@ impl CtrlTask for CtrlFanCurveZbus {
}
async fn create_tasks(&self, _signal_ctxt: SignalEmitter<'static>) -> Result<(), RogError> {
let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?;
let watch_platform_profile = self.platform.monitor_platform_profile()?;
let platform = self.platform.clone();
let config = self.config.clone();
let fan_curves = self.config.clone();
tokio::spawn(async move {
let mut buffer = [0; 32];
if let Ok(mut stream) = watch_throttle_thermal_policy.into_event_stream(&mut buffer) {
if let Ok(mut stream) = watch_platform_profile.into_event_stream(&mut buffer) {
while (stream.next().await).is_some() {
debug!("watch_throttle_thermal_policy changed");
if let Ok(profile) = platform.get_throttle_thermal_policy().map_err(|e| {
error!("get_throttle_thermal_policy error: {e}");
}) {
debug!("watch_platform_profile changed");
if let Ok(profile) =
platform
.get_platform_profile()
.map(|p| p.into())
.map_err(|e| {
error!("get_platform_profile error: {e}");
})
{
if profile != config.lock().await.current {
fan_curves
.lock()
.await
.profiles
.write_profile_curve_to_platform(
profile.into(),
&mut find_fan_curve_node().unwrap(),
profile,
&mut find_fan_curve_node().unwrap()
)
.map_err(|e| warn!("write_profile_curve_to_platform, {}", e))
.ok();
@@ -274,7 +279,7 @@ impl CtrlTask for CtrlFanCurveZbus {
impl crate::Reloadable for CtrlFanCurveZbus {
/// Fetch the active profile and use that to set all related components up
async fn reload(&mut self) -> Result<(), RogError> {
let active = self.platform.get_throttle_thermal_policy()?.into();
let active = self.platform.get_platform_profile()?.into();
let mut config = self.config.lock().await;
if let Ok(mut device) = find_fan_curve_node() {
config

View File

@@ -4,20 +4,21 @@ use std::sync::Arc;
use config_traits::StdConfig;
use log::{debug, error, info, warn};
use rog_platform::asus_armoury::FirmwareAttributes;
use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
// use rog_platform::firmware_attributes::FirmwareAttributes;
use rog_platform::platform::{GpuMode, Properties, RogPlatform, ThrottlePolicy};
use rog_platform::platform::{PlatformProfile, Properties, RogPlatform};
use rog_platform::power::AsusPower;
use zbus::export::futures_util::lock::Mutex;
use zbus::fdo::Error as FdoErr;
use zbus::object_server::SignalEmitter;
use zbus::{interface, Connection};
use crate::asus_armoury::set_config_or_default;
use crate::config::Config;
use crate::error::RogError;
use crate::{task_watch_item, task_watch_item_notify, CtrlTask, ReloadAndNotify};
use crate::{task_watch_item, CtrlTask, ReloadAndNotify};
const PLATFORM_ZBUS_PATH: &str = "/org/asuslinux";
const PLATFORM_ZBUS_PATH: &str = "/xyz/ljones";
macro_rules! platform_get_value {
($self:ident, $property:tt, $prop_name:literal) => {
@@ -38,73 +39,22 @@ macro_rules! platform_get_value {
}
}
macro_rules! platform_set_value {
($self:ident, $property:tt, $prop_name:literal, $new_value:expr) => {
concat_idents::concat_idents!(has = has_, $property {
if $self.platform.has() {
concat_idents::concat_idents!(set = set_, $property {
$self.platform.set($new_value).map_err(|err| {
error!("RogPlatform: {} {err}", $prop_name);
FdoErr::Failed(format!("RogPlatform: {} {err}", $prop_name))
})?;
});
let mut lock = $self.config.lock().await;
lock.$property = $new_value;
lock.write();
Ok(())
} else {
debug!("RogPlatform: {} not supported", $prop_name);
Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)))
}
})
}
}
macro_rules! platform_ppt_set_value {
($self:ident, $property:tt, $prop_name:literal, $new_value:expr) => {
concat_idents::concat_idents!(has = has_, $property {
if $self.platform.has() {
concat_idents::concat_idents!(set = set_, $property {
$self.platform.set($new_value).map_err(|err| {
error!("RogPlatform: {} {err}", $prop_name);
FdoErr::NotSupported(format!("RogPlatform: {} {err}", $prop_name))
})?;
});
let mut lock = $self.config.lock().await;
lock.$property = Some($new_value);
lock.write();
Ok(())
} else {
debug!("RogPlatform: ppt: setting {} not supported", $prop_name);
Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)))
}
})
}
}
#[derive(Clone)]
pub struct CtrlPlatform {
power: AsusPower,
platform: RogPlatform,
cpu_control: Option<CPUControl>,
config: Arc<Mutex<Config>>,
config: Arc<Mutex<Config>>
}
impl CtrlPlatform {
pub fn new(
config: Arc<Mutex<Config>>,
config_path: &Path,
signal_context: SignalEmitter<'static>,
signal_context: SignalEmitter<'static>
) -> Result<Self, RogError> {
// let attrs = FirmwareAttributes::new();
let platform = RogPlatform::new()?;
let power = AsusPower::new()?;
if !platform.has_gpu_mux_mode() {
info!("G-Sync Switchable Graphics or GPU MUX not detected");
info!("Standard graphics switching will still work.");
}
let config1 = config.clone();
let config_path = config_path.to_owned();
@@ -114,7 +64,7 @@ impl CtrlPlatform {
config,
cpu_control: CPUControl::new()
.map_err(|e| error!("Couldn't get CPU control sysfs: {e}"))
.ok(),
.ok()
};
let mut inotify_self = ret_self.clone();
@@ -133,7 +83,7 @@ impl CtrlPlatform {
inotify::WatchMask::MODIFY
| inotify::WatchMask::CLOSE_WRITE
| inotify::WatchMask::ATTRIB
| inotify::WatchMask::CREATE,
| inotify::WatchMask::CREATE
)
.inspect_err(|e| {
if e.kind() == std::io::ErrorKind::NotFound {
@@ -170,23 +120,12 @@ impl CtrlPlatform {
Ok(ret_self)
}
fn set_gfx_mode(&self, mode: GpuMode) -> Result<(), RogError> {
self.platform.set_gpu_mux_mode(mode.to_mux_attr())?;
// self.update_initramfs(enable)?;
if mode == GpuMode::Ultimate {
info!("Set system-level graphics mode: Dedicated Nvidia");
} else {
info!("Set system-level graphics mode: Optimus");
}
Ok(())
}
async fn restore_charge_limit(&self) {
let limit = self.config.lock().await.base_charge_control_end_threshold;
if limit > 0
&& std::mem::replace(
&mut self.config.lock().await.charge_control_end_threshold,
limit,
limit
) != limit
{
self.power
@@ -264,45 +203,43 @@ impl CtrlPlatform {
}
}
async fn get_config_epp_for_throttle(&self, throttle: ThrottlePolicy) -> CPUEPP {
async fn get_config_epp_for_throttle(&self, throttle: PlatformProfile) -> CPUEPP {
match throttle {
ThrottlePolicy::Balanced => self.config.lock().await.throttle_balanced_epp,
ThrottlePolicy::Performance => self.config.lock().await.throttle_performance_epp,
ThrottlePolicy::Quiet => self.config.lock().await.throttle_quiet_epp,
PlatformProfile::Balanced => self.config.lock().await.profile_balanced_epp,
PlatformProfile::Performance => self.config.lock().await.profile_performance_epp,
PlatformProfile::Quiet => self.config.lock().await.profile_quiet_epp
}
}
async fn update_policy_ac_or_bat(&self, power_plugged: bool, change_epp: bool) {
if power_plugged && !self.config.lock().await.change_throttle_policy_on_ac {
if power_plugged && !self.config.lock().await.change_platform_profile_on_ac {
debug!(
"Power status changed but set_throttle_policy_on_ac set false. Not setting the \
"Power status changed but set_platform_profile_on_ac set false. Not setting the \
thing"
);
return;
}
if !power_plugged && !self.config.lock().await.change_throttle_policy_on_battery {
if !power_plugged && !self.config.lock().await.change_platform_profile_on_battery {
debug!(
"Power status changed but set_throttle_policy_on_battery set false. Not setting \
"Power status changed but set_platform_profile_on_battery set false. Not setting \
the thing"
);
return;
}
let throttle = if power_plugged {
self.config.lock().await.throttle_policy_on_ac
self.config.lock().await.platform_profile_on_ac
} else {
self.config.lock().await.throttle_policy_on_battery
self.config.lock().await.platform_profile_on_battery
};
debug!("Setting {throttle:?} before EPP");
let epp = self.get_config_epp_for_throttle(throttle).await;
self.platform
.set_throttle_thermal_policy(throttle.into())
.ok();
self.platform.set_platform_profile(throttle.into()).ok();
self.check_and_set_epp(epp, change_epp);
}
}
#[interface(name = "org.asuslinux.Platform")]
#[interface(name = "xyz.ljones.Platform")]
impl CtrlPlatform {
#[zbus(property)]
async fn version(&self) -> String {
@@ -339,21 +276,7 @@ impl CtrlPlatform {
Properties::ChargeControlEndThreshold
);
platform_name!(dgpu_disable, Properties::DgpuDisable);
platform_name!(gpu_mux_mode, Properties::GpuMuxMode);
platform_name!(boot_sound, Properties::PostAnimationSound);
platform_name!(panel_od, Properties::PanelOd);
platform_name!(mini_led_mode, Properties::MiniLedMode);
platform_name!(egpu_enable, Properties::EgpuEnable);
platform_name!(throttle_thermal_policy, Properties::ThrottlePolicy);
platform_name!(ppt_pl1_spl, Properties::PptPl1Spl);
platform_name!(ppt_pl2_sppt, Properties::PptPl2Sppt);
platform_name!(ppt_fppt, Properties::PptFppt);
platform_name!(ppt_apu_sppt, Properties::PptApuSppt);
platform_name!(ppt_platform_sppt, Properties::PptPlatformSppt);
platform_name!(nv_dynamic_boost, Properties::NvDynamicBoost);
platform_name!(nv_temp_target, Properties::NvTempTarget);
platform_name!(platform_profile, Properties::ThrottlePolicy);
supported
}
@@ -379,7 +302,7 @@ impl CtrlPlatform {
async fn one_shot_full_charge(&self) -> Result<(), FdoErr> {
let base_limit = std::mem::replace(
&mut self.config.lock().await.charge_control_end_threshold,
100,
100
);
if base_limit != 100 {
self.power.set_charge_control_end_threshold(100)?;
@@ -389,147 +312,121 @@ impl CtrlPlatform {
Ok(())
}
#[zbus(property)]
fn gpu_mux_mode(&self) -> Result<u8, FdoErr> {
self.platform.get_gpu_mux_mode().map_err(|err| {
warn!("get_gpu_mux_mode {err}");
FdoErr::NotSupported("RogPlatform: set_gpu_mux_mode not supported".to_owned())
})
}
#[zbus(property)]
async fn set_gpu_mux_mode(&mut self, mode: u8) -> Result<(), FdoErr> {
if self.platform.has_gpu_mux_mode() {
self.set_gfx_mode(mode.into()).map_err(|err| {
warn!("set_gpu_mux_mode {}", err);
FdoErr::Failed(format!("RogPlatform: set_gpu_mux_mode: {err}"))
})?;
self.config.lock().await.write();
} else {
return Err(FdoErr::NotSupported(
"RogPlatform: set_gpu_mux_mode not supported".to_owned(),
));
}
Ok(())
}
/// Toggle to next platform_profile. Names provided by `Profiles`.
/// If fan-curves are supported will also activate a fan curve for profile.
async fn next_throttle_thermal_policy(
async fn next_platform_profile(
&mut self,
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
#[zbus(signal_context)] ctxt: SignalEmitter<'_>
) -> Result<(), FdoErr> {
let policy: ThrottlePolicy =
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
.map(|n| n.into())?;
let policy = ThrottlePolicy::next(policy);
let policy: PlatformProfile =
platform_get_value!(self, platform_profile, "platform_profile").map(|n| n.into())?;
let policy = PlatformProfile::next(policy);
if self.platform.has_throttle_thermal_policy() {
let change_epp = self.config.lock().await.throttle_policy_linked_epp;
if self.platform.has_platform_profile() {
let change_epp = self.config.lock().await.platform_profile_linked_epp;
let epp = self.get_config_epp_for_throttle(policy).await;
self.check_and_set_epp(epp, change_epp);
self.platform
.set_throttle_thermal_policy(policy.into())
.set_platform_profile(policy.into())
.map_err(|err| {
warn!("throttle_thermal_policy {}", err);
FdoErr::Failed(format!("RogPlatform: throttle_thermal_policy: {err}"))
warn!("platform_profile {}", err);
FdoErr::Failed(format!("RogPlatform: platform_profile: {err}"))
})?;
Ok(self.throttle_thermal_policy_changed(&ctxt).await?)
Ok(self.platform_profile_changed(&ctxt).await?)
} else {
Err(FdoErr::NotSupported(
"RogPlatform: throttle_thermal_policy not supported".to_owned(),
"RogPlatform: platform_profile not supported".to_owned()
))
}
}
#[zbus(property)]
fn throttle_thermal_policy(&self) -> Result<ThrottlePolicy, FdoErr> {
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
.map(|n| n.into())
fn platform_profile(&self) -> Result<PlatformProfile, FdoErr> {
platform_get_value!(self, platform_profile, "platform_profile").map(|n| n.into())
}
#[zbus(property)]
async fn set_throttle_thermal_policy(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> {
async fn set_platform_profile(&mut self, policy: PlatformProfile) -> Result<(), FdoErr> {
// TODO: watch for external changes
if self.platform.has_throttle_thermal_policy() {
let change_epp = self.config.lock().await.throttle_policy_linked_epp;
if self.platform.has_platform_profile() {
let change_epp = self.config.lock().await.platform_profile_linked_epp;
let epp = self.get_config_epp_for_throttle(policy).await;
self.check_and_set_epp(epp, change_epp);
self.config.lock().await.write();
self.platform
.set_throttle_thermal_policy(policy.into())
.set_platform_profile(policy.into())
.map_err(|err| {
warn!("throttle_thermal_policy {}", err);
FdoErr::Failed(format!("RogPlatform: throttle_thermal_policy: {err}"))
warn!("platform_profile {}", err);
FdoErr::Failed(format!("RogPlatform: platform_profile: {err}"))
})
} else {
Err(FdoErr::NotSupported(
"RogPlatform: throttle_thermal_policy not supported".to_owned(),
"RogPlatform: platform_profile not supported".to_owned()
))
}
}
#[zbus(property)]
async fn throttle_policy_linked_epp(&self) -> Result<bool, FdoErr> {
Ok(self.config.lock().await.throttle_policy_linked_epp)
async fn platform_profile_linked_epp(&self) -> Result<bool, FdoErr> {
Ok(self.config.lock().await.platform_profile_linked_epp)
}
#[zbus(property)]
async fn set_throttle_policy_linked_epp(&self, linked: bool) -> Result<(), zbus::Error> {
self.config.lock().await.throttle_policy_linked_epp = linked;
async fn set_platform_profile_linked_epp(&self, linked: bool) -> Result<(), zbus::Error> {
self.config.lock().await.platform_profile_linked_epp = linked;
self.config.lock().await.write();
Ok(())
}
#[zbus(property)]
async fn throttle_policy_on_battery(&self) -> Result<ThrottlePolicy, FdoErr> {
Ok(self.config.lock().await.throttle_policy_on_battery)
async fn platform_profile_on_battery(&self) -> Result<PlatformProfile, FdoErr> {
Ok(self.config.lock().await.platform_profile_on_battery)
}
#[zbus(property)]
async fn set_throttle_policy_on_battery(
async fn set_platform_profile_on_battery(
&mut self,
policy: ThrottlePolicy,
policy: PlatformProfile
) -> Result<(), FdoErr> {
self.config.lock().await.throttle_policy_on_battery = policy;
self.set_throttle_thermal_policy(policy).await?;
self.config.lock().await.platform_profile_on_battery = policy;
self.set_platform_profile(policy).await?;
self.config.lock().await.write();
Ok(())
}
#[zbus(property)]
async fn change_throttle_policy_on_battery(&self) -> Result<bool, FdoErr> {
Ok(self.config.lock().await.change_throttle_policy_on_battery)
async fn change_platform_profile_on_battery(&self) -> Result<bool, FdoErr> {
Ok(self.config.lock().await.change_platform_profile_on_battery)
}
#[zbus(property)]
async fn set_change_throttle_policy_on_battery(&mut self, change: bool) -> Result<(), FdoErr> {
self.config.lock().await.change_throttle_policy_on_battery = change;
async fn set_change_platform_profile_on_battery(&mut self, change: bool) -> Result<(), FdoErr> {
self.config.lock().await.change_platform_profile_on_battery = change;
self.config.lock().await.write();
Ok(())
}
#[zbus(property)]
async fn throttle_policy_on_ac(&self) -> Result<ThrottlePolicy, FdoErr> {
Ok(self.config.lock().await.throttle_policy_on_ac)
async fn platform_profile_on_ac(&self) -> Result<PlatformProfile, FdoErr> {
Ok(self.config.lock().await.platform_profile_on_ac)
}
#[zbus(property)]
async fn set_throttle_policy_on_ac(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> {
self.config.lock().await.throttle_policy_on_ac = policy;
self.set_throttle_thermal_policy(policy).await?;
async fn set_platform_profile_on_ac(&mut self, policy: PlatformProfile) -> Result<(), FdoErr> {
self.config.lock().await.platform_profile_on_ac = policy;
self.set_platform_profile(policy).await?;
self.config.lock().await.write();
Ok(())
}
#[zbus(property)]
async fn change_throttle_policy_on_ac(&self) -> Result<bool, FdoErr> {
Ok(self.config.lock().await.change_throttle_policy_on_ac)
async fn change_platform_profile_on_ac(&self) -> Result<bool, FdoErr> {
Ok(self.config.lock().await.change_platform_profile_on_ac)
}
#[zbus(property)]
async fn set_change_throttle_policy_on_ac(&mut self, change: bool) -> Result<(), FdoErr> {
self.config.lock().await.change_throttle_policy_on_ac = change;
async fn set_change_platform_profile_on_ac(&mut self, change: bool) -> Result<(), FdoErr> {
self.config.lock().await.change_platform_profile_on_ac = change;
self.config.lock().await.write();
Ok(())
}
@@ -537,14 +434,14 @@ impl CtrlPlatform {
/// The energy_performance_preference for the quiet throttle/platform
/// profile
#[zbus(property)]
async fn throttle_quiet_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_quiet_epp)
async fn profile_quiet_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.profile_quiet_epp)
}
#[zbus(property)]
async fn set_throttle_quiet_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
self.config.lock().await.throttle_quiet_epp = epp;
async fn set_profile_quiet_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.platform_profile_linked_epp;
self.config.lock().await.profile_quiet_epp = epp;
self.check_and_set_epp(epp, change_pp);
self.config.lock().await.write();
Ok(())
@@ -553,14 +450,14 @@ impl CtrlPlatform {
/// The energy_performance_preference for the balanced throttle/platform
/// profile
#[zbus(property)]
async fn throttle_balanced_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_balanced_epp)
async fn profile_balanced_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.profile_balanced_epp)
}
#[zbus(property)]
async fn set_throttle_balanced_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
self.config.lock().await.throttle_balanced_epp = epp;
async fn set_profile_balanced_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.platform_profile_linked_epp;
self.config.lock().await.profile_balanced_epp = epp;
self.check_and_set_epp(epp, change_pp);
self.config.lock().await.write();
Ok(())
@@ -569,171 +466,18 @@ impl CtrlPlatform {
/// The energy_performance_preference for the performance throttle/platform
/// profile
#[zbus(property)]
async fn throttle_performance_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_performance_epp)
async fn profile_performance_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.profile_performance_epp)
}
#[zbus(property)]
async fn set_throttle_performance_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
self.config.lock().await.throttle_performance_epp = epp;
async fn set_profile_performance_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.platform_profile_linked_epp;
self.config.lock().await.profile_performance_epp = epp;
self.check_and_set_epp(epp, change_pp);
self.config.lock().await.write();
Ok(())
}
/// Get the `panel_od` value from platform. Updates the stored value in
/// internal config also.
#[zbus(property)]
fn panel_od(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, panel_od, "panel_od")
}
#[zbus(property)]
async fn set_panel_od(&mut self, overdrive: bool) -> Result<(), FdoErr> {
platform_set_value!(self, panel_od, "panel_od", overdrive)?;
self.config.lock().await.write();
Ok(())
}
/// Get the `boot_sound` value from platform. Updates the stored value in
/// internal config also.
#[zbus(property)]
fn boot_sound(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, boot_sound, "boot_sound")
}
#[zbus(property)]
async fn set_boot_sound(&mut self, on: bool) -> Result<(), FdoErr> {
platform_set_value!(self, boot_sound, "boot_sound", on)?;
self.config.lock().await.write();
Ok(())
}
/// Get the `panel_od` value from platform. Updates the stored value in
/// internal config also.
#[zbus(property)]
fn mini_led_mode(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, mini_led_mode, "mini_led_mode")
}
#[zbus(property)]
async fn set_mini_led_mode(&mut self, on: bool) -> Result<(), FdoErr> {
platform_set_value!(self, mini_led_mode, "mini_led_mode", on)?;
self.config.lock().await.write();
Ok(())
}
#[zbus(property)]
fn dgpu_disable(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, dgpu_disable, "dgpu_disable")
}
#[zbus(property)]
fn egpu_enable(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, egpu_enable, "egpu_enable")
}
/// ***********************************************************************
/// Set the Package Power Target total of CPU: PL1 on Intel, SPL on AMD.
/// Shown on Intel+Nvidia or AMD+Nvidia based systems:
/// * min=5, max=250
#[zbus(property)]
async fn ppt_pl1_spl(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, ppt_pl1_spl, "ppt_pl1_spl")
}
#[zbus(property)]
async fn set_ppt_pl1_spl(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, ppt_pl1_spl, "ppt_pl1_spl", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the Slow Package Power Tracking Limit of CPU: PL2 on Intel, SPPT,
/// on AMD. Shown on Intel+Nvidia or AMD+Nvidia based systems:
/// * min=5, max=250
#[zbus(property)]
async fn ppt_pl2_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, ppt_pl2_sppt, "ppt_pl2_sppt")
}
#[zbus(property)]
async fn set_ppt_pl2_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, ppt_pl2_sppt, "ppt_pl2_sppt", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the Fast Package Power Tracking Limit of CPU. AMD+Nvidia only:
/// * min=5, max=250
#[zbus(property)]
async fn ppt_fppt(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, ppt_fppt, "ppt_fppt")
}
#[zbus(property)]
async fn set_ppt_fppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, ppt_fppt, "ppt_fppt", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the APU SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
#[zbus(property)]
async fn ppt_apu_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, ppt_apu_sppt, "ppt_apu_sppt")
}
#[zbus(property)]
async fn set_ppt_apu_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, ppt_apu_sppt, "ppt_apu_sppt", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the platform SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
#[zbus(property)]
async fn ppt_platform_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, ppt_platform_sppt, "ppt_platform_sppt")
}
#[zbus(property)]
async fn set_ppt_platform_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, ppt_platform_sppt, "ppt_platform_sppt", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the dynamic boost limit of the Nvidia dGPU:
/// * min=5, max=25
#[zbus(property)]
async fn nv_dynamic_boost(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, nv_dynamic_boost, "nv_dynamic_boost")
}
#[zbus(property)]
async fn set_nv_dynamic_boost(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, nv_dynamic_boost, "nv_dynamic_boost", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the target temperature limit of the Nvidia dGPU:
/// * min=75, max=87
#[zbus(property)]
async fn nv_temp_target(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, nv_temp_target, "nv_temp_target")
}
#[zbus(property)]
async fn set_nv_temp_target(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, nv_temp_target, "nv_temp_target", value)?;
self.config.lock().await.write();
Ok(())
}
}
impl crate::ZbusRun for CtrlPlatform {
@@ -749,7 +493,7 @@ impl ReloadAndNotify for CtrlPlatform {
async fn reload_and_notify(
&mut self,
signal_context: &SignalEmitter<'static>,
data: Self::Data,
data: Self::Data
) -> Result<(), RogError> {
let mut config = self.config.lock().await;
if *config != data {
@@ -757,7 +501,9 @@ impl ReloadAndNotify for CtrlPlatform {
let mut base_charge_control_end_threshold = None;
if self.power.has_charge_control_end_threshold() {
if self.power.has_charge_control_end_threshold()
&& data.charge_control_end_threshold != config.charge_control_end_threshold
{
let limit = data.charge_control_end_threshold;
warn!("setting charge_control_end_threshold to {limit}");
self.power.set_charge_control_end_threshold(limit)?;
@@ -768,56 +514,25 @@ impl ReloadAndNotify for CtrlPlatform {
.or(Some(limit));
}
if self.platform.has_throttle_thermal_policy()
&& config.throttle_policy_linked_epp != data.throttle_policy_linked_epp
if self.platform.has_platform_profile()
&& config.platform_profile_linked_epp != data.platform_profile_linked_epp
{
// TODO: extra stuff
}
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
macro_rules! reload_and_notify {
($property:tt, $prop_name:literal) => {
concat_idents::concat_idents!(has = has_, $property {
if self.platform.has() && config.$property != data.$property {
concat_idents::concat_idents!(set = set_, $property {
self.platform
.set(data.$property)?;});
concat_idents::concat_idents!(changed = $property, _changed {
self.changed(signal_context).await?;});
}
})
}
let epp = match profile {
PlatformProfile::Balanced => data.profile_balanced_epp,
PlatformProfile::Performance => data.profile_performance_epp,
PlatformProfile::Quiet => data.profile_quiet_epp
};
warn!("setting epp to {epp:?}");
self.check_and_set_epp(epp, true);
}
reload_and_notify!(mini_led_mode, "mini_led_mode");
reload_and_notify!(panel_od, "panel_od");
reload_and_notify!(boot_sound, "boot_sound");
// reload_and_notify!(throttle_thermal_policy, "throttle_thermal_policy");
macro_rules! ppt_reload_and_notify {
($property:tt, $prop_name:literal) => {
concat_idents::concat_idents!(has = has_, $property {
if self.platform.has() && config.$property != data.$property {
concat_idents::concat_idents!(set = set_, $property {
self.platform
.set(data.$property.unwrap_or_default())?;});
concat_idents::concat_idents!(changed = $property, _changed {
self.changed(signal_context).await?;});
}
})
}
}
ppt_reload_and_notify!(ppt_pl1_spl, "ppt_pl1_spl");
ppt_reload_and_notify!(ppt_pl2_sppt, "ppt_pl2_sppt");
ppt_reload_and_notify!(ppt_fppt, "ppt_fppt");
ppt_reload_and_notify!(ppt_apu_sppt, "ppt_apu_sppt");
ppt_reload_and_notify!(ppt_platform_sppt, "ppt_platform_sppt");
ppt_reload_and_notify!(nv_dynamic_boost, "nv_dynamic_boost");
ppt_reload_and_notify!(nv_temp_target, "nv_temp_target");
// reload_and_notify!(platform_profile, "platform_profile");
*config = data;
config.base_charge_control_end_threshold =
base_charge_control_end_threshold.unwrap_or_default();
}
Ok(())
}
}
@@ -834,45 +549,10 @@ impl crate::Reloadable for CtrlPlatform {
warn!("No charge_control_end_threshold found")
}
macro_rules! reload {
($property:tt, $prop_name:literal) => {
concat_idents::concat_idents!(has = has_, $property {
if self.platform.has() {
concat_idents::concat_idents!(set = set_, $property {
self.platform
.set(self.config.lock().await.$property)?;});
}
})
}
}
reload!(mini_led_mode, "mini_led_mode");
reload!(panel_od, "panel_od");
reload!(boot_sound, "boot_sound");
macro_rules! ppt_reload {
($property:tt, $prop_name:literal) => {
concat_idents::concat_idents!(has = has_, $property {
if self.platform.has() {
concat_idents::concat_idents!(set = set_, $property {
self.platform
.set(self.config.lock().await.$property.unwrap_or_default())?;});
}
})
}
}
ppt_reload!(ppt_pl1_spl, "ppt_pl1_spl");
ppt_reload!(ppt_pl2_sppt, "ppt_pl2_sppt");
ppt_reload!(ppt_fppt, "ppt_fppt");
ppt_reload!(ppt_apu_sppt, "ppt_apu_sppt");
ppt_reload!(ppt_platform_sppt, "ppt_platform_sppt");
ppt_reload!(nv_dynamic_boost, "nv_dynamic_boost");
ppt_reload!(nv_temp_target, "nv_temp_target");
if let Ok(power_plugged) = self.power.get_online() {
self.config.lock().await.last_power_plugged = power_plugged;
if self.platform.has_throttle_thermal_policy() {
let change_epp = self.config.lock().await.throttle_policy_linked_epp;
if self.platform.has_platform_profile() {
let change_epp = self.config.lock().await.platform_profile_linked_epp;
self.update_policy_ac_or_bat(power_plugged > 0, change_epp)
.await;
}
@@ -884,34 +564,7 @@ impl crate::Reloadable for CtrlPlatform {
}
impl CtrlPlatform {
task_watch_item!(panel_od "panel_od" platform);
task_watch_item!(mini_led_mode "mini_led_mode" platform);
task_watch_item!(charge_control_end_threshold "charge_control_end_threshold" power);
task_watch_item_notify!(boot_sound platform);
task_watch_item_notify!(dgpu_disable platform);
task_watch_item_notify!(egpu_enable platform);
// NOTE: see note further below
task_watch_item_notify!(gpu_mux_mode platform);
task_watch_item_notify!(ppt_pl1_spl platform);
task_watch_item_notify!(ppt_pl2_sppt platform);
task_watch_item_notify!(ppt_fppt platform);
task_watch_item_notify!(ppt_apu_sppt platform);
task_watch_item_notify!(ppt_platform_sppt platform);
task_watch_item_notify!(nv_dynamic_boost platform);
task_watch_item_notify!(nv_temp_target platform);
}
impl CtrlTask for CtrlPlatform {
@@ -927,17 +580,6 @@ impl CtrlTask for CtrlPlatform {
move |sleeping| {
let platform1 = platform1.clone();
async move {
info!("RogPlatform reloading panel_od");
if !sleeping && platform1.platform.has_panel_od() {
platform1
.platform
.set_panel_od(platform1.config.lock().await.panel_od)
.map_err(|err| {
warn!("CtrlCharge: panel_od {}", err);
err
})
.ok();
}
// This block is commented out due to some kind of issue reported. Maybe the
// desktops used were storing a value whcih was then read here.
// Don't store it on suspend, assume that the current config setting is desired
@@ -951,15 +593,15 @@ impl CtrlTask for CtrlPlatform {
platform1
.power
.set_charge_control_end_threshold(
platform1.config.lock().await.charge_control_end_threshold,
platform1.config.lock().await.charge_control_end_threshold
)
.ok();
}
if let Ok(power_plugged) = platform1.power.get_online() {
if platform1.config.lock().await.last_power_plugged != power_plugged {
if !sleeping && platform1.platform.has_throttle_thermal_policy() {
if !sleeping && platform1.platform.has_platform_profile() {
let change_epp =
platform1.config.lock().await.throttle_policy_linked_epp;
platform1.config.lock().await.platform_profile_linked_epp;
platform1
.update_policy_ac_or_bat(power_plugged > 0, change_epp)
.await;
@@ -977,17 +619,6 @@ impl CtrlTask for CtrlPlatform {
async move {
info!("RogPlatform reloading panel_od");
let lock = platform2.config.lock().await;
if !shutting_down && platform2.platform.has_panel_od() {
platform2
.platform
.set_panel_od(lock.panel_od)
.map_err(|err| {
warn!("CtrlCharge: panel_od {}", err);
err
})
.ok();
}
if shutting_down
&& platform2.power.has_charge_control_end_threshold()
&& lock.base_charge_control_end_threshold > 0
@@ -996,7 +627,7 @@ impl CtrlTask for CtrlPlatform {
platform2
.power
.set_charge_control_end_threshold(
lock.base_charge_control_end_threshold,
lock.base_charge_control_end_threshold
)
.map_err(|err| {
warn!("CtrlCharge: charge_control_end_threshold {}", err);
@@ -1014,8 +645,8 @@ impl CtrlTask for CtrlPlatform {
let platform3 = platform3.clone();
// power change
async move {
if platform3.platform.has_throttle_thermal_policy() {
let change_epp = platform3.config.lock().await.throttle_policy_linked_epp;
if platform3.platform.has_platform_profile() {
let change_epp = platform3.config.lock().await.platform_profile_linked_epp;
platform3
.update_policy_ac_or_bat(power_plugged, change_epp)
.await;
@@ -1025,55 +656,74 @@ impl CtrlTask for CtrlPlatform {
if platform3.power.has_charge_control_end_threshold() && !power_plugged {
platform3.restore_charge_limit().await;
}
if let Ok(profile) = platform3
.platform
.get_platform_profile()
.map(|p| p.into())
.map_err(|e| {
error!("Platform: get_platform_profile error: {e}");
})
{
let attrs = FirmwareAttributes::new();
set_config_or_default(
&attrs,
&mut *platform3.config.lock().await,
power_plugged,
profile
)
.await;
}
}
},
}
)
.await;
// This spawns a new task for every item.
// TODO: find a better way to manage this
self.watch_panel_od(signal_ctxt.clone()).await?;
self.watch_mini_led_mode(signal_ctxt.clone()).await?;
self.watch_charge_control_end_threshold(signal_ctxt.clone())
.await?;
self.watch_dgpu_disable(signal_ctxt.clone()).await?;
self.watch_egpu_enable(signal_ctxt.clone()).await?;
// NOTE: Can't have this as a watch because on a write to it, it reverts back to
// booted-with value as it does not actually change until reboot.
self.watch_gpu_mux_mode(signal_ctxt.clone()).await?;
self.watch_boot_sound(signal_ctxt.clone()).await?;
self.watch_ppt_pl1_spl(signal_ctxt.clone()).await?;
self.watch_ppt_pl2_sppt(signal_ctxt.clone()).await?;
self.watch_ppt_fppt(signal_ctxt.clone()).await?;
self.watch_ppt_apu_sppt(signal_ctxt.clone()).await?;
self.watch_ppt_platform_sppt(signal_ctxt.clone()).await?;
self.watch_nv_dynamic_boost(signal_ctxt.clone()).await?;
self.watch_nv_temp_target(signal_ctxt.clone()).await?;
let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?;
let watch_platform_profile = self.platform.monitor_platform_profile()?;
let ctrl = self.clone();
// Need a copy here, not ideal. But first use in asus_armoury.rs is
// moved to zbus
let attrs = FirmwareAttributes::new();
tokio::spawn(async move {
use futures_lite::StreamExt;
let mut buffer = [0; 32];
if let Ok(mut stream) = watch_throttle_thermal_policy.into_event_stream(&mut buffer) {
if let Ok(mut stream) = watch_platform_profile.into_event_stream(&mut buffer) {
while (stream.next().await).is_some() {
// this blocks
debug!("Platform: watch_throttle_thermal_policy changed");
debug!("Platform: watch_platform_profile changed");
if let Ok(profile) = ctrl
.platform
.get_throttle_thermal_policy()
.map(ThrottlePolicy::from)
.get_platform_profile()
.map(|p| p.into())
.map_err(|e| {
error!("Platform: get_throttle_thermal_policy error: {e}");
error!("Platform: get_platform_profile error: {e}");
})
{
let change_epp = ctrl.config.lock().await.throttle_policy_linked_epp;
let change_epp = ctrl.config.lock().await.platform_profile_linked_epp;
let epp = ctrl.get_config_epp_for_throttle(profile).await;
ctrl.check_and_set_epp(epp, change_epp);
ctrl.platform_profile_changed(&signal_ctxt).await.ok();
let power_plugged = ctrl
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
set_config_or_default(
&attrs,
&mut *ctrl.config.lock().await,
power_plugged == 1,
profile
)
.await;
}
}
}

View File

@@ -4,6 +4,7 @@ use std::sync::Arc;
use ::zbus::export::futures_util::lock::Mutex;
use ::zbus::Connection;
use asusd::asus_armoury::start_attributes_zbus;
use asusd::aura_manager::DeviceManager;
use asusd::config::Config;
use asusd::ctrl_fancurves::CtrlFanCurveZbus;
@@ -11,6 +12,8 @@ use asusd::ctrl_platform::CtrlPlatform;
use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME};
use config_traits::{StdConfig, StdConfigLoad1};
use log::{error, info};
use rog_platform::platform::RogPlatform;
use rog_platform::power::AsusPower;
use zbus::fdo::ObjectManager;
#[tokio::main]
@@ -26,7 +29,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let is_service = match env::var_os("IS_SERVICE") {
Some(val) => val == "1",
None => true,
None => true
};
if !is_service {
@@ -56,23 +59,22 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
// println!("{:?}", supported.supported_functions());
// Start zbus server
let mut connection = Connection::system().await?;
connection
.object_server()
.at("/", ObjectManager)
.await
.unwrap();
let mut server = Connection::system().await?;
server.object_server().at("/", ObjectManager).await.unwrap();
let config = Config::new().load();
let cfg_path = config.file_path();
let config = Arc::new(Mutex::new(config));
// supported.add_to_server(&mut connection).await;
let platform = RogPlatform::new()?; // TODO: maybe needs async mutex?
let power = AsusPower::new()?; // TODO: maybe needs async mutex?
start_attributes_zbus(&server, platform, power, config.clone()).await?;
match CtrlFanCurveZbus::new() {
Ok(ctrl) => {
let sig_ctx = CtrlFanCurveZbus::signal_context(&connection)?;
start_tasks(ctrl, &mut connection, sig_ctx).await?;
let sig_ctx = CtrlFanCurveZbus::signal_context(&server)?;
start_tasks(ctrl, &mut server, sig_ctx).await?;
}
Err(err) => {
error!("FanCurves: {}", err);
@@ -82,24 +84,24 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
match CtrlPlatform::new(
config.clone(),
&cfg_path,
CtrlPlatform::signal_context(&connection)?,
CtrlPlatform::signal_context(&server)?
) {
Ok(ctrl) => {
let sig_ctx = CtrlPlatform::signal_context(&connection)?;
start_tasks(ctrl, &mut connection, sig_ctx).await?;
let sig_ctx = CtrlPlatform::signal_context(&server)?;
start_tasks(ctrl, &mut server, sig_ctx).await?;
}
Err(err) => {
error!("CtrlPlatform: {}", err);
}
}
let _ = DeviceManager::new(connection.clone()).await?;
let _ = DeviceManager::new(server.clone()).await?;
// Request dbus name after finishing initalizing all functions
connection.request_name(DBUS_NAME).await?;
server.request_name(DBUS_NAME).await?;
loop {
// This is just a blocker to idle and ensure the reator reacts
connection.executor().tick().await;
server.executor().tick().await;
}
}

View File

@@ -37,7 +37,7 @@ pub enum RogError {
SystemdUnitAction(String),
SystemdUnitWaitTimeout(String),
Command(String, std::io::Error),
ParseRon(ron::Error),
ParseRon(ron::Error)
}
impl fmt::Display for RogError {
@@ -87,7 +87,7 @@ impl fmt::Display for RogError {
)
}
RogError::Command(func, error) => write!(f, "Command exec error: {}: {}", func, error),
RogError::ParseRon(error) => write!(f, "Parse config error: {}", error),
RogError::ParseRon(error) => write!(f, "Parse config error: {}", error)
}
}
}
@@ -142,3 +142,10 @@ impl From<RogError> for zbus::fdo::Error {
zbus::fdo::Error::Failed(format!("{}", err))
}
}
impl From<RogError> for zbus::Error {
#[inline]
fn from(err: RogError) -> Self {
zbus::Error::Failure(format!("{}", err))
}
}

View File

@@ -6,6 +6,7 @@ pub mod ctrl_fancurves;
/// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode
pub mod ctrl_platform;
pub mod asus_armoury;
pub mod aura_anime;
pub mod aura_laptop;
pub mod aura_manager;
@@ -30,9 +31,11 @@ use zbus::Connection;
use crate::error::RogError;
const CONFIG_PATH_BASE: &str = "/etc/asusd/";
pub static DBUS_NAME: &str = "org.asuslinux.Daemon";
pub static DBUS_PATH: &str = "/org/asuslinux/Daemon";
pub static DBUS_IFACE: &str = "org.asuslinux.Daemon";
pub const ASUS_ZBUS_PATH: &str = "/xyz/ljones";
pub static DBUS_NAME: &str = "xyz.ljones.Asusd";
pub static DBUS_PATH: &str = "/xyz/ljones/Daemon";
pub static DBUS_IFACE: &str = "xyz.ljones.Asusd";
/// This macro adds a function which spawns an `inotify` task on the passed in
/// `Executor`.
@@ -146,7 +149,7 @@ pub trait ReloadAndNotify {
fn reload_and_notify(
&mut self,
signal_context: &SignalEmitter<'static>,
data: Self::Data,
data: Self::Data
) -> impl Future<Output = Result<(), RogError>> + Send;
}
@@ -156,7 +159,7 @@ pub trait ZbusRun {
fn add_to_server_helper(
iface: impl Interface,
path: &str,
server: &mut Connection,
server: &mut Connection
) -> impl Future<Output = ()> + Send {
async move {
server
@@ -185,7 +188,7 @@ pub trait CtrlTask {
/// separate thread.
fn create_tasks(
&self,
signal: SignalEmitter<'static>,
signal: SignalEmitter<'static>
) -> impl Future<Output = Result<(), RogError>> + Send;
// /// Create a timed repeating task
@@ -209,7 +212,7 @@ pub trait CtrlTask {
mut on_prepare_for_sleep: F1,
mut on_prepare_for_shutdown: F2,
mut on_lid_change: F3,
mut on_external_power_change: F4,
mut on_external_power_change: F4
) -> impl Future<Output = ()> + Send
where
F1: FnMut(bool) -> Fut1 + Send + 'static,
@@ -219,7 +222,7 @@ pub trait CtrlTask {
Fut1: Future<Output = ()> + Send,
Fut2: Future<Output = ()> + Send,
Fut3: Future<Output = ()> + Send,
Fut4: Future<Output = ()> + Send,
Fut4: Future<Output = ()> + Send
{
async {
let connection = Connection::system()
@@ -299,10 +302,10 @@ pub trait GetSupported {
pub async fn start_tasks<T>(
mut zbus: T,
connection: &mut Connection,
signal_ctx: SignalEmitter<'static>,
signal_ctx: SignalEmitter<'static>
) -> Result<(), RogError>
where
T: ZbusRun + Reloadable + CtrlTask + Clone,
T: ZbusRun + Reloadable + CtrlTask + Clone
{
let zbus_clone = zbus.clone();

View File

@@ -19,7 +19,7 @@ use serde::Serialize;
/// implemented, the rest are intended to be free methods.
pub trait StdConfig
where
Self: Serialize + DeserializeOwned,
Self: Serialize + DeserializeOwned
{
/// Taking over the standard `new()` to ensure things can be generic
fn new() -> Self;
@@ -203,7 +203,7 @@ macro_rules! std_config_load {
/// new one created
pub trait $trait_name<$($generic),*>
where
Self: $crate::StdConfig +std::fmt::Debug + DeserializeOwned + Serialize,
Self: $crate::StdConfig + DeserializeOwned + Serialize,
$($generic: DeserializeOwned + Into<Self>),*
{
fn load(mut self) -> Self {

View File

@@ -1,11 +0,0 @@
[package]
name = "cpuctl"
license.workspace = true
version.workspace = true
readme.workspace = true
authors.workspace = true
repository.workspace = true
homepage.workspace = true
edition.workspace = true
[dependencies]

View File

@@ -1,14 +0,0 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

View File

@@ -3,24 +3,24 @@
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy group="adm">
<allow send_destination="org.asuslinux.Daemon"/>
<allow receive_sender="org.asuslinux.Daemon"/>
<allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="xyz.ljones.Asusd"/>
</policy>
<policy group="sudo">
<allow send_destination="org.asuslinux.Daemon"/>
<allow receive_sender="org.asuslinux.Daemon"/>
<allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="xyz.ljones.Asusd"/>
</policy>
<policy group="users">
<allow send_destination="org.asuslinux.Daemon"/>
<allow receive_sender="org.asuslinux.Daemon"/>
<allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="xyz.ljones.Asusd"/>
</policy>
<policy group="wheel">
<allow send_destination="org.asuslinux.Daemon"/>
<allow receive_sender="org.asuslinux.Daemon"/>
<allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="xyz.ljones.Asusd"/>
</policy>
<policy user="root">
<allow own="org.asuslinux.Daemon"/>
<allow send_destination="org.asuslinux.Daemon"/>
<allow receive_sender="org.asuslinux.Daemon"/>
<allow own="xyz.ljones.Asusd"/>
<allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="xyz.ljones.Asusd"/>
</policy>
</busconfig>

View File

@@ -13,6 +13,6 @@ ExecStart=/usr/bin/asusd
Restart=on-failure
RestartSec=1
Type=dbus
BusName=org.asuslinux.Daemon
BusName=xyz.ljones.Asusd
SELinuxContext=system_u:system_r:unconfined_t:s0
#SELinuxContext=system_u:object_r:modules_object_t:s0

View File

@@ -135,7 +135,7 @@ impl crate::ZbusAdd for CtrlAnimeZbus {
}
}
#[dbus_interface(name = "org.asuslinux.Daemon")]
#[dbus_interface(name = "xyz.ljones.Asusd")]
impl CtrlAnimeZbus {
async fn <zbus method>() {
let lock = self.inner.lock().await;

View File

@@ -12,7 +12,7 @@ pub struct DMIID {
pub bios_vendor: String,
pub bios_version: String,
pub product_family: String,
pub product_name: String,
pub product_name: String
}
impl DMIID {
@@ -77,7 +77,7 @@ impl DMIID {
product_name: device
.attribute_value("product_name")
.map(|s| s.to_string_lossy().to_string())
.unwrap_or("Unknown".to_string()),
.unwrap_or("Unknown".to_string())
});
}
Err("dmi not found".into())

View File

@@ -30,7 +30,6 @@ log.workspace = true
serde.workspace = true
glam.workspace = true
typeshare.workspace = true
zbus = { workspace = true, optional = true }

View File

@@ -6,7 +6,6 @@ use std::time::{Duration, Instant};
use dmi_id::DMIID;
use log::info;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value};
@@ -23,27 +22,29 @@ const BLOCK_END: usize = 634;
const PANE_LEN: usize = BLOCK_END - BLOCK_START;
/// First packet is for GA401 + GA402
pub const USB_PREFIX1: [u8; 7] = [0x5e, 0xc0, 0x02, 0x01, 0x00, 0x73, 0x02];
pub const USB_PREFIX1: [u8; 7] = [
0x5e, 0xc0, 0x02, 0x01, 0x00, 0x73, 0x02
];
/// Second packet is for GA401 + GA402
pub const USB_PREFIX2: [u8; 7] = [0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02];
pub const USB_PREFIX2: [u8; 7] = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02
];
/// Third packet is for GA402 matrix
pub const USB_PREFIX3: [u8; 7] = [0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02];
pub const USB_PREFIX3: [u8; 7] = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02
];
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[typeshare]
#[derive(Default, Deserialize, PartialEq, Eq, Clone, Copy, Serialize, Debug)]
pub struct Animations {
pub boot: AnimBooting,
pub awake: AnimAwake,
pub sleep: AnimSleeping,
pub shutdown: AnimShutdown,
pub shutdown: AnimShutdown
}
// TODO: move this out
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))]
#[typeshare]
#[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub struct DeviceState {
pub display_enabled: bool,
@@ -53,10 +54,9 @@ pub struct DeviceState {
pub off_when_unplugged: bool,
pub off_when_suspended: bool,
pub off_when_lid_closed: bool,
pub brightness_on_battery: Brightness,
pub brightness_on_battery: Brightness
}
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize, Default)]
pub enum AnimeType {
@@ -64,7 +64,7 @@ pub enum AnimeType {
GA402,
GU604,
#[default]
Unsupported,
Unsupported
}
impl FromStr for AnimeType {
@@ -75,7 +75,7 @@ impl FromStr for AnimeType {
"ga401" | "GA401" => Self::GA401,
"ga402" | "GA402" => Self::GA402,
"gu604" | "GU604" => Self::GU604,
_ => Self::Unsupported,
_ => Self::Unsupported
})
}
}
@@ -98,7 +98,7 @@ impl AnimeType {
pub fn width(&self) -> usize {
match self {
AnimeType::GU604 => 70,
_ => 74,
_ => 74
}
}
@@ -107,7 +107,7 @@ impl AnimeType {
match self {
AnimeType::GA401 => 36,
AnimeType::GU604 => 43,
_ => 39,
_ => 39
}
}
@@ -116,7 +116,7 @@ impl AnimeType {
match self {
AnimeType::GA401 => PANE_LEN * 2,
AnimeType::GU604 => PANE_LEN * 3,
_ => PANE_LEN * 3,
_ => PANE_LEN * 3
}
}
}
@@ -127,7 +127,7 @@ impl AnimeType {
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct AnimeDataBuffer {
data: Vec<u8>,
anime: AnimeType,
anime: AnimeType
}
impl AnimeDataBuffer {
@@ -137,7 +137,7 @@ impl AnimeDataBuffer {
AnimeDataBuffer {
data: vec![0u8; len],
anime,
anime
}
}
@@ -180,7 +180,7 @@ impl TryFrom<AnimeDataBuffer> for AnimePacketType {
let mut buffers = match anime.anime {
AnimeType::GA401 => vec![[0; 640]; 2],
AnimeType::GA402 | AnimeType::GU604 | AnimeType::Unsupported => vec![[0; 640]; 3],
AnimeType::GA402 | AnimeType::GU604 | AnimeType::Unsupported => vec![[0; 640]; 3]
};
for (idx, chunk) in anime.data.as_slice().chunks(PANE_LEN).enumerate() {

View File

@@ -20,7 +20,7 @@ impl AnimeDiagonal {
Self(
anime_type,
vec![vec![0; anime_type.width()]; anime_type.height()],
duration,
duration
)
}
@@ -49,7 +49,7 @@ impl AnimeDiagonal {
path: &Path,
duration: Option<Duration>,
bright: f32,
anime_type: AnimeType,
anime_type: AnimeType
) -> Result<Self> {
let data = std::fs::read(path).map_err(|e| {
error!("Could not open {path:?}: {e:?}");
@@ -86,7 +86,7 @@ impl AnimeDiagonal {
png_pong::PngRaster::Rgba16(ras) => {
Self::pixels_from_16bit(ras, &mut matrix, bright, false);
}
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format),
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format)
};
Ok(matrix)
@@ -96,9 +96,9 @@ impl AnimeDiagonal {
ras: &pix::Raster<P>,
matrix: &mut AnimeDiagonal,
bright: f32,
grey: bool,
grey: bool
) where
P: pix::el::Pixel<Chan = pix::chan::Ch8>,
P: pix::el::Pixel<Chan = pix::chan::Ch8>
{
let width = ras.width();
for (y, row) in ras.pixels().chunks(width as usize).enumerate() {
@@ -121,9 +121,9 @@ impl AnimeDiagonal {
ras: &pix::Raster<P>,
matrix: &mut AnimeDiagonal,
bright: f32,
grey: bool,
grey: bool
) where
P: pix::el::Pixel<Chan = pix::chan::Ch16>,
P: pix::el::Pixel<Chan = pix::chan::Ch16>
{
let width = ras.width();
for (y, row) in ras.pixels().chunks(width as usize).enumerate() {
@@ -146,7 +146,7 @@ impl AnimeDiagonal {
match anime_type {
AnimeType::GA401 => self.to_ga401_packets(),
AnimeType::GU604 => self.to_gu604_packets(),
_ => self.to_ga402_packets(),
_ => self.to_ga402_packets()
}
}
@@ -224,7 +224,7 @@ impl AnimeDiagonal {
x: usize,
y: usize,
start_index: &mut usize,
len: usize,
len: usize
) {
buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len));
*start_index += len;
@@ -307,7 +307,7 @@ impl AnimeDiagonal {
x: usize,
y: usize,
start_index: &mut usize,
len: usize,
len: usize
) {
buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len));
*start_index += len;

View File

@@ -24,7 +24,7 @@ pub enum AnimeError {
DataBufferLength,
PixelGifWidth(usize),
PixelGifHeight(usize),
ParseError(String),
ParseError(String)
}
impl fmt::Display for AnimeError {
@@ -61,7 +61,7 @@ impl fmt::Display for AnimeError {
AnimeError::PixelGifHeight(n) => write!(
f,
"The gif used for pixel-perfect gif is is taller than {n}"
),
)
}
}
}

View File

@@ -16,7 +16,7 @@ pub struct AnimeFrame {
/// the `asusd` daemon over dbus or converted to USB packet with
/// `AnimePacketType::from(buffer)`
data: AnimeDataBuffer,
delay: Duration,
delay: Duration
}
impl AnimeFrame {
@@ -44,7 +44,7 @@ pub enum AnimTime {
/// Run for infinite time
Infinite,
/// Fade in, play for, fade out
Fade(Fade),
Fade(Fade)
}
impl Default for AnimTime {
@@ -59,7 +59,7 @@ impl Default for AnimTime {
pub struct Fade {
fade_in: Duration,
show_for: Option<Duration>,
fade_out: Duration,
fade_out: Duration
}
impl Fade {
@@ -67,7 +67,7 @@ impl Fade {
Self {
fade_in,
show_for,
fade_out,
fade_out
}
}
@@ -100,7 +100,7 @@ impl AnimeGif {
file_name: &Path,
duration: AnimTime,
brightness: f32,
anime_type: AnimeType,
anime_type: AnimeType
) -> Result<Self> {
let mut matrix = AnimeDiagonal::new(anime_type, None);
@@ -142,7 +142,7 @@ impl AnimeGif {
frames.push(AnimeFrame {
data: matrix.into_data_buffer(anime_type)?,
delay: Duration::from_millis(wait as u64),
delay: Duration::from_millis(wait as u64)
});
}
Ok(Self(frames, duration))
@@ -154,7 +154,7 @@ impl AnimeGif {
file_name: &Path,
anime_type: AnimeType,
duration: AnimTime,
brightness: f32,
brightness: f32
) -> Result<Self> {
let image = AnimeDiagonal::from_png(file_name, None, brightness, anime_type)?;
@@ -170,7 +170,7 @@ impl AnimeGif {
let single = AnimeFrame {
data: image.into_data_buffer(anime_type)?,
delay: Duration::from_millis(30),
delay: Duration::from_millis(30)
};
let frames = vec![single; frame_count as usize];
@@ -187,7 +187,7 @@ impl AnimeGif {
translation: Vec2,
duration: AnimTime,
brightness: f32,
anime_type: AnimeType,
anime_type: AnimeType
) -> Result<Self> {
let mut frames = Vec::new();
let mut decoder = gif::DecodeOptions::new();
@@ -211,7 +211,7 @@ impl AnimeGif {
brightness,
pixels,
decoder.width() as u32,
anime_type,
anime_type
)?;
while let Some(frame) = decoder.read_next_frame()? {
@@ -226,7 +226,7 @@ impl AnimeGif {
brightness,
pixels,
width as u32,
anime_type,
anime_type
)?;
}
for (y, row) in frame.buffer.chunks(frame.width as usize * 4).enumerate() {
@@ -239,7 +239,7 @@ impl AnimeGif {
(x + frame.left as usize) + ((y + frame.top as usize) * width as usize);
image.get_mut()[pos] = Pixel {
color: ((px[0] as u32 + px[1] as u32 + px[2] as u32) / 3),
alpha: 1.0,
alpha: 1.0
};
}
}
@@ -247,7 +247,7 @@ impl AnimeGif {
frames.push(AnimeFrame {
data: <AnimeDataBuffer>::try_from(&image)?,
delay: Duration::from_millis(wait as u64),
delay: Duration::from_millis(wait as u64)
});
}
Ok(Self(frames, duration))
@@ -265,7 +265,7 @@ impl AnimeGif {
translation: Vec2,
duration: AnimTime,
brightness: f32,
anime_type: AnimeType,
anime_type: AnimeType
) -> Result<Self> {
let image =
AnimeImage::from_png(file_name, scale, angle, translation, brightness, anime_type)?;
@@ -282,7 +282,7 @@ impl AnimeGif {
let single = AnimeFrame {
data: <AnimeDataBuffer>::try_from(&image)?,
delay: Duration::from_millis(30),
delay: Duration::from_millis(30)
};
let frames = vec![single; frame_count as usize];

View File

@@ -18,7 +18,7 @@ const HEIGHT: usize = 55;
#[derive(Debug, Clone)]
pub struct AnimeGrid {
anime_type: AnimeType,
data: [[u8; WIDTH]; HEIGHT],
data: [[u8; WIDTH]; HEIGHT]
}
impl AnimeGrid {
@@ -26,7 +26,7 @@ impl AnimeGrid {
pub fn new(anime_type: AnimeType) -> Self {
Self {
anime_type,
data: [[0u8; WIDTH]; HEIGHT],
data: [[0u8; WIDTH]; HEIGHT]
}
}
@@ -174,7 +174,7 @@ mod tests {
0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0,
0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0
];
assert_eq!(matrix.data(), &data_cmp);
}

View File

@@ -13,7 +13,7 @@ use crate::AnimeType;
#[derive(Copy, Clone, Debug)]
pub struct Pixel {
pub color: u32,
pub alpha: f32,
pub alpha: f32
}
impl Default for Pixel {
@@ -21,7 +21,7 @@ impl Default for Pixel {
fn default() -> Self {
Pixel {
color: 0,
alpha: 0.0,
alpha: 0.0
}
}
}
@@ -76,7 +76,7 @@ pub struct AnimeImage {
/// The type of the display. The GA401 and GA402 use the same controller and
/// therefore same ID, so the identifier must be by laptop model in
/// `AnimeType`.
anime_type: AnimeType,
anime_type: AnimeType
}
impl AnimeImage {
@@ -88,7 +88,7 @@ impl AnimeImage {
bright: f32,
pixels: Vec<Pixel>,
width: u32,
anime_type: AnimeType,
anime_type: AnimeType
) -> Result<Self> {
if !(0.0..=1.0).contains(&bright) {
return Err(AnimeError::InvalidBrightness(bright));
@@ -102,7 +102,7 @@ impl AnimeImage {
led_pos: Self::generate_image_positioning(anime_type),
img_pixels: pixels,
width,
anime_type,
anime_type
})
}
@@ -121,7 +121,7 @@ impl AnimeImage {
match anime_type {
AnimeType::GA401 => 0.8,
AnimeType::GU604 => 0.78,
_ => 0.77,
_ => 0.77
}
}
@@ -138,7 +138,7 @@ impl AnimeImage {
match anime_type {
AnimeType::GA401 => 0.3,
AnimeType::GU604 => 0.28,
_ => 0.283,
_ => 0.283
}
}
@@ -237,7 +237,7 @@ impl AnimeImage {
AnimeType::GA401 => (33.0 + 0.5) * Self::scale_x(anime_type),
AnimeType::GU604 => (38.0 + 0.5) * Self::scale_x(anime_type),
_ => (35.0 + 0.5) * Self::scale_x(anime_type),
_ => (35.0 + 0.5) * Self::scale_x(anime_type)
}
}
@@ -246,7 +246,7 @@ impl AnimeImage {
match anime_type {
AnimeType::GA401 => 55,
AnimeType::GU604 => 62,
_ => 61,
_ => 61
}
}
@@ -257,7 +257,7 @@ impl AnimeImage {
AnimeType::GA401 => (54.0 + 1.0) * Self::scale_y(anime_type),
AnimeType::GU604 => 62.0 * Self::scale_y(anime_type),
// GA402 may not have dead pixels and require only the physical LED count
_ => 61.0 * Self::scale_y(anime_type),
_ => 61.0 * Self::scale_y(anime_type)
}
}
@@ -267,11 +267,11 @@ impl AnimeImage {
AnimeType::GA401 => match y {
0 | 2 | 4 => 33,
1 | 3 => 35, // Some rows are padded
_ => 36 - y / 2,
_ => 36 - y / 2
},
AnimeType::GU604 => AnimeImage::width(anime_type, y),
// GA402 does not have padding, equivalent to width
_ => AnimeImage::width(anime_type, y),
_ => AnimeImage::width(anime_type, y)
}
}
@@ -321,7 +321,9 @@ impl AnimeImage {
let pos = Vec3::new(led.x(), led.y(), 1.0);
let x0 = led_from_px.mul_vec3(pos + Vec3::new(0.0, -0.5, 0.0));
const GROUP: [f32; 4] = [0.0, 0.5, 1.0, 1.5];
const GROUP: [f32; 4] = [
0.0, 0.5, 1.0, 1.5
];
for u in &GROUP {
for v in &GROUP {
let sample = x0 + *u * du + *v * dv;
@@ -397,7 +399,7 @@ impl AnimeImage {
let led_from_cm = Mat3::from_scale(Vec2::new(
1.0 / AnimeImage::scale_x(self.anime_type),
1.0 / AnimeImage::scale_y(self.anime_type),
1.0 / AnimeImage::scale_y(self.anime_type)
));
let transform =
@@ -420,7 +422,7 @@ impl AnimeImage {
angle: f32,
translation: Vec2,
bright: f32,
anime_type: AnimeType,
anime_type: AnimeType
) -> Result<Self> {
let data = std::fs::read(path).map_err(|e| {
error!("Could not open {path:?}: {e:?}");
@@ -464,7 +466,7 @@ impl AnimeImage {
width = ras.width();
Self::pixels_from_16bit(ras, false)
}
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format),
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format)
};
let mut matrix = AnimeImage::new(
@@ -474,7 +476,7 @@ impl AnimeImage {
bright,
pixels,
width,
anime_type,
anime_type
)?;
matrix.update();
@@ -483,7 +485,7 @@ impl AnimeImage {
fn pixels_from_8bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel>
where
P: pix::el::Pixel<Chan = pix::chan::Ch8>,
P: pix::el::Pixel<Chan = pix::chan::Ch8>
{
ras.pixels()
.iter()
@@ -495,14 +497,14 @@ impl AnimeImage {
+ (<u8>::from(px.two()) / 3) as u32
+ (<u8>::from(px.three()) / 3) as u32
},
alpha: <f32>::from(px.alpha()),
alpha: <f32>::from(px.alpha())
})
.collect()
}
fn pixels_from_16bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel>
where
P: pix::el::Pixel<Chan = pix::chan::Ch16>,
P: pix::el::Pixel<Chan = pix::chan::Ch16>
{
ras.pixels()
.iter()
@@ -514,7 +516,7 @@ impl AnimeImage {
+ ((<u16>::from(px.two()) / 3) >> 8) as u32
+ ((<u16>::from(px.three()) / 3) >> 8) as u32
},
alpha: <f32>::from(px.alpha()),
alpha: <f32>::from(px.alpha())
})
.collect()
}
@@ -651,7 +653,7 @@ mod tests {
Vec2::default(),
AnimTime::Infinite,
1.0,
AnimeType::GA402,
AnimeType::GA402
)
.unwrap();
matrix.frames()[0].frame();

View File

@@ -16,13 +16,13 @@ pub enum ActionLoader {
AsusAnimation {
file: PathBuf,
time: AnimTime,
brightness: f32,
brightness: f32
},
/// Image designed to be pixel perfect using the slanted template
AsusImage {
file: PathBuf,
time: AnimTime,
brightness: f32,
brightness: f32
},
/// Animated gif. If the file is a png a static gif is created using the
/// `time` properties
@@ -32,7 +32,7 @@ pub enum ActionLoader {
angle: f32,
translation: Vec2,
time: AnimTime,
brightness: f32,
brightness: f32
},
Image {
file: PathBuf,
@@ -40,10 +40,10 @@ pub enum ActionLoader {
angle: f32,
translation: Vec2,
time: AnimTime,
brightness: f32,
brightness: f32
},
/// A pause to be used between sequences
Pause(Duration),
Pause(Duration)
}
/// All the possible `AniMe` actions that can be used. The enum is intended to
@@ -64,7 +64,7 @@ pub enum ActionData {
/// Placeholder
TimeDate,
/// Placeholder
Matrix,
Matrix
}
impl ActionData {
@@ -73,17 +73,14 @@ impl ActionData {
ActionLoader::AsusAnimation {
file,
time,
brightness,
brightness
} => ActionData::Animation(AnimeGif::from_diagonal_gif(
file,
*time,
*brightness,
anime_type,
file, *time, *brightness, anime_type
)?),
ActionLoader::AsusImage {
file,
time,
brightness,
brightness
} => match time {
AnimTime::Infinite => {
let image = AnimeDiagonal::from_png(file, None, *brightness, anime_type)?;
@@ -91,11 +88,8 @@ impl ActionData {
ActionData::Image(Box::new(data))
}
_ => ActionData::Animation(AnimeGif::from_diagonal_png(
file,
anime_type,
*time,
*brightness,
)?),
file, anime_type, *time, *brightness
)?)
},
ActionLoader::ImageAnimation {
file,
@@ -103,29 +97,17 @@ impl ActionData {
angle,
translation,
time,
brightness,
brightness
} => {
if let Some(ext) = file.extension() {
if ext.to_string_lossy().to_lowercase() == "png" {
return Ok(ActionData::Animation(AnimeGif::from_png(
file,
*scale,
*angle,
*translation,
*time,
*brightness,
anime_type,
file, *scale, *angle, *translation, *time, *brightness, anime_type
)?));
}
}
ActionData::Animation(AnimeGif::from_gif(
file,
*scale,
*angle,
*translation,
*time,
*brightness,
anime_type,
file, *scale, *angle, *translation, *time, *brightness, anime_type
)?)
}
ActionLoader::Image {
@@ -134,34 +116,23 @@ impl ActionData {
angle,
translation,
brightness,
time,
time
} => {
match time {
AnimTime::Infinite => {
// If no time then create a plain static image
let image = AnimeImage::from_png(
file,
*scale,
*angle,
*translation,
*brightness,
anime_type,
file, *scale, *angle, *translation, *brightness, anime_type
)?;
let data = <AnimeDataBuffer>::try_from(&image)?;
ActionData::Image(Box::new(data))
}
_ => ActionData::Animation(AnimeGif::from_png(
file,
*scale,
*angle,
*translation,
*time,
*brightness,
anime_type,
)?),
file, *scale, *angle, *translation, *time, *brightness, anime_type
)?)
}
}
ActionLoader::Pause(duration) => ActionData::Pause(*duration),
ActionLoader::Pause(duration) => ActionData::Pause(*duration)
};
Ok(a)
}
@@ -200,7 +171,7 @@ impl Sequences {
pub fn iter(&self) -> ActionIterator<'_> {
ActionIterator {
actions: self,
next_idx: 0,
next_idx: 0
}
}
}
@@ -208,7 +179,7 @@ impl Sequences {
/// Iteractor helper for iterating over all the actions in `Sequences`
pub struct ActionIterator<'a> {
actions: &'a Sequences,
next_idx: usize,
next_idx: usize
}
impl<'a> Iterator for ActionIterator<'a> {

View File

@@ -12,7 +12,6 @@ use std::str::FromStr;
use dmi_id::DMIID;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value};
@@ -29,7 +28,6 @@ pub const PROD_ID: u16 = 0x193b;
derive(Type, Value, OwnedValue),
zvariant(signature = "u")
)]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
/// Base LED brightness of the display
pub enum Brightness {
@@ -37,7 +35,7 @@ pub enum Brightness {
Low = 1,
#[default]
Med = 2,
High = 3,
High = 3
}
impl FromStr for Brightness {
@@ -49,7 +47,7 @@ impl FromStr for Brightness {
"Low" | "low" => Brightness::Low,
"Med" | "med" => Brightness::Med,
"High" | "high" => Brightness::High,
_ => Brightness::Med,
_ => Brightness::Med
})
}
}
@@ -60,7 +58,7 @@ impl From<u8> for Brightness {
0 => Brightness::Off,
1 => Brightness::Low,
3 => Brightness::High,
_ => Brightness::Med,
_ => Brightness::Med
}
}
}
@@ -82,12 +80,11 @@ impl From<Brightness> for i32 {
derive(Type, Value, OwnedValue),
zvariant(signature = "s")
)]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimBooting {
#[default]
GlitchConstruction = 0,
StaticEmergence = 1,
StaticEmergence = 1
}
impl FromStr for AnimBooting {
@@ -97,7 +94,7 @@ impl FromStr for AnimBooting {
match s {
"GlitchConstruction" => Ok(Self::GlitchConstruction),
"StaticEmergence" => Ok(Self::StaticEmergence),
_ => Err(AnimeError::ParseError(s.to_owned())),
_ => Err(AnimeError::ParseError(s.to_owned()))
}
}
}
@@ -107,7 +104,7 @@ impl From<i32> for AnimBooting {
match value {
0 => Self::GlitchConstruction,
1 => Self::StaticEmergence,
_ => Self::default(),
_ => Self::default()
}
}
}
@@ -123,12 +120,11 @@ impl From<AnimBooting> for i32 {
derive(Type, Value, OwnedValue),
zvariant(signature = "s")
)]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimAwake {
#[default]
BinaryBannerScroll = 0,
RogLogoGlitch = 1,
RogLogoGlitch = 1
}
impl FromStr for AnimAwake {
@@ -138,7 +134,7 @@ impl FromStr for AnimAwake {
match s {
"BinaryBannerScroll" => Ok(Self::BinaryBannerScroll),
"RogLogoGlitch" => Ok(Self::RogLogoGlitch),
_ => Err(AnimeError::ParseError(s.to_owned())),
_ => Err(AnimeError::ParseError(s.to_owned()))
}
}
}
@@ -148,7 +144,7 @@ impl From<i32> for AnimAwake {
match value {
0 => Self::BinaryBannerScroll,
1 => Self::RogLogoGlitch,
_ => Self::default(),
_ => Self::default()
}
}
}
@@ -164,12 +160,11 @@ impl From<AnimAwake> for i32 {
derive(Type, Value, OwnedValue),
zvariant(signature = "s")
)]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimSleeping {
#[default]
BannerSwipe = 0,
Starfield = 1,
Starfield = 1
}
impl FromStr for AnimSleeping {
@@ -179,7 +174,7 @@ impl FromStr for AnimSleeping {
match s {
"BannerSwipe" => Ok(Self::BannerSwipe),
"Starfield" => Ok(Self::Starfield),
_ => Err(AnimeError::ParseError(s.to_owned())),
_ => Err(AnimeError::ParseError(s.to_owned()))
}
}
}
@@ -189,7 +184,7 @@ impl From<i32> for AnimSleeping {
match value {
0 => Self::BannerSwipe,
1 => Self::Starfield,
_ => Self::default(),
_ => Self::default()
}
}
}
@@ -205,12 +200,11 @@ impl From<AnimSleeping> for i32 {
derive(Type, Value, OwnedValue),
zvariant(signature = "s")
)]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimShutdown {
#[default]
GlitchOut = 0,
SeeYa = 1,
SeeYa = 1
}
impl FromStr for AnimShutdown {
@@ -220,7 +214,7 @@ impl FromStr for AnimShutdown {
match s {
"GlitchOut" => Ok(Self::GlitchOut),
"SeeYa" => Ok(Self::SeeYa),
_ => Err(AnimeError::ParseError(s.to_owned())),
_ => Err(AnimeError::ParseError(s.to_owned()))
}
}
}
@@ -230,7 +224,7 @@ impl From<i32> for AnimShutdown {
match value {
0 => Self::GlitchOut,
1 => Self::SeeYa,
_ => Self::default(),
_ => Self::default()
}
}
}
@@ -332,7 +326,7 @@ pub const fn pkt_set_builtin_animations(
boot: AnimBooting,
awake: AnimAwake,
sleep: AnimSleeping,
shutdown: AnimShutdown,
shutdown: AnimShutdown
) -> [u8; PACKET_SIZE] {
let mut pkt = [0; PACKET_SIZE];
pkt[0] = DEV_PAGE;

View File

@@ -52,7 +52,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -100,7 +100,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let mut matrix = AnimeImage::new(
@@ -110,7 +110,7 @@ mod tests {
0.0,
vec![Pixel::default(); 1000],
100,
AnimeType::GA401,
AnimeType::GA401
)
.unwrap();
matrix.edge_outline();
@@ -175,7 +175,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -223,7 +223,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

View File

@@ -52,7 +52,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt1_check = [
0x5e, 0xc0, 0x2, 0x74, 0x2, 0x73, 0x2, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
@@ -100,7 +100,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt2_check = [
0x5e, 0xc0, 0x2, 0xe7, 0x4, 0x73, 0x2, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00,
@@ -148,7 +148,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let mut matrix = AnimeImage::new(
@@ -158,7 +158,7 @@ mod tests {
0.0,
vec![Pixel::default(); 1000],
100,
AnimeType::GA402,
AnimeType::GA402
)
.unwrap();
matrix.edge_outline();
@@ -218,7 +218,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00,
@@ -266,7 +266,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
@@ -314,7 +314,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
@@ -378,7 +378,7 @@ mod tests {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -426,7 +426,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
@@ -474,7 +474,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

View File

@@ -52,7 +52,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -100,7 +100,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -148,7 +148,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let mut matrix = AnimeImage::new(
@@ -158,7 +158,7 @@ mod tests {
0.0,
vec![Pixel::default(); 1000],
100,
AnimeType::GU604,
AnimeType::GU604
)
.unwrap();
matrix.edge_outline();
@@ -218,7 +218,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -266,7 +266,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -314,7 +314,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

View File

@@ -23,6 +23,5 @@ dmi_id = { path = "../dmi-id" }
# cli and logging
log.workspace = true
typeshare.workspace = true
ron = { version = "*", optional = true }

View File

@@ -179,6 +179,15 @@
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar],
),
(
device_name: "G533QS",
product_id: "18c6",
layout_name: "g533q-per-key",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar],
),
(
device_name: "G533Z",
product_id: "",
@@ -539,6 +548,15 @@
advanced_type: Zoned([SingleZone]),
power_zones: [Keyboard],
),
(
device_name: "GA605W",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse],
basic_zones: [],
advanced_type: Zoned([SingleZone]),
power_zones: [Keyboard],
),
(
device_name: "GL503",
product_id: "",
@@ -656,15 +674,6 @@
advanced_type: Zoned([SingleZone]),
power_zones: [Keyboard],
),
(
device_name: "GA605W",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse],
basic_zones: [],
advanced_type: Zoned([SingleZone]),
power_zones: [Keyboard],
),
(
device_name: "GV301Q",
product_id: "",
@@ -845,4 +854,4 @@
advanced_type: None,
power_zones: [Ally],
),
])
])

View File

@@ -54,7 +54,7 @@ pub struct LedSupportData {
#[serde(default)]
pub advanced_type: AdvancedAuraType,
/// If empty will default to `Keyboard` power zone
pub power_zones: Vec<PowerZones>,
pub power_zones: Vec<PowerZones>
}
impl LedSupportData {
@@ -116,7 +116,7 @@ impl LedSupportFile {
basic_modes: vec![AuraModeNum::Static],
basic_zones: vec![],
advanced_type: AdvancedAuraType::None,
power_zones: vec![PowerZones::Keyboard],
power_zones: vec![PowerZones::Keyboard]
}
}
@@ -191,9 +191,16 @@ mod tests {
product_id: String::new(),
layout_name: "ga401".to_owned(),
basic_modes: vec![AuraModeNum::Static],
basic_zones: vec![AuraZone::Key1, AuraZone::Logo, AuraZone::BarLeft],
basic_zones: vec![
AuraZone::Key1,
AuraZone::Logo,
AuraZone::BarLeft,
],
advanced_type: AdvancedAuraType::Zoned(vec![LedCode::LightbarRight]),
power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow],
power_zones: vec![
PowerZones::Keyboard,
PowerZones::RearGlow,
]
};
assert!(ron::to_string(&led).is_ok());
@@ -214,9 +221,7 @@ mod tests {
tmp_sort.0.sort_by(|a, b| a.product_id.cmp(&b.product_id));
tmp_sort.0.sort_by(|a, b| a.device_name.cmp(&b.device_name));
for model in tmp_sort.0.iter_mut() {
model
.basic_modes
.sort_by(|a, b| (*a as u8).cmp(&(*b as u8)));
model.basic_modes.sort_by_key(|a| *a as u8);
}
if tmp != tmp_sort {
let sorted =

View File

@@ -2,14 +2,12 @@ use std::fmt::Display;
use std::str::FromStr;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value};
use crate::error::Error;
use crate::AURA_LAPTOP_LED_MSG_LEN;
#[typeshare]
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr(
feature = "dbus",
@@ -21,7 +19,7 @@ pub enum LedBrightness {
Low = 1,
#[default]
Med = 2,
High = 3,
High = 3
}
impl LedBrightness {
@@ -30,7 +28,7 @@ impl LedBrightness {
Self::Off => Self::Low,
Self::Low => Self::Med,
Self::Med => Self::High,
Self::High => Self::Off,
Self::High => Self::Off
}
}
@@ -39,7 +37,7 @@ impl LedBrightness {
Self::Off => Self::High,
Self::Low => Self::Off,
Self::Med => Self::Low,
Self::High => Self::Med,
Self::High => Self::Med
}
}
}
@@ -50,7 +48,7 @@ impl From<u8> for LedBrightness {
0 => LedBrightness::Off,
1 => LedBrightness::Low,
3 => LedBrightness::High,
_ => LedBrightness::Med,
_ => LedBrightness::Med
}
}
}
@@ -74,18 +72,17 @@ impl From<i32> for LedBrightness {
1 => LedBrightness::Low,
2 => LedBrightness::Med,
3 => LedBrightness::High,
_ => LedBrightness::Med,
_ => LedBrightness::Med
}
}
}
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Debug, Clone, PartialEq, Eq, Copy, Deserialize, Serialize)]
pub struct Colour {
pub r: u8,
pub g: u8,
pub b: u8,
pub b: u8
}
impl Default for Colour {
@@ -113,14 +110,18 @@ impl From<&[f32; 3]> for Colour {
Self {
r: (255.0 * c[0]) as u8,
g: (255.0 * c[1]) as u8,
b: (255.0 * c[2]) as u8,
b: (255.0 * c[2]) as u8
}
}
}
impl From<Colour> for [f32; 3] {
fn from(c: Colour) -> Self {
[c.r as f32 / 255.0, c.g as f32 / 255.0, c.b as f32 / 255.0]
[
c.r as f32 / 255.0,
c.g as f32 / 255.0,
c.b as f32 / 255.0
]
}
}
@@ -129,18 +130,19 @@ impl From<&[u8; 3]> for Colour {
Self {
r: c[0],
g: c[1],
b: c[2],
b: c[2]
}
}
}
impl From<Colour> for [u8; 3] {
fn from(c: Colour) -> Self {
[c.r, c.g, c.b]
[
c.r, c.g, c.b
]
}
}
#[typeshare]
#[cfg_attr(
feature = "dbus",
derive(Type, Value, OwnedValue),
@@ -151,7 +153,7 @@ pub enum Speed {
Low = 0xe1,
#[default]
Med = 0xeb,
High = 0xf5,
High = 0xf5
}
impl FromStr for Speed {
@@ -163,7 +165,7 @@ impl FromStr for Speed {
"low" => Ok(Speed::Low),
"med" => Ok(Speed::Med),
"high" => Ok(Speed::High),
_ => Err(Error::ParseSpeed),
_ => Err(Error::ParseSpeed)
}
}
}
@@ -173,7 +175,7 @@ impl From<i32> for Speed {
match value {
0 => Self::Low,
2 => Self::High,
_ => Self::Med,
_ => Self::Med
}
}
}
@@ -183,7 +185,7 @@ impl From<Speed> for i32 {
match value {
Speed::Low => 0,
Speed::Med => 1,
Speed::High => 2,
Speed::High => 2
}
}
}
@@ -193,14 +195,13 @@ impl From<Speed> for u8 {
match s {
Speed::Low => 0,
Speed::Med => 1,
Speed::High => 2,
Speed::High => 2
}
}
}
/// Used for Rainbow mode.
///
/// Enum corresponds to the required integer value
#[typeshare]
#[cfg_attr(
feature = "dbus",
derive(Type, Value, OwnedValue),
@@ -212,7 +213,7 @@ pub enum Direction {
Right = 0,
Left = 1,
Up = 2,
Down = 3,
Down = 3
}
impl FromStr for Direction {
@@ -225,7 +226,7 @@ impl FromStr for Direction {
"up" => Ok(Direction::Up),
"down" => Ok(Direction::Down),
"left" => Ok(Direction::Left),
_ => Err(Error::ParseDirection),
_ => Err(Error::ParseDirection)
}
}
}
@@ -236,7 +237,7 @@ impl From<i32> for Direction {
1 => Self::Left,
2 => Self::Up,
3 => Self::Down,
_ => Self::Right,
_ => Self::Right
}
}
}
@@ -248,7 +249,6 @@ impl From<Direction> for i32 {
}
/// Enum of modes that convert to the actual number required by a USB HID packet
#[typeshare]
#[cfg_attr(
feature = "dbus",
derive(Type, Value, OwnedValue),
@@ -270,7 +270,7 @@ pub enum AuraModeNum {
Ripple = 8,
Pulse = 10,
Comet = 11,
Flash = 12,
Flash = 12
}
impl Display for AuraModeNum {
@@ -299,7 +299,7 @@ impl From<&AuraModeNum> for &str {
AuraModeNum::Ripple => "Ripple",
AuraModeNum::Pulse => "Pulse",
AuraModeNum::Comet => "Comet",
AuraModeNum::Flash => "Flash",
AuraModeNum::Flash => "Flash"
}
}
}
@@ -317,7 +317,7 @@ impl From<&str> for AuraModeNum {
"Pulse" => AuraModeNum::Pulse,
"Comet" => AuraModeNum::Comet,
"Flash" => AuraModeNum::Flash,
_ => AuraModeNum::Static,
_ => AuraModeNum::Static
}
}
}
@@ -336,7 +336,7 @@ impl From<u8> for AuraModeNum {
10 => AuraModeNum::Pulse,
11 => AuraModeNum::Comet,
12 => AuraModeNum::Flash,
_ => AuraModeNum::Static,
_ => AuraModeNum::Static
}
}
}
@@ -360,7 +360,6 @@ impl From<AuraEffect> for AuraModeNum {
}
/// Base effects have no zoning, while multizone is 1-4
#[typeshare]
#[cfg_attr(
feature = "dbus",
derive(Type, Value, OwnedValue),
@@ -384,7 +383,7 @@ pub enum AuraZone {
/// The left part of a lightbar (typically on the front of laptop)
BarLeft = 6,
/// The right part of a lightbar
BarRight = 7,
BarRight = 7
}
impl FromStr for AuraZone {
@@ -401,7 +400,7 @@ impl FromStr for AuraZone {
"5" | "logo" => Ok(AuraZone::Logo),
"6" | "lightbar-left" => Ok(AuraZone::BarLeft),
"7" | "lightbar-right" => Ok(AuraZone::BarRight),
_ => Err(Error::ParseSpeed),
_ => Err(Error::ParseSpeed)
}
}
}
@@ -416,7 +415,7 @@ impl From<i32> for AuraZone {
5 => Self::Logo,
6 => Self::BarLeft,
7 => Self::BarRight,
_ => Self::default(),
_ => Self::default()
}
}
}
@@ -432,7 +431,6 @@ impl From<AuraZone> for i32 {
/// ```rust
/// // let bytes: [u8; LED_MSG_LEN] = mode.into();
/// ```
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct AuraEffect {
@@ -447,7 +445,7 @@ pub struct AuraEffect {
/// One of three speeds for modes that support speed (most that animate)
pub speed: Speed,
/// Up, down, left, right. Only Rainbow mode seems to use this
pub direction: Direction,
pub direction: Direction
}
impl AuraEffect {
@@ -483,7 +481,7 @@ impl Default for AuraEffect {
colour1: Colour { r: 166, g: 0, b: 0 },
colour2: Colour { r: 0, g: 0, b: 0 },
speed: Speed::Med,
direction: Direction::Right,
direction: Direction::Right
}
}
}
@@ -543,7 +541,7 @@ impl From<&AuraEffect> for Vec<u8> {
#[cfg(test)]
mod tests {
use crate::{
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, Speed, AURA_LAPTOP_LED_MSG_LEN,
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, Speed, AURA_LAPTOP_LED_MSG_LEN
};
#[test]
@@ -554,18 +552,18 @@ mod tests {
colour1: Colour {
r: 0xff,
g: 0x11,
b: 0xdd,
b: 0xdd
},
colour2: Colour::default(),
speed: Speed::Med,
direction: Direction::Right,
direction: Direction::Right
};
let ar = <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st);
println!("{:02x?}", ar);
let check = [
0x5d, 0xb3, 0x0, 0x0, 0xff, 0x11, 0xdd, 0xeb, 0x0, 0x0, 0xa6, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,
0x0
];
assert_eq!(ar, check);
}
@@ -578,15 +576,15 @@ mod tests {
colour1: Colour {
r: 0xff,
g: 0,
b: 0,
b: 0
},
colour2: Colour { r: 0, g: 0, b: 0 },
speed: Speed::Low,
direction: Direction::Left,
direction: Direction::Left
};
let capture = [
0x5d, 0xb3, 0x01, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0,
0x0, 0x0
];
assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -597,11 +595,11 @@ mod tests {
st.colour1 = Colour {
r: 0xff,
g: 0xff,
b: 0,
b: 0
};
let capture = [
0x5d, 0xb3, 0x02, 0x00, 0xff, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0,
0x0, 0x0
];
assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -612,11 +610,11 @@ mod tests {
st.colour1 = Colour {
r: 0,
g: 0xff,
b: 0xff,
b: 0xff
};
let capture = [
0x5d, 0xb3, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0,
0x0, 0x0
];
assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -627,11 +625,11 @@ mod tests {
st.colour1 = Colour {
r: 0xff,
g: 0x00,
b: 0xff,
b: 0xff
};
let capture = [
0x5d, 0xb3, 0x04, 0x00, 0xff, 0x00, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0,
0x0, 0x0
];
assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -642,11 +640,11 @@ mod tests {
st.colour1 = Colour {
r: 0x2c,
g: 0xff,
b: 0x00,
b: 0x00
};
let capture = [
0x5d, 0xb3, 0x05, 0x00, 0x2c, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0,
0x0, 0x0
];
assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -657,11 +655,11 @@ mod tests {
st.colour1 = Colour {
r: 0xff,
g: 0x00,
b: 0x00,
b: 0x00
};
let capture = [
0x5d, 0xb3, 0x06, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0,
0x0, 0x0
];
assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -672,11 +670,11 @@ mod tests {
st.colour1 = Colour {
r: 0xff,
g: 0x00,
b: 0xcd,
b: 0xcd
};
let capture = [
0x5d, 0xb3, 0x07, 0x00, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0,
0x0, 0x0
];
assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -686,7 +684,7 @@ mod tests {
st.mode = AuraModeNum::RainbowWave;
let capture = [
0x5d, 0xb3, 0x07, 0x03, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0,
0x0, 0x0
];
assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],

View File

@@ -11,7 +11,7 @@ pub struct InputBased {
/// - temperature
/// - fan speed
/// - time
input: Box<dyn InputForEffect>,
input: Box<dyn InputForEffect>
}
impl EffectState for InputBased {

View File

@@ -19,7 +19,7 @@ pub struct Breathe {
#[serde(skip)]
count_flipped: bool,
#[serde(skip)]
use_colour1: bool,
use_colour1: bool
}
impl Breathe {
@@ -31,7 +31,7 @@ impl Breathe {
speed,
colour: colour1,
count_flipped: false,
use_colour1: true,
use_colour1: true
}
}
}

View File

@@ -13,7 +13,7 @@ pub struct DoomFlicker {
#[serde(skip)]
count: u8,
#[serde(skip)]
colour: Colour,
colour: Colour
}
impl DoomFlicker {
@@ -24,7 +24,7 @@ impl DoomFlicker {
count: 4,
max_percentage,
min_percentage,
start_colour: colour,
start_colour: colour
}
}
}
@@ -53,13 +53,13 @@ impl EffectState for DoomFlicker {
let max_light = Colour {
r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8,
g: (start_colour.g as f32 / 100.0 * *max_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8
};
// min light is a percentage of the set colour
let min_light = Colour {
r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8,
g: (start_colour.g as f32 / 100.0 * *min_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8
};
// Convert the 255 to percentage
@@ -96,7 +96,7 @@ pub struct DoomLightFlash {
#[serde(skip)]
count: u8,
#[serde(skip)]
colour: Colour,
colour: Colour
}
impl DoomLightFlash {
@@ -109,7 +109,7 @@ impl DoomLightFlash {
min_percentage,
start_colour: colour,
max_time: 32,
min_time: 7,
min_time: 7
}
}
}
@@ -135,13 +135,13 @@ impl EffectState for DoomLightFlash {
let max_light = Colour {
r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8,
g: (start_colour.g as f32 / 100.0 * *max_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8
};
// min light is a percentage of the set colour
let min_light = Colour {
r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8,
g: (start_colour.g as f32 / 100.0 * *min_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8
};
if *colour == max_light {

View File

@@ -32,7 +32,7 @@ pub const RNDTABLE: [i32; 256] = [
206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95, 28, 139, 123, 98, 125, 196, 15, 70, 194, 253,
54, 14, 109, 226, 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36, 17, 46, 52,
231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106, 197, 242, 98, 43, 39, 175, 254, 145, 190,
84, 118, 222, 187, 136, 120, 163, 236, 249,
84, 118, 222, 187, 136, 120, 163, 236, 249
];
pub fn p_random() -> i32 {
@@ -67,7 +67,7 @@ pub(crate) trait EffectState {
#[derive(Debug, Deserialize, Serialize, Default)]
pub struct AdvancedEffects {
effects: Vec<Effect>,
zoned: bool,
zoned: bool
}
impl AdvancedEffects {
@@ -75,7 +75,7 @@ impl AdvancedEffects {
pub fn new(zoned: bool) -> Self {
Self {
effects: Default::default(),
zoned,
zoned
}
}
@@ -186,7 +186,7 @@ pub enum Effect {
Static(Static),
Breathe(Breathe),
DoomFlicker(DoomFlicker),
DoomLightFlash(DoomLightFlash),
DoomLightFlash(DoomLightFlash)
}
impl Default for Effect {
@@ -207,14 +207,12 @@ mod tests {
fn single_key_next_state_then_create() {
let layout = KeyLayout::default_layout();
let mut seq = AdvancedEffects::new(false);
seq.effects.push(Effect::Static(Static::new(
LedCode::F,
Colour {
seq.effects
.push(Effect::Static(Static::new(LedCode::F, Colour {
r: 255,
g: 127,
b: 0,
},
)));
b: 0
})));
seq.next_state(&layout);
let packets = seq.create_packets();
@@ -234,14 +232,14 @@ mod tests {
Colour {
r: 255,
g: 127,
b: 0,
b: 0
},
Colour {
r: 127,
g: 0,
b: 255,
b: 255
},
Speed::Med,
Speed::Med
)));
let s =
@@ -276,10 +274,10 @@ mod tests {
Colour {
r: 255,
g: 127,
b: 80,
b: 80
},
100,
10,
10
)));
seq.next_state(&layout);

View File

@@ -8,14 +8,14 @@ use crate::{effect_state_impl, Colour};
pub struct Static {
led: LedCode,
/// The starting colour
colour: Colour,
colour: Colour
}
impl Static {
pub fn new(address: LedCode, colour: Colour) -> Self {
Self {
led: address,
colour,
colour
}
}
}

View File

@@ -8,7 +8,7 @@ pub enum Error {
ParseBrightness,
IoPath(String, std::io::Error),
Ron(ron::Error),
RonParse(ron::error::SpannedError),
RonParse(ron::error::SpannedError)
}
impl fmt::Display for Error {
@@ -21,7 +21,7 @@ impl fmt::Display for Error {
Error::ParseBrightness => write!(f, "Could not parse brightness"),
Error::IoPath(path, io) => write!(f, "IO Error: {path}, {io}"),
Error::Ron(e) => write!(f, "RON Parse Error: {e}"),
Error::RonParse(e) => write!(f, "RON Parse Error: {e}"),
Error::RonParse(e) => write!(f, "RON Parse Error: {e}")
}
}
}

View File

@@ -1,6 +1,5 @@
use log::warn;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")]
use zbus::zvariant::Type;
@@ -165,7 +164,7 @@ pub enum LedCode {
/// To be ignored by effects
Spacing,
/// To be ignored by effects
Blocking,
Blocking
}
impl LedCode {
@@ -194,7 +193,6 @@ impl LedCode {
}
/// Represents the per-key raw USB packets
#[typeshare]
pub type AuraLaptopUsbPackets = Vec<Vec<u8>>;
/// A `UsbPackets` contains all data to change the full set of keyboard
@@ -204,7 +202,6 @@ pub type AuraLaptopUsbPackets = Vec<Vec<u8>>;
/// to the keyboard EC. One row controls one group of keys, these keys are not
/// necessarily all on the same row of the keyboard, with some splitting between
/// two rows.
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct LedUsbPackets {
@@ -213,7 +210,7 @@ pub struct LedUsbPackets {
/// Wether or not this packet collection is zoned. The determines which
/// starting bytes are used and what the indexing is for lightbar RGB
/// colours
zoned: bool,
zoned: bool
}
impl Default for LedUsbPackets {
@@ -247,7 +244,7 @@ impl LedUsbPackets {
}
Self {
usb_packets: set,
zoned: false,
zoned: false
}
}
@@ -277,7 +274,7 @@ impl LedUsbPackets {
}
Self {
usb_packets: vec![pkt],
zoned: true,
zoned: true
}
}
@@ -636,7 +633,7 @@ impl From<&LedCode> for &str {
LedCode::ZonedKbLeft => "Left Zone (zone 1)",
LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)",
LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)",
LedCode::ZonedKbRight => "Right Zone (zone 4)",
LedCode::ZonedKbRight => "Right Zone (zone 4)"
}
}
}

View File

@@ -26,12 +26,12 @@ pub enum KeyShape {
pad_left: f32,
pad_right: f32,
pad_top: f32,
pad_bottom: f32,
pad_bottom: f32
},
Blank {
width: f32,
height: f32,
},
height: f32
}
}
impl KeyShape {
@@ -41,7 +41,7 @@ impl KeyShape {
pad_left: f32,
pad_right: f32,
pad_top: f32,
pad_bottom: f32,
pad_bottom: f32
) -> Self {
Self::Led {
width,
@@ -49,7 +49,7 @@ impl KeyShape {
pad_left,
pad_right,
pad_top,
pad_bottom,
pad_bottom
}
}
@@ -66,7 +66,7 @@ impl KeyShape {
pad_left,
pad_right,
pad_top,
pad_bottom,
pad_bottom
} => {
*width *= scale;
*height *= scale;
@@ -97,7 +97,7 @@ pub struct KeyRow {
row: Vec<(LedCode, String)>,
/// The final data structure merged key_shapes and rows
#[serde(skip)]
built_row: Vec<(LedCode, KeyShape)>,
built_row: Vec<(LedCode, KeyShape)>
}
impl KeyRow {
@@ -106,7 +106,7 @@ impl KeyRow {
pad_left,
pad_top,
row,
built_row: Default::default(),
built_row: Default::default()
}
}
@@ -132,7 +132,7 @@ impl KeyRow {
pad_bottom,
..
} => height + pad_top + pad_bottom,
KeyShape::Blank { height, .. } => *height,
KeyShape::Blank { height, .. } => *height
};
if h < height {
@@ -156,7 +156,7 @@ impl KeyRow {
pad_right,
..
} => w += width + pad_left + pad_right,
KeyShape::Blank { width, .. } => w += width,
KeyShape::Blank { width, .. } => w += width
}
}
w
@@ -185,7 +185,7 @@ pub struct KeyLayout {
/// Should be copied from the `LaptopLedData` as laptops may have the same
/// layout, but different EC features.
#[serde(skip)]
advanced_type: AdvancedAuraType,
advanced_type: AdvancedAuraType
}
impl KeyLayout {
@@ -195,7 +195,7 @@ impl KeyLayout {
if buf.is_empty() {
Err(Error::IoPath(
path.to_string_lossy().to_string(),
std::io::ErrorKind::InvalidData.into(),
std::io::ErrorKind::InvalidData.into()
))
} else {
let mut data = ron::from_str::<Self>(&buf)?;
@@ -332,121 +332,97 @@ impl KeyLayout {
advanced_type: AdvancedAuraType::None,
key_shapes: HashMap::from([(
"regular".to_owned(),
KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1),
KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1)
)]),
key_rows: vec![
KeyRow::new(
0.1,
0.1,
vec![
(LedCode::Esc, "regular".to_owned()),
(LedCode::F1, "regular".to_owned()),
(LedCode::F2, "regular".to_owned()),
(LedCode::F3, "regular".to_owned()),
(LedCode::F4, "regular".to_owned()),
// not sure which key to put here
(LedCode::F5, "regular".to_owned()),
(LedCode::F6, "regular".to_owned()),
(LedCode::F7, "regular".to_owned()),
(LedCode::F8, "regular".to_owned()),
(LedCode::F9, "regular".to_owned()),
(LedCode::F10, "regular".to_owned()),
(LedCode::F11, "regular".to_owned()),
(LedCode::F12, "regular".to_owned()),
],
),
KeyRow::new(
0.1,
0.1,
vec![
(LedCode::Tilde, "regular".to_owned()),
(LedCode::N1, "regular".to_owned()),
(LedCode::N2, "regular".to_owned()),
(LedCode::N3, "regular".to_owned()),
(LedCode::N4, "regular".to_owned()),
(LedCode::N5, "regular".to_owned()),
(LedCode::N6, "regular".to_owned()),
(LedCode::N7, "regular".to_owned()),
(LedCode::N8, "regular".to_owned()),
(LedCode::N9, "regular".to_owned()),
(LedCode::N0, "regular".to_owned()),
(LedCode::Hyphen, "regular".to_owned()),
(LedCode::Equals, "regular".to_owned()),
(LedCode::Backspace, "regular".to_owned()),
],
),
KeyRow::new(
0.1,
0.1,
vec![
(LedCode::Tab, "regular".to_owned()),
(LedCode::Q, "regular".to_owned()),
(LedCode::W, "regular".to_owned()),
(LedCode::E, "regular".to_owned()),
(LedCode::R, "regular".to_owned()),
(LedCode::T, "regular".to_owned()),
(LedCode::Y, "regular".to_owned()),
(LedCode::U, "regular".to_owned()),
(LedCode::I, "regular".to_owned()),
(LedCode::O, "regular".to_owned()),
(LedCode::P, "regular".to_owned()),
(LedCode::LBracket, "regular".to_owned()),
(LedCode::RBracket, "regular".to_owned()),
(LedCode::BackSlash, "regular".to_owned()),
],
),
KeyRow::new(
0.1,
0.1,
vec![
(LedCode::Caps, "regular".to_owned()),
(LedCode::A, "regular".to_owned()),
(LedCode::S, "regular".to_owned()),
(LedCode::D, "regular".to_owned()),
(LedCode::F, "regular".to_owned()),
(LedCode::G, "regular".to_owned()),
(LedCode::H, "regular".to_owned()),
(LedCode::J, "regular".to_owned()),
(LedCode::K, "regular".to_owned()),
(LedCode::L, "regular".to_owned()),
(LedCode::SemiColon, "regular".to_owned()),
(LedCode::Quote, "regular".to_owned()),
(LedCode::Return, "regular".to_owned()),
],
),
KeyRow::new(
0.1,
0.1,
vec![
(LedCode::LShift, "regular".to_owned()),
(LedCode::Z, "regular".to_owned()),
(LedCode::X, "regular".to_owned()),
(LedCode::C, "regular".to_owned()),
(LedCode::V, "regular".to_owned()),
(LedCode::B, "regular".to_owned()),
(LedCode::N, "regular".to_owned()),
(LedCode::M, "regular".to_owned()),
(LedCode::Comma, "regular".to_owned()),
(LedCode::Period, "regular".to_owned()),
(LedCode::FwdSlash, "regular".to_owned()),
(LedCode::Rshift, "regular".to_owned()),
],
),
KeyRow::new(
0.1,
0.1,
vec![
(LedCode::LCtrl, "regular".to_owned()),
(LedCode::LFn, "regular".to_owned()),
(LedCode::Meta, "regular".to_owned()),
(LedCode::LAlt, "regular".to_owned()),
(LedCode::Spacebar, "regular".to_owned()),
(LedCode::RAlt, "regular".to_owned()),
(LedCode::PrtSc, "regular".to_owned()),
(LedCode::RCtrl, "regular".to_owned()),
],
),
],
KeyRow::new(0.1, 0.1, vec![
(LedCode::Esc, "regular".to_owned()),
(LedCode::F1, "regular".to_owned()),
(LedCode::F2, "regular".to_owned()),
(LedCode::F3, "regular".to_owned()),
(LedCode::F4, "regular".to_owned()),
// not sure which key to put here
(LedCode::F5, "regular".to_owned()),
(LedCode::F6, "regular".to_owned()),
(LedCode::F7, "regular".to_owned()),
(LedCode::F8, "regular".to_owned()),
(LedCode::F9, "regular".to_owned()),
(LedCode::F10, "regular".to_owned()),
(LedCode::F11, "regular".to_owned()),
(LedCode::F12, "regular".to_owned()),
]),
KeyRow::new(0.1, 0.1, vec![
(LedCode::Tilde, "regular".to_owned()),
(LedCode::N1, "regular".to_owned()),
(LedCode::N2, "regular".to_owned()),
(LedCode::N3, "regular".to_owned()),
(LedCode::N4, "regular".to_owned()),
(LedCode::N5, "regular".to_owned()),
(LedCode::N6, "regular".to_owned()),
(LedCode::N7, "regular".to_owned()),
(LedCode::N8, "regular".to_owned()),
(LedCode::N9, "regular".to_owned()),
(LedCode::N0, "regular".to_owned()),
(LedCode::Hyphen, "regular".to_owned()),
(LedCode::Equals, "regular".to_owned()),
(LedCode::Backspace, "regular".to_owned()),
]),
KeyRow::new(0.1, 0.1, vec![
(LedCode::Tab, "regular".to_owned()),
(LedCode::Q, "regular".to_owned()),
(LedCode::W, "regular".to_owned()),
(LedCode::E, "regular".to_owned()),
(LedCode::R, "regular".to_owned()),
(LedCode::T, "regular".to_owned()),
(LedCode::Y, "regular".to_owned()),
(LedCode::U, "regular".to_owned()),
(LedCode::I, "regular".to_owned()),
(LedCode::O, "regular".to_owned()),
(LedCode::P, "regular".to_owned()),
(LedCode::LBracket, "regular".to_owned()),
(LedCode::RBracket, "regular".to_owned()),
(LedCode::BackSlash, "regular".to_owned()),
]),
KeyRow::new(0.1, 0.1, vec![
(LedCode::Caps, "regular".to_owned()),
(LedCode::A, "regular".to_owned()),
(LedCode::S, "regular".to_owned()),
(LedCode::D, "regular".to_owned()),
(LedCode::F, "regular".to_owned()),
(LedCode::G, "regular".to_owned()),
(LedCode::H, "regular".to_owned()),
(LedCode::J, "regular".to_owned()),
(LedCode::K, "regular".to_owned()),
(LedCode::L, "regular".to_owned()),
(LedCode::SemiColon, "regular".to_owned()),
(LedCode::Quote, "regular".to_owned()),
(LedCode::Return, "regular".to_owned()),
]),
KeyRow::new(0.1, 0.1, vec![
(LedCode::LShift, "regular".to_owned()),
(LedCode::Z, "regular".to_owned()),
(LedCode::X, "regular".to_owned()),
(LedCode::C, "regular".to_owned()),
(LedCode::V, "regular".to_owned()),
(LedCode::B, "regular".to_owned()),
(LedCode::N, "regular".to_owned()),
(LedCode::M, "regular".to_owned()),
(LedCode::Comma, "regular".to_owned()),
(LedCode::Period, "regular".to_owned()),
(LedCode::FwdSlash, "regular".to_owned()),
(LedCode::Rshift, "regular".to_owned()),
]),
KeyRow::new(0.1, 0.1, vec![
(LedCode::LCtrl, "regular".to_owned()),
(LedCode::LFn, "regular".to_owned()),
(LedCode::Meta, "regular".to_owned()),
(LedCode::LAlt, "regular".to_owned()),
(LedCode::Spacebar, "regular".to_owned()),
(LedCode::RAlt, "regular".to_owned()),
(LedCode::PrtSc, "regular".to_owned()),
(LedCode::RCtrl, "regular".to_owned()),
]),
]
}
}
}

View File

@@ -16,5 +16,5 @@ pub enum AdvancedAuraType {
#[default]
None,
Zoned(Vec<LedCode>),
PerKey,
PerKey
}

View File

@@ -5,7 +5,6 @@ use std::ops::{BitAnd, BitOr};
use log::warn;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value};
@@ -16,7 +15,6 @@ use crate::{AuraDeviceType, PowerZones};
/// - 2021+, the struct is a single zone with 4 states
/// - pre-2021, the struct is 1 or 2 zones and 3 states
/// - Tuf, the struct is 1 zone and 3 states
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct AuraPowerState {
@@ -25,7 +23,7 @@ pub struct AuraPowerState {
pub awake: bool,
pub sleep: bool,
/// Ignored for pre-2021 and Tuf
pub shutdown: bool,
pub shutdown: bool
}
impl Default for AuraPowerState {
@@ -36,7 +34,7 @@ impl Default for AuraPowerState {
boot: true,
awake: true,
sleep: true,
shutdown: true,
shutdown: true
}
}
}
@@ -48,13 +46,15 @@ impl AuraPowerState {
boot: true,
awake: true,
sleep: true,
shutdown: true,
shutdown: true
}
}
fn tuf_to_bytes(&self) -> Vec<u8> {
// &cmd, &boot, &awake, &sleep, &keyboard
vec![1, self.boot as u8, self.awake as u8, self.sleep as u8, 1]
vec![
1, self.boot as u8, self.awake as u8, self.sleep as u8, 1,
]
}
/// # Bits for older 0x1866 keyboard model
@@ -106,50 +106,49 @@ impl AuraPowerState {
match self.zone {
PowerZones::Logo => {
self.boot as u32
| (self.awake as u32) << 2
| (self.sleep as u32) << 4
| (self.shutdown as u32) << 6
| ((self.awake as u32) << 2)
| ((self.sleep as u32) << 4)
| ((self.shutdown as u32) << 6)
}
PowerZones::Ally => {
(self.boot as u32)
| (self.awake as u32) << 1
| (self.sleep as u32) << 2
| (self.shutdown as u32) << 3
| ((self.awake as u32) << 1)
| ((self.sleep as u32) << 2)
| ((self.shutdown as u32) << 3)
}
PowerZones::Keyboard => {
(self.boot as u32) << 1
| (self.awake as u32) << 3
| (self.sleep as u32) << 5
| (self.shutdown as u32) << 7
((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)
((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)
((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)
((self.boot as u32) << (23 + 1))
| ((self.awake as u32) << (23 + 2))
| ((self.sleep as u32) << (23 + 3))
| ((self.shutdown as u32) << (23 + 4))
}
PowerZones::None | PowerZones::KeyboardAndLightbar => 0,
PowerZones::None | PowerZones::KeyboardAndLightbar => 0
}
}
}
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct LaptopAuraPower {
pub states: Vec<AuraPowerState>,
pub states: Vec<AuraPowerState>
}
impl LaptopAuraPower {
@@ -207,26 +206,32 @@ impl LaptopAuraPower {
// 3. KeyboardAndLightbar
if support_data.power_zones.contains(&PowerZones::Lightbar) {
Self {
states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)],
states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)]
}
} else {
Self {
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)],
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)]
}
}
}
AuraDeviceType::LaptopKeyboardTuf => Self {
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)],
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)]
},
AuraDeviceType::ScsiExtDisk => todo!(),
AuraDeviceType::AnimeOrSlash => todo!(),
AuraDeviceType::AnimeOrSlash => todo!()
}
}
pub fn to_bytes(&self, aura_type: AuraDeviceType) -> Vec<u8> {
if let Some(stuff) = self.states.first() {
if stuff.zone == PowerZones::Ally {
return vec![0x5d, 0xd1, 0x09, 0x01, stuff.new_to_byte() as u8];
return vec![
0x5d,
0xd1,
0x09,
0x01,
stuff.new_to_byte() as u8,
];
}
}
match aura_type {
@@ -261,7 +266,7 @@ impl LaptopAuraPower {
self.new_to_bytes()
}
AuraDeviceType::ScsiExtDisk => todo!("scsi disk not implemented yet"),
AuraDeviceType::AnimeOrSlash => todo!("anime/slash not implemented yet"),
AuraDeviceType::AnimeOrSlash => todo!("anime/slash not implemented yet")
}
}
}
@@ -280,7 +285,7 @@ enum OldAuraPower {
Boot = 0xc31209,
Sleep = 0x300804,
Keyboard = 0x080000,
Lightbar = 0x040500,
Lightbar = 0x040500
}
impl BitOr<OldAuraPower> for OldAuraPower {
@@ -321,26 +326,30 @@ mod test {
#[test]
fn check_0x1866_control_bytes() {
let power = LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Keyboard,
boot: false,
awake: true,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Keyboard,
boot: false,
awake: true,
sleep: false,
shutdown: false
},
]
};
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]);
let power = LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lightbar,
boot: false,
awake: true,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Lightbar,
boot: false,
awake: true,
sleep: false,
shutdown: false
},
]
};
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
@@ -360,16 +369,16 @@ mod test {
boot: true,
awake: true,
sleep: true,
shutdown: false,
shutdown: false
},
AuraPowerState {
zone: PowerZones::Lightbar,
boot: true,
awake: true,
sleep: true,
shutdown: false,
shutdown: false
},
],
]
};
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
@@ -379,184 +388,224 @@ mod test {
#[test]
fn check_0x19b6_control_bytes_binary_rep() {
let boot_logo_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Logo,
boot: true,
awake: false,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Logo,
boot: true,
awake: false,
sleep: false,
shutdown: false
},
]
});
let boot_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Keyboard,
boot: true,
awake: false,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Keyboard,
boot: true,
awake: false,
sleep: false,
shutdown: false
},
]
});
let sleep_logo = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Logo,
boot: false,
awake: false,
sleep: true,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Logo,
boot: false,
awake: false,
sleep: true,
shutdown: false
},
]
});
let sleep_keyb = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Keyboard,
boot: false,
awake: false,
sleep: true,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Keyboard,
boot: false,
awake: false,
sleep: true,
shutdown: false
},
]
});
let awake_logo = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Logo,
boot: false,
awake: true,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Logo,
boot: false,
awake: true,
sleep: false,
shutdown: false
},
]
});
let awake_keyb = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Keyboard,
boot: false,
awake: true,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Keyboard,
boot: false,
awake: true,
sleep: false,
shutdown: false
},
]
});
let shut_logo_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Logo,
boot: false,
awake: false,
sleep: false,
shutdown: true,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Logo,
boot: false,
awake: false,
sleep: false,
shutdown: true
},
]
});
let shut_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Keyboard,
boot: false,
awake: false,
sleep: false,
shutdown: true,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Keyboard,
boot: false,
awake: false,
sleep: false,
shutdown: true
},
]
});
let boot_bar__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lightbar,
boot: true,
awake: false,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Lightbar,
boot: true,
awake: false,
sleep: false,
shutdown: false
},
]
});
let awake_bar_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lightbar,
boot: false,
awake: true,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Lightbar,
boot: false,
awake: true,
sleep: false,
shutdown: false
},
]
});
let sleep_bar_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lightbar,
boot: false,
awake: false,
sleep: true,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Lightbar,
boot: false,
awake: false,
sleep: true,
shutdown: false
},
]
});
let shut_bar__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lightbar,
boot: false,
awake: false,
sleep: false,
shutdown: true,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Lightbar,
boot: false,
awake: false,
sleep: false,
shutdown: true
},
]
});
let boot_lid__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lid,
boot: true,
awake: false,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Lid,
boot: true,
awake: false,
sleep: false,
shutdown: false
},
]
});
let awake_lid_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lid,
boot: false,
awake: true,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Lid,
boot: false,
awake: true,
sleep: false,
shutdown: false
},
]
});
let sleep_lid_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lid,
boot: false,
awake: false,
sleep: true,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Lid,
boot: false,
awake: false,
sleep: true,
shutdown: false
},
]
});
let shut_lid__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lid,
boot: false,
awake: false,
sleep: false,
shutdown: true,
}],
states: vec![
AuraPowerState {
zone: PowerZones::Lid,
boot: false,
awake: false,
sleep: false,
shutdown: true
},
]
});
let boot_rear_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::RearGlow,
boot: true,
awake: false,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::RearGlow,
boot: true,
awake: false,
sleep: false,
shutdown: false
},
]
});
let awake_rear = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::RearGlow,
boot: false,
awake: true,
sleep: false,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::RearGlow,
boot: false,
awake: true,
sleep: false,
shutdown: false
},
]
});
let sleep_rear = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::RearGlow,
boot: false,
awake: false,
sleep: true,
shutdown: false,
}],
states: vec![
AuraPowerState {
zone: PowerZones::RearGlow,
boot: false,
awake: false,
sleep: true,
shutdown: false
},
]
});
let shut_rear_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::RearGlow,
boot: false,
awake: false,
sleep: false,
shutdown: true,
}],
states: vec![
AuraPowerState {
zone: PowerZones::RearGlow,
boot: false,
awake: false,
sleep: false,
shutdown: true
},
]
});
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
@@ -606,7 +655,7 @@ mod test {
zone: PowerZones::RearGlow,
..Default::default()
},
],
]
});
assert_eq!(byte1, "11111111, 00011110, 00001111, 00001111");
}

View File

@@ -6,7 +6,6 @@
use std::fmt::Debug;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value};
@@ -30,41 +29,42 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const RED: Colour = Colour {
r: 0xff,
g: 0x00,
b: 0x00,
b: 0x00
};
pub const GREEN: Colour = Colour {
r: 0x00,
g: 0xff,
b: 0x00,
b: 0x00
};
pub const BLUE: Colour = Colour {
r: 0x00,
g: 0x00,
b: 0xff,
b: 0xff
};
pub const VIOLET: Colour = Colour {
r: 0x9b,
g: 0x26,
b: 0xb6,
b: 0xb6
};
pub const TEAL: Colour = Colour {
r: 0x00,
g: 0x7c,
b: 0x80,
b: 0x80
};
pub const YELLOW: Colour = Colour {
r: 0xff,
g: 0xef,
b: 0x00,
b: 0x00
};
pub const ORANGE: Colour = Colour {
r: 0xff,
g: 0xa4,
b: 0x00,
b: 0x00
};
pub const GRADIENT: [Colour; 7] = [RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE];
pub const GRADIENT: [Colour; 7] = [
RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE
];
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AuraDeviceType {
@@ -76,7 +76,7 @@ pub enum AuraDeviceType {
ScsiExtDisk = 3,
Ally = 4,
AnimeOrSlash = 5,
Unknown = 255,
Unknown = 255
}
impl AuraDeviceType {
@@ -110,13 +110,12 @@ impl From<&str> for AuraDeviceType {
"1abe" | "1b4c" => Self::Ally,
"19b3" | "193b" => Self::AnimeOrSlash,
"19b6" => Self::LaptopKeyboard2021,
_ => Self::Unknown,
_ => Self::Unknown
}
}
}
/// The powerr zones this laptop supports
#[typeshare]
#[cfg_attr(
feature = "dbus",
derive(Type, Value, OwnedValue),
@@ -139,5 +138,5 @@ pub enum PowerZones {
KeyboardAndLightbar = 5,
/// Ally specific for creating correct packet
Ally = 6,
None = 255,
None = 255
}

View File

@@ -1,4 +1,7 @@
// Only these two packets must be 17 bytes
pub const AURA_LAPTOP_LED_APPLY: [u8; 17] =
[0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
pub const AURA_LAPTOP_LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
pub const AURA_LAPTOP_LED_APPLY: [u8; 17] = [
0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
];
pub const AURA_LAPTOP_LED_SET: [u8; 17] = [
0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
];

View File

@@ -20,7 +20,7 @@ fn main() {
CompilerConfiguration::new()
// .embed_resources(EmbedResourcesKind::EmbedFiles)
.with_include_paths(vec![include])
.with_style("fluent-dark".into()),
.with_style("fluent".into())
)
.unwrap();
}

View File

@@ -23,5 +23,5 @@ pub struct CliStart {
help = "put ROGCC in layout viewing mode - this is helpful for finding existing layouts \
that might match your laptop"
)]
pub layout_viewing: bool,
pub layout_viewing: bool
}

View File

@@ -21,7 +21,7 @@ pub struct Config {
pub fullscreen_width: u32,
pub fullscreen_height: u32,
// This field must be last
pub notifications: EnabledNotifications,
pub notifications: EnabledNotifications
}
impl Default for Config {
@@ -36,7 +36,7 @@ impl Default for Config {
fullscreen_height: 1080,
notifications: EnabledNotifications::default(),
ac_command: String::new(),
bat_command: String::new(),
bat_command: String::new()
}
}
}
@@ -77,7 +77,7 @@ pub struct Config461 {
pub enable_dgpu_notifications: bool,
pub dark_mode: bool,
// This field must be last
pub enabled_notifications: EnabledNotifications,
pub enabled_notifications: EnabledNotifications
}
impl From<Config461> for Config {
@@ -92,7 +92,7 @@ impl From<Config461> for Config {
start_fullscreen: false,
fullscreen_width: 1920,
fullscreen_height: 1080,
notifications: c.enabled_notifications,
notifications: c.enabled_notifications
}
}
}

View File

@@ -9,7 +9,7 @@ pub enum Error {
ConfigLockFail,
XdgVars,
Zbus(zbus::Error),
Notification(notify_rust::error::Error),
Notification(notify_rust::error::Error)
}
impl fmt::Display for Error {
@@ -21,7 +21,7 @@ impl fmt::Display for Error {
Error::ConfigLockFail => write!(f, "Failed to lock user config"),
Error::XdgVars => write!(f, "XDG environment vars appear unset"),
Error::Zbus(err) => write!(f, "Error: {}", err),
Error::Notification(err) => write!(f, "Notification Error: {}", err),
Error::Notification(err) => write!(f, "Notification Error: {}", err)
}
}
}

View File

@@ -15,7 +15,7 @@ pub mod notify;
pub mod tray;
pub mod types;
pub mod ui;
pub mod zbus;
pub mod zbus_proxies;
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png";
@@ -38,5 +38,5 @@ pub enum Page {
System,
AuraEffects,
AnimeMatrix,
FanCurves,
FanCurves
}

View File

@@ -1,4 +1,3 @@
use std::borrow::BorrowMut;
use std::env::args;
use std::path::{Path, PathBuf};
use std::process::exit;
@@ -17,8 +16,8 @@ use rog_control_center::notify::start_notifications;
use rog_control_center::slint::ComponentHandle;
use rog_control_center::tray::init_tray;
use rog_control_center::ui::setup_window;
use rog_control_center::zbus::{
AppState, ROGCCZbus, ROGCCZbusProxyBlocking, ZBUS_IFACE, ZBUS_PATH,
use rog_control_center::zbus_proxies::{
AppState, ROGCCZbus, ROGCCZbusProxyBlocking, ZBUS_IFACE, ZBUS_PATH
};
use rog_control_center::{print_versions, MainWindow};
use tokio::runtime::Runtime;
@@ -118,11 +117,6 @@ async fn main() -> Result<()> {
config.startup_in_background = false;
}
if config.startup_in_background {
config.run_in_background = true;
}
config.write();
let enable_tray_icon = config.enable_tray_icon;
let startup_in_background = config.startup_in_background;
let config = Arc::new(Mutex::new(config));
@@ -159,11 +153,12 @@ async fn main() -> Result<()> {
state = *lock;
}
// This sleep is required to give the event loop time to react
sleep(Duration::from_millis(300));
if state == AppState::MainWindowShouldOpen {
if let Ok(mut lock) = app_state.lock() {
*lock = AppState::MainWindowOpen;
}
sleep(Duration::from_millis(50));
let config_copy = config.clone();
let app_state_copy = app_state.clone();
@@ -203,18 +198,7 @@ async fn main() -> Result<()> {
exit(0);
}
}
slint::invoke_from_event_loop(move || {
UI.with(|ui| {
let mut ui = ui.take();
if let Some(ui) = ui.borrow_mut() {
ui.window().hide().unwrap();
}
});
})
.unwrap();
}
sleep(Duration::from_millis(300));
}
});
@@ -223,42 +207,6 @@ async fn main() -> Result<()> {
Ok(())
}
// /// Bah.. the icon dosn't work on wayland anyway, but we'll leave it in for
// now. fn load_icon() -> IconData {
// let path = PathBuf::from(APP_ICON_PATH);
// let mut rgba = Vec::new();
// let mut height = 512;
// let mut width = 512;
// if path.exists() {
// if let Ok(data) = std::fs::read(path)
// .map_err(|e| error!("Error reading app icon: {e:?}"))
// .map_err(|e| error!("Error opening app icon: {e:?}"))
// {
// let data = std::io::Cursor::new(data);
// let decoder = png_pong::Decoder::new(data).unwrap().into_steps();
// let png_pong::Step { raster, delay: _ } =
// decoder.last().unwrap().unwrap();
// if let png_pong::PngRaster::Rgba8(ras) = raster {
// rgba = ras.as_u8_slice().to_vec();
// width = ras.width();
// height = ras.height();
// info!("Loaded app icon. Not actually supported in Wayland
// yet"); }
// }
// } else {
// error!("Missing {APP_ICON_PATH}");
// }
// IconData {
// height,
// width,
// rgba
//
//
// / }
// }
fn do_cli_help(parsed: &CliStart) -> bool {
if parsed.help {
println!("{}", CliStart::usage());

View File

@@ -5,7 +5,7 @@ use rog_aura::{AuraEffect, AuraModeNum, AuraZone};
use rog_platform::platform::GpuMode;
use rog_platform::supported::{
AdvancedAura, AnimeSupportedFunctions, ChargeSupportedFunctions, LedSupportedFunctions,
PlatformProfileFunctions, RogBiosSupportedFunctions, SupportedFunctions,
PlatformProfileFunctions, RogBiosSupportedFunctions, SupportedFunctions
};
use rog_profiles::fan_curve_set::{CurveData, FanCurveSet};
use supergfxctl::pci_device::{GfxMode, GfxPower};
@@ -16,7 +16,7 @@ const NOPE: &str = "";
#[derive(Default)]
pub struct DaemonProxyBlocking<'a> {
_phantom: &'a str,
_phantom: &'a str
}
impl<'a> DaemonProxyBlocking<'a> {
@@ -35,7 +35,7 @@ impl<'a> DaemonProxyBlocking<'a> {
#[derive(Default)]
pub struct RogDbusClientBlocking<'a> {
_phantom: &'a str,
_phantom: &'a str
}
impl<'a> RogDbusClientBlocking<'a> {
@@ -125,10 +125,18 @@ impl Profile {
pub fn fan_curve_data(&self, _p: rog_profiles::Profile) -> Result<FanCurveSet> {
let mut curve = FanCurveSet::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];
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
];
Ok(curve)
}
@@ -196,7 +204,7 @@ impl Led {
AuraDevRog2::AwakeKeyb,
AuraDevRog2::SleepLogo,
AuraDevRog2::AwakeLogo,
],
]
})
}
@@ -234,11 +242,11 @@ impl Supported {
Ok(SupportedFunctions {
anime_ctrl: AnimeSupportedFunctions(true),
charge_ctrl: ChargeSupportedFunctions {
charge_level_set: true,
charge_level_set: true
},
platform_profile: PlatformProfileFunctions {
platform_profile: true,
fan_curves: true,
fan_curves: true
},
keyboard_led: LedSupportedFunctions {
dev_id: AuraDevice::X19b6,
@@ -259,7 +267,7 @@ impl Supported {
AuraZone::BarRight,
AuraZone::Logo,
],
advanced_type: AdvancedAura::PerKey,
advanced_type: AdvancedAura::PerKey
},
rog_bios_ctrl: RogBiosSupportedFunctions {
post_sound: true,
@@ -267,8 +275,8 @@ impl Supported {
panel_overdrive: true,
dgpu_disable: true,
mini_led_mode: true,
egpu_enable: true,
},
egpu_enable: true
}
})
}
}

View File

@@ -11,7 +11,6 @@ use std::time::Duration;
use log::{debug, error, info, warn};
use notify_rust::{Hint, Notification, Timeout, Urgency};
use rog_dbus::zbus_platform::PlatformProxy;
use rog_platform::platform::GpuMode;
use rog_platform::power::AsusPower;
use serde::{Deserialize, Serialize};
@@ -32,7 +31,7 @@ const NOTIF_HEADER: &str = "ROG Control";
pub struct EnabledNotifications {
pub enabled: bool,
pub receive_notify_gfx: bool,
pub receive_notify_gfx_status: bool,
pub receive_notify_gfx_status: bool
}
impl Default for EnabledNotifications {
@@ -40,7 +39,7 @@ impl Default for EnabledNotifications {
Self {
enabled: true,
receive_notify_gfx: true,
receive_notify_gfx_status: true,
receive_notify_gfx_status: true
}
}
}
@@ -93,7 +92,7 @@ fn start_dpu_status_mon(config: Arc<Mutex<Config>>) {
pub fn start_notifications(
config: Arc<Mutex<Config>>,
rt: &Runtime,
rt: &Runtime
) -> Result<Vec<JoinHandle<()>>> {
// Setup the AC/BAT commands that will run on power status change
let config_copy = config.clone();
@@ -154,39 +153,41 @@ pub fn start_notifications(
};
// GPU MUX Mode notif
let enabled_notifications_copy = config.clone();
tokio::spawn(async move {
let conn = zbus::Connection::system().await.map_err(|e| {
error!("zbus signal: receive_notify_gpu_mux_mode: {e}");
e
})?;
let proxy = PlatformProxy::new(&conn).await.map_err(|e| {
error!("zbus signal: receive_notify_gpu_mux_mode: {e}");
e
})?;
// TODO: need to get armoury attrs and iter to find
// let enabled_notifications_copy = config.clone();
// tokio::spawn(async move {
// let conn = zbus::Connection::system().await.map_err(|e| {
// error!("zbus signal: receive_notify_gpu_mux_mode: {e}");
// e
// })?;
// let proxy = PlatformProxy::new(&conn).await.map_err(|e| {
// error!("zbus signal: receive_notify_gpu_mux_mode: {e}");
// e
// })?;
let mut actual_mux_mode = GpuMode::Error;
if let Ok(mode) = proxy.gpu_mux_mode().await {
actual_mux_mode = GpuMode::from(mode);
}
// let mut actual_mux_mode = GpuMode::Error;
// if let Ok(mode) = proxy.gpu_mux_mode().await {
// actual_mux_mode = GpuMode::from(mode);
// }
info!("Started zbus signal thread: receive_notify_gpu_mux_mode");
while let Some(e) = proxy.receive_gpu_mux_mode_changed().await.next().await {
if let Ok(config) = enabled_notifications_copy.lock() {
if !config.notifications.enabled || !config.notifications.receive_notify_gfx {
continue;
}
}
if let Ok(out) = e.get().await {
let mode = GpuMode::from(out);
if mode == actual_mux_mode {
continue;
}
do_mux_notification("Reboot required. BIOS GPU MUX mode set to", &mode).ok();
}
}
Ok::<(), zbus::Error>(())
});
// info!("Started zbus signal thread: receive_notify_gpu_mux_mode");
// while let Some(e) =
// proxy.receive_gpu_mux_mode_changed().await.next().await { if let
// Ok(config) = enabled_notifications_copy.lock() { if
// !config.notifications.enabled || !config.notifications.receive_notify_gfx {
// continue;
// }
// }
// if let Ok(out) = e.get().await {
// let mode = GpuMode::from(out);
// if mode == actual_mux_mode {
// continue;
// }
// do_mux_notification("Reboot required. BIOS GPU MUX mode set to",
// &mode).ok(); }
// }
// Ok::<(), zbus::Error>(())
// });
let enabled_notifications_copy = config.clone();
// GPU Mode change/action notif
@@ -213,7 +214,7 @@ pub fn start_notifications(
supergfxctl::actions::UserActionRequired::Reboot => {
do_mux_notification("Graphics mode change requires reboot", &mode)
}
_ => do_gfx_action_notif(<&str>::from(action), *action, mode),
_ => do_gfx_action_notif(<&str>::from(action), *action, mode)
}
.map_err(|e| {
error!("zbus signal: do_gfx_action_notif: {e}");
@@ -265,13 +266,13 @@ fn convert_gfx_mode(gfx: GfxMode) -> GpuMode {
GfxMode::Vfio => GpuMode::Vfio,
GfxMode::AsusEgpu => GpuMode::Egpu,
GfxMode::AsusMuxDgpu => GpuMode::Ultimate,
GfxMode::None => GpuMode::Error,
GfxMode::None => GpuMode::Error
}
}
fn base_notification<T>(message: &str, data: &T) -> Notification
where
T: Display,
T: Display
{
let mut notif = Notification::new();
notif
@@ -289,7 +290,7 @@ fn do_gpu_status_notif(message: &str, data: &GfxPower) -> Notification {
GfxPower::Off => "asus_notif_green",
GfxPower::AsusDisabled => "asus_notif_white",
GfxPower::AsusMuxDiscreet | GfxPower::Active => "asus_notif_red",
GfxPower::Unknown => "gpu-integrated",
GfxPower::Unknown => "gpu-integrated"
};
notif.icon(icon);
notif
@@ -329,7 +330,9 @@ fn do_gfx_action_notif(message: &str, action: GfxUserAction, mode: GpuMode) -> R
handle.wait_for_action(|id| {
if id == "gfx-mode-session-action" {
let mut cmd = Command::new("qdbus");
cmd.args(["org.kde.ksmserver", "/KSMServer", "logout", "1", "0", "0"]);
cmd.args([
"org.kde.ksmserver", "/KSMServer", "logout", "1", "0", "0"
]);
cmd.spawn().ok();
} else if id == "__closed" {
// TODO: cancel the switching
@@ -371,7 +374,9 @@ fn do_mux_notification(message: &str, m: &GpuMode) -> Result<()> {
handle.wait_for_action(|id| {
if id == "gfx-mode-session-action" {
let mut cmd = Command::new("qdbus");
cmd.args(["org.kde.ksmserver", "/KSMServer", "logout", "1", "1", "0"]);
cmd.args([
"org.kde.ksmserver", "/KSMServer", "logout", "1", "1", "0"
]);
cmd.spawn().ok();
} else if id == "__closed" {
// TODO: cancel the switching

View File

@@ -14,7 +14,7 @@ use supergfxctl::zbus_proxy::DaemonProxy as GfxProxy;
use versions::Versioning;
use crate::config::Config;
use crate::zbus::{AppState, ROGCCZbusProxyBlocking};
use crate::zbus_proxies::{AppState, ROGCCZbusProxyBlocking};
const TRAY_LABEL: &str = "ROG Control Center";
const TRAY_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/";
@@ -24,7 +24,7 @@ struct Icons {
rog_red: Icon,
rog_green: Icon,
rog_white: Icon,
gpu_integrated: Icon,
gpu_integrated: Icon
}
static ICONS: OnceLock<Icons> = OnceLock::new();
@@ -48,14 +48,14 @@ fn read_icon(file: &Path) -> Icon {
Icon {
width: width as i32,
height: height as i32,
data: img.into_raw(),
data: img.into_raw()
}
}
struct AsusTray {
current_title: String,
current_icon: Icon,
proxy: ROGCCZbusProxyBlocking<'static>,
proxy: ROGCCZbusProxyBlocking<'static>
}
impl ksni::Tray for AsusTray {
@@ -103,7 +103,7 @@ async fn set_tray_icon_and_tip(
mode: GfxMode,
power: GfxPower,
tray: &mut Handle<AsusTray>,
supergfx_active: bool,
supergfx_active: bool
) {
if let Some(icons) = ICONS.get() {
let icon = match power {
@@ -127,7 +127,6 @@ async fn set_tray_icon_and_tip(
};
tray.update(|tray: &mut AsusTray| {
dbg!(power);
tray.current_icon = icon;
tray.current_title = format!(
"ROG: gpu mode = {mode:?}, gpu power =
@@ -160,21 +159,23 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
let rog_red = read_icon(&PathBuf::from("asus_notif_red.png"));
let tray = AsusTray {
let tray_init = AsusTray {
current_title: TRAY_LABEL.to_string(),
current_icon: rog_red.clone(),
proxy,
proxy
};
let mut tray = tray
.spawn_without_dbus_name()
.await
.map_err(|e| {
// TODO: return an error to the UI
let mut tray;
match tray_init.spawn_without_dbus_name().await {
Ok(t) => tray = t,
Err(e) => {
log::error!(
"Tray unable to be initialised: {e:?}. Do you have a system tray enabled?"
)
})
.unwrap();
);
return;
}
}
info!("Tray started");
let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png"));
@@ -186,7 +187,7 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
rog_red: rog_red.clone(),
rog_green,
rog_white,
gpu_integrated,
gpu_integrated
});
let mut has_supergfx = false;
@@ -207,7 +208,7 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
}
}
}
Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}"),
Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}")
}
info!("Started ROGTray");

View File

@@ -1,6 +1,6 @@
use crate::slint_generatedMainWindow::{
AuraDevType as SlintDeviceType, AuraPowerState as SlintAuraPowerState,
LaptopAuraPower as SlintLaptopAuraPower,
LaptopAuraPower as SlintLaptopAuraPower
};
impl From<rog_aura::AuraEffect> for crate::slint_generatedMainWindow::AuraEffect {
@@ -10,20 +10,20 @@ impl From<rog_aura::AuraEffect> for crate::slint_generatedMainWindow::AuraEffect
red: m.colour1.r,
green: m.colour1.g,
blue: m.colour1.b,
alpha: 255,
alpha: 255
}
.into(),
colour2: RgbaColor {
red: m.colour2.r,
green: m.colour2.g,
blue: m.colour2.b,
alpha: 255,
alpha: 255
}
.into(),
direction: m.direction.into(),
mode: m.mode.into(),
speed: m.speed.into(),
zone: m.zone.into(),
zone: m.zone.into()
}
}
}
@@ -36,17 +36,17 @@ impl From<crate::slint_generatedMainWindow::AuraEffect> for rog_aura::AuraEffect
colour1: rog_aura::Colour {
r: c1.red,
g: c1.green,
b: c1.blue,
b: c1.blue
},
colour2: rog_aura::Colour {
r: c2.red,
g: c2.green,
b: c2.blue,
b: c2.blue
},
direction: m.direction.into(),
mode: m.mode.into(),
speed: m.speed.into(),
zone: m.zone.into(),
zone: m.zone.into()
}
}
}
@@ -66,7 +66,7 @@ impl From<PowerZones> for SlintPowerZones {
PowerZones::RearGlow => SlintPowerZones::RearGlow,
PowerZones::KeyboardAndLightbar => SlintPowerZones::KeyboardAndLightbar,
PowerZones::Ally => SlintPowerZones::Ally,
PowerZones::None => SlintPowerZones::Keyboard,
PowerZones::None => SlintPowerZones::Keyboard
}
}
}
@@ -80,7 +80,7 @@ impl From<SlintPowerZones> for PowerZones {
SlintPowerZones::Lid => PowerZones::Lid,
SlintPowerZones::RearGlow => PowerZones::RearGlow,
SlintPowerZones::KeyboardAndLightbar => PowerZones::KeyboardAndLightbar,
SlintPowerZones::Ally => PowerZones::Ally,
SlintPowerZones::Ally => PowerZones::Ally
}
}
}
@@ -92,7 +92,7 @@ impl From<SlintAuraPowerState> for AuraPowerState {
boot: value.boot,
awake: value.awake,
sleep: value.sleep,
shutdown: value.shutdown,
shutdown: value.shutdown
}
}
}
@@ -106,7 +106,7 @@ impl From<AuraPowerState> for SlintAuraPowerState {
sleep: value.sleep,
shutdown: value.shutdown,
zone,
zone_name_idx: zone as i32,
zone_name_idx: zone as i32
}
}
}
@@ -120,7 +120,7 @@ impl From<&AuraPowerState> for SlintAuraPowerState {
sleep: value.sleep,
shutdown: value.shutdown,
zone,
zone_name_idx: zone as i32,
zone_name_idx: zone as i32
}
}
}
@@ -140,7 +140,7 @@ impl From<LaptopAuraPower> for SlintLaptopAuraPower {
let converted: Vec<SlintAuraPowerState> =
value.states.iter().map(SlintAuraPowerState::from).collect();
Self {
states: ModelRc::from(converted.as_slice()),
states: ModelRc::from(converted.as_slice())
}
}
}
@@ -154,7 +154,7 @@ impl From<SlintDeviceType> for AuraDeviceType {
SlintDeviceType::ScsiExtDisk => Self::ScsiExtDisk,
SlintDeviceType::Unknown => Self::Unknown,
SlintDeviceType::Ally => Self::Ally,
SlintDeviceType::AnimeOrSlash => Self::AnimeOrSlash,
SlintDeviceType::AnimeOrSlash => Self::AnimeOrSlash
}
}
}
@@ -168,7 +168,7 @@ impl From<AuraDeviceType> for SlintDeviceType {
AuraDeviceType::ScsiExtDisk => SlintDeviceType::ScsiExtDisk,
AuraDeviceType::Unknown => SlintDeviceType::Unknown,
AuraDeviceType::Ally => SlintDeviceType::Ally,
AuraDeviceType::AnimeOrSlash => SlintDeviceType::AnimeOrSlash,
AuraDeviceType::AnimeOrSlash => SlintDeviceType::AnimeOrSlash
}
}
}

View File

@@ -1,24 +1,24 @@
use rog_platform::platform::ThrottlePolicy;
use rog_platform::platform::PlatformProfile;
use rog_profiles::FanCurvePU;
use crate::{FanType, Profile};
impl From<Profile> for ThrottlePolicy {
impl From<Profile> for PlatformProfile {
fn from(value: Profile) -> Self {
match value {
Profile::Balanced => ThrottlePolicy::Balanced,
Profile::Performance => ThrottlePolicy::Performance,
Profile::Quiet => ThrottlePolicy::Quiet,
Profile::Balanced => PlatformProfile::Balanced,
Profile::Performance => PlatformProfile::Performance,
Profile::Quiet => PlatformProfile::Quiet
}
}
}
impl From<ThrottlePolicy> for Profile {
fn from(value: ThrottlePolicy) -> Self {
impl From<PlatformProfile> for Profile {
fn from(value: PlatformProfile) -> Self {
match value {
ThrottlePolicy::Balanced => Profile::Balanced,
ThrottlePolicy::Performance => Profile::Performance,
ThrottlePolicy::Quiet => Profile::Quiet,
PlatformProfile::Balanced => Profile::Balanced,
PlatformProfile::Performance => Profile::Performance,
PlatformProfile::Quiet => Profile::Quiet
}
}
}
@@ -28,7 +28,7 @@ impl From<FanType> for FanCurvePU {
match value {
FanType::CPU => FanCurvePU::CPU,
FanType::Middle => FanCurvePU::MID,
FanType::GPU => FanCurvePU::GPU,
FanType::GPU => FanCurvePU::GPU
}
}
}
@@ -38,7 +38,7 @@ impl From<FanCurvePU> for FanType {
match value {
FanCurvePU::CPU => FanType::CPU,
FanCurvePU::GPU => FanType::GPU,
FanCurvePU::MID => FanType::Middle,
FanCurvePU::MID => FanType::Middle
}
}
}

View File

@@ -16,21 +16,6 @@ use crate::ui::setup_fans::setup_fan_curve_page;
use crate::ui::setup_system::{setup_system_page, setup_system_page_callbacks};
use crate::{AppSettingsPageData, MainWindow};
// This macro expects are consistent naming between proxy calls and slint
// globals
#[macro_export]
macro_rules! set_ui_props_async {
($ui:ident, $proxy:ident, $global:ident, $proxy_fn:ident) => {
if let Ok(value) = $proxy.$proxy_fn().await {
$ui.upgrade_in_event_loop(move |handle| {
concat_idents::concat_idents!(set = set_, $proxy_fn {
handle.global::<$global>().set(value.into());
});
}).ok();
}
};
}
// this macro sets up:
// - a link from UI callback -> dbus proxy property
// - a link from dbus property signal -> UI state
@@ -41,7 +26,7 @@ macro_rules! set_ui_callbacks {
let handle_copy = $handle.as_weak();
let proxy_copy = $proxy.clone();
let data = $handle.global::<$data>();
concat_idents::concat_idents!(on_set = on_set_, $proxy_fn {
concat_idents::concat_idents!(on_set = on_cb_, $proxy_fn {
data.on_set(move |value| {
let proxy_copy = proxy_copy.clone();
let handle_copy = handle_copy.clone();
@@ -82,7 +67,7 @@ pub fn show_toast(
success: SharedString,
fail: SharedString,
handle: Weak<MainWindow>,
result: zbus::Result<()>,
result: zbus::Result<()>
) {
match result {
Ok(_) => {
@@ -92,7 +77,7 @@ pub fn show_toast(
log::warn!("{fail}: {e}");
handle.unwrap().invoke_show_toast(fail)
})
.ok(),
.ok()
};
}
@@ -112,14 +97,14 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
ui.set_sidebar_items_avilable(
[
// Needs to match the order of slint sidebar items
available.contains(&"org.asuslinux.Platform".to_string()),
available.contains(&"org.asuslinux.Aura".to_string()),
available.contains(&"org.asuslinux.Anime".to_string()),
available.contains(&"org.asuslinux.FanCurves".to_string()),
true,
available.contains(&"xyz.ljones.Platform".to_string()),
available.contains(&"xyz.ljones.Aura".to_string()),
available.contains(&"xyz.ljones.Anime".to_string()),
available.contains(&"xyz.ljones.FanCurves".to_string()),
true,
true
]
.into(),
.into()
);
ui.on_exit_app(move || {
@@ -127,17 +112,17 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
});
setup_app_settings_page(&ui, config.clone());
if available.contains(&"org.asuslinux.Platform".to_string()) {
if available.contains(&"xyz.ljones.Platform".to_string()) {
setup_system_page(&ui, config.clone());
setup_system_page_callbacks(&ui, config.clone());
}
if available.contains(&"org.asuslinux.Aura".to_string()) {
if available.contains(&"xyz.ljones.Aura".to_string()) {
setup_aura_page(&ui, config.clone());
}
if available.contains(&"org.asuslinux.Anime".to_string()) {
if available.contains(&"xyz.ljones.Anime".to_string()) {
setup_anime_page(&ui, config.clone());
}
if available.contains(&"org.asuslinux.FanCurves".to_string()) {
if available.contains(&"xyz.ljones.FanCurves".to_string()) {
setup_fan_curve_page(&ui, config);
}
ui

View File

@@ -1,7 +1,8 @@
use std::sync::{Arc, Mutex};
use log::{error, info, warn};
use log::{error, info};
use rog_anime::Animations;
use rog_dbus::find_iface_async;
use rog_dbus::zbus_anime::AnimeProxy;
use slint::ComponentHandle;
@@ -12,124 +13,123 @@ use crate::{set_ui_callbacks, set_ui_props_async, AnimePageData, MainWindow};
pub fn setup_anime_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
let handle = ui.as_weak();
tokio::spawn(async move {
let Ok(conn) = zbus::Connection::system().await.map_err(|e| warn!("{e:}")) else {
return;
};
let Ok(anime) = AnimeProxy::new(&conn).await.map_err(|e| warn!("{e:}")) else {
info!("This device may not have an AniMe. If not then the error can be ignored");
let Ok(animes) = find_iface_async::<AnimeProxy>("xyz.ljones.Anime").await else {
info!("This device appears to have no aura interfaces");
return;
};
set_ui_props_async!(handle, anime, AnimePageData, brightness);
set_ui_props_async!(handle, anime, AnimePageData, builtins_enabled);
set_ui_props_async!(handle, anime, AnimePageData, enable_display);
set_ui_props_async!(handle, anime, AnimePageData, off_when_lid_closed);
set_ui_props_async!(handle, anime, AnimePageData, off_when_suspended);
set_ui_props_async!(handle, anime, AnimePageData, off_when_unplugged);
for anime in animes {
set_ui_props_async!(handle, anime, AnimePageData, brightness);
set_ui_props_async!(handle, anime, AnimePageData, builtins_enabled);
set_ui_props_async!(handle, anime, AnimePageData, enable_display);
set_ui_props_async!(handle, anime, AnimePageData, off_when_lid_closed);
set_ui_props_async!(handle, anime, AnimePageData, off_when_suspended);
set_ui_props_async!(handle, anime, AnimePageData, off_when_unplugged);
let builtins = anime.builtin_animations().await.unwrap_or_default();
handle
.upgrade_in_event_loop(move |handle| {
{
let global = handle.global::<AnimePageData>();
global.set_boot_anim(builtins.boot as i32);
global.set_awake_anim(builtins.awake as i32);
global.set_sleep_anim(builtins.sleep as i32);
global.set_shutdown_anim(builtins.shutdown as i32);
let builtins = anime.builtin_animations().await.unwrap_or_default();
handle
.upgrade_in_event_loop(move |handle| {
{
let global = handle.global::<AnimePageData>();
global.set_boot_anim(builtins.boot as i32);
global.set_awake_anim(builtins.awake as i32);
global.set_sleep_anim(builtins.sleep as i32);
global.set_shutdown_anim(builtins.shutdown as i32);
let handle_copy = handle.as_weak();
let anime_copy = anime.clone();
global.on_set_builtin_animations(move |boot, awake, sleep, shutdown| {
let handle_copy = handle_copy.clone();
let anime_copy = anime_copy.clone();
tokio::spawn(async move {
show_toast(
"Anime builtin animations changed".into(),
"Failed to set Anime builtin animations".into(),
handle_copy,
anime_copy
.set_builtin_animations(Animations {
boot: boot.into(),
awake: awake.into(),
sleep: sleep.into(),
shutdown: shutdown.into(),
})
.await,
);
let handle_copy = handle.as_weak();
let anime_copy = anime.clone();
global.on_cb_builtin_animations(move |boot, awake, sleep, shutdown| {
let handle_copy = handle_copy.clone();
let anime_copy = anime_copy.clone();
tokio::spawn(async move {
show_toast(
"Anime builtin animations changed".into(),
"Failed to set Anime builtin animations".into(),
handle_copy,
anime_copy
.set_builtin_animations(Animations {
boot: boot.into(),
awake: awake.into(),
sleep: sleep.into(),
shutdown: shutdown.into()
})
.await
);
});
});
});
let handle_copy = handle.as_weak();
let anime_copy = anime.clone();
tokio::spawn(async move {
let mut x = anime_copy.receive_builtin_animations_changed().await;
use zbus::export::futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
handle_copy
.upgrade_in_event_loop(move |handle| {
handle
.global::<AnimePageData>()
.set_boot_anim(out.boot.into());
handle
.global::<AnimePageData>()
.set_awake_anim(out.awake.into());
handle
.global::<AnimePageData>()
.set_sleep_anim(out.sleep.into());
handle
.global::<AnimePageData>()
.set_shutdown_anim(out.shutdown.into());
})
.ok();
let handle_copy = handle.as_weak();
let anime_copy = anime.clone();
tokio::spawn(async move {
let mut x = anime_copy.receive_builtin_animations_changed().await;
use zbus::export::futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
handle_copy
.upgrade_in_event_loop(move |handle| {
handle
.global::<AnimePageData>()
.set_boot_anim(out.boot.into());
handle
.global::<AnimePageData>()
.set_awake_anim(out.awake.into());
handle
.global::<AnimePageData>()
.set_sleep_anim(out.sleep.into());
handle
.global::<AnimePageData>()
.set_shutdown_anim(out.shutdown.into());
})
.ok();
}
}
}
});
}
});
}
set_ui_callbacks!(handle,
AnimePageData(.into()),
anime.brightness(.into()),
"Anime LED brightness successfully set to {}",
"Setting Anime LED brightness failed"
);
set_ui_callbacks!(
handle,
AnimePageData(),
anime.builtins_enabled(),
"Keyboard LED mode successfully set to {}",
"Setting keyboard LEDmode failed"
);
set_ui_callbacks!(
handle,
AnimePageData(),
anime.enable_display(),
"Anime display successfully set to {}",
"Setting Anime display failed"
);
set_ui_callbacks!(
handle,
AnimePageData(),
anime.off_when_lid_closed(),
"Anime off_when_lid_closed successfully set to {}",
"Setting Anime off_when_lid_closed failed"
);
set_ui_callbacks!(
handle,
AnimePageData(),
anime.off_when_suspended(),
"Anime off_when_suspended successfully set to {}",
"Setting Anime off_when_suspended failed"
);
set_ui_callbacks!(
handle,
AnimePageData(),
anime.off_when_unplugged(),
"Anime off_when_unplugged successfully set to {}",
"Setting Anime off_when_unplugged failed"
);
})
.map_err(|e| error!("setup_anime_page: upgrade_in_event_loop: {e:?}"))
.ok();
set_ui_callbacks!(handle,
AnimePageData(.into()),
anime.brightness(.into()),
"Anime LED brightness successfully set to {}",
"Setting Anime LED brightness failed"
);
set_ui_callbacks!(
handle,
AnimePageData(),
anime.builtins_enabled(),
"Keyboard LED mode successfully set to {}",
"Setting keyboard LEDmode failed"
);
set_ui_callbacks!(
handle,
AnimePageData(),
anime.enable_display(),
"Anime display successfully set to {}",
"Setting Anime display failed"
);
set_ui_callbacks!(
handle,
AnimePageData(),
anime.off_when_lid_closed(),
"Anime off_when_lid_closed successfully set to {}",
"Setting Anime off_when_lid_closed failed"
);
set_ui_callbacks!(
handle,
AnimePageData(),
anime.off_when_suspended(),
"Anime off_when_suspended successfully set to {}",
"Setting Anime off_when_suspended failed"
);
set_ui_callbacks!(
handle,
AnimePageData(),
anime.off_when_unplugged(),
"Anime off_when_unplugged successfully set to {}",
"Setting Anime off_when_unplugged failed"
);
})
.map_err(|e| error!("setup_anime_page: upgrade_in_event_loop: {e:?}"))
.ok();
}
});
}

View File

@@ -9,7 +9,7 @@ use slint::{ComponentHandle, Model, RgbaColor, SharedString};
use crate::config::Config;
use crate::ui::show_toast;
use crate::{
set_ui_callbacks, set_ui_props_async, AuraPageData, MainWindow, PowerZones as SlintPowerZones,
set_ui_callbacks, set_ui_props_async, AuraPageData, MainWindow, PowerZones as SlintPowerZones
};
fn decode_hex(s: &str) -> RgbaColor<u8> {
@@ -19,7 +19,7 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
alpha: 255,
red: 0,
green: 0,
blue: 0,
blue: 0
};
}
let c: Vec<u8> = (0..s.len())
@@ -30,7 +30,7 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
alpha: 255,
red: *c.first().unwrap_or(&255),
green: *c.get(1).unwrap_or(&128),
blue: *c.get(2).unwrap_or(&32),
blue: *c.get(2).unwrap_or(&32)
}
}
@@ -38,12 +38,12 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
// TODO: return all
async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Error>> {
let conn = zbus::Connection::system().await?;
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").await?;
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").await?;
let interfaces = f.get_managed_objects().await?;
let mut aura_paths = Vec::new();
for v in interfaces.iter() {
for k in v.1.keys() {
if k.as_str() == "org.asuslinux.Aura" {
if k.as_str() == "xyz.ljones.Aura" {
println!("Found aura device at {}, {}", v.0, k);
aura_paths.push(v.0.clone());
}
@@ -56,7 +56,7 @@ async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Err
if let Some(path) = aura_paths.first() {
return Ok(AuraProxy::builder(&conn)
.path(path.clone())?
.destination("org.asuslinux.Daemon")?
.destination("xyz.ljones.Asusd")?
.build()
.await?);
}
@@ -65,12 +65,12 @@ async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Err
}
pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
ui.global::<AuraPageData>().on_set_hex_from_colour(|c| {
ui.global::<AuraPageData>().on_cb_hex_from_colour(|c| {
format!("#{:02X}{:02X}{:02X}", c.red(), c.green(), c.blue()).into()
});
ui.global::<AuraPageData>()
.on_set_hex_to_colour(|s| decode_hex(s.as_str()).into());
.on_cb_hex_to_colour(|s| decode_hex(s.as_str()).into());
let handle = ui.as_weak();
tokio::spawn(async move {
@@ -189,7 +189,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
.upgrade_in_event_loop(|handle| {
handle
.global::<AuraPageData>()
.on_set_led_power(move |power| {
.on_cb_led_power(move |power| {
let handle_copy = handle_copy.clone();
let proxy_copy = aura.clone();
let power: LaptopAuraPower = power.into();
@@ -198,7 +198,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
"Aura power settings changed".into(),
"Failed to set Aura power settings".into(),
handle_copy,
proxy_copy.set_led_power(power).await,
proxy_copy.set_led_power(power).await
);
});
});

View File

@@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex};
use log::{error, info};
use rog_dbus::zbus_fan_curves::FanCurvesProxy;
use rog_platform::platform::ThrottlePolicy;
use rog_platform::platform::PlatformProfile;
use rog_profiles::fan_curve_set::CurveData;
use slint::{ComponentHandle, Model, Weak};
@@ -13,7 +13,7 @@ pub fn update_fan_data(
handle: Weak<MainWindow>,
bal: Vec<CurveData>,
perf: Vec<CurveData>,
quiet: Vec<CurveData>,
quiet: Vec<CurveData>
) {
handle
.upgrade_in_event_loop(move |handle| {
@@ -24,7 +24,7 @@ pub fn update_fan_data(
.zip(pwm.iter())
.map(|(x, y)| Node {
x: *x as f32,
y: *y as f32,
y: *y as f32
})
.collect();
tmp.as_slice().into()
@@ -109,21 +109,21 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
let handle_copy = handle.clone();
// Do initial setup
let Ok(balanced) = fans
.fan_curve_data(ThrottlePolicy::Balanced)
.fan_curve_data(PlatformProfile::Balanced)
.await
.map_err(|e| error!("{e:}"))
else {
return;
};
let Ok(perf) = fans
.fan_curve_data(ThrottlePolicy::Performance)
.fan_curve_data(PlatformProfile::Performance)
.await
.map_err(|e| error!("{e:}"))
else {
return;
};
let Ok(quiet) = fans
.fan_curve_data(ThrottlePolicy::Quiet)
.fan_curve_data(PlatformProfile::Quiet)
.await
.map_err(|e| error!("{e:}"))
else {
@@ -144,21 +144,21 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
return;
}
let Ok(balanced) = fans
.fan_curve_data(ThrottlePolicy::Balanced)
.fan_curve_data(PlatformProfile::Balanced)
.await
.map_err(|e| error!("{e:}"))
else {
return;
};
let Ok(perf) = fans
.fan_curve_data(ThrottlePolicy::Performance)
.fan_curve_data(PlatformProfile::Performance)
.await
.map_err(|e| error!("{e:}"))
else {
return;
};
let Ok(quiet) = fans
.fan_curve_data(ThrottlePolicy::Quiet)
.fan_curve_data(PlatformProfile::Quiet)
.await
.map_err(|e| error!("{e:}"))
else {
@@ -199,6 +199,6 @@ fn fan_data_for(fan: FanType, enabled: bool, data: Vec<Node>) -> CurveData {
fan: fan.into(),
pwm,
temp,
enabled,
enabled
}
}

View File

@@ -1,40 +1,244 @@
use std::sync::{Arc, Mutex};
use concat_idents::concat_idents;
use log::{debug, error};
use rog_dbus::asus_armoury::AsusArmouryProxy;
use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking};
use rog_platform::asus_armoury::FirmwareAttribute;
use rog_platform::platform::Properties;
use slint::ComponentHandle;
use super::show_toast;
use crate::config::Config;
use crate::{
set_ui_callbacks, set_ui_props_async, AvailableSystemProperties, MainWindow, SystemPageData,
use crate::zbus_proxies::find_iface_async;
use crate::{set_ui_callbacks, set_ui_props_async, AttrMinMax, MainWindow, SystemPageData};
const MINMAX: AttrMinMax = AttrMinMax {
min: 0,
max: 0,
val: -1.0
};
pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
let conn = zbus::blocking::Connection::system().unwrap();
let platform = PlatformProxyBlocking::new(&conn).unwrap();
// let armoury_attrs =
// find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury").unwrap();
// Null everything before the setup step
ui.global::<SystemPageData>()
.set_charge_control_end_threshold(-1.0);
ui.global::<SystemPageData>().set_platform_profile(-1);
ui.global::<SystemPageData>().set_panel_overdrive(-1);
ui.global::<SystemPageData>().set_boot_sound(-1);
ui.global::<SystemPageData>().set_mini_led_mode(-1);
ui.global::<SystemPageData>().set_ppt_pl1_spl(MINMAX);
ui.global::<SystemPageData>().set_ppt_pl2_sppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_pl3_fppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_fppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_apu_sppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_platform_sppt(MINMAX);
ui.global::<SystemPageData>().set_nv_dynamic_boost(MINMAX);
ui.global::<SystemPageData>().set_nv_temp_target(MINMAX);
let sys_props = platform.supported_properties().unwrap();
log::debug!("Available system properties: {sys_props:?}");
let props = AvailableSystemProperties {
ac_command: true,
bat_command: true,
charge_control_end_threshold: sys_props.contains(&Properties::ChargeControlEndThreshold),
disable_nvidia_powerd_on_battery: true,
mini_led_mode: sys_props.contains(&Properties::MiniLedMode),
nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost),
nv_temp_target: sys_props.contains(&Properties::NvTempTarget),
panel_od: sys_props.contains(&Properties::PanelOd),
boot_sound: sys_props.contains(&Properties::PostAnimationSound),
ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt),
ppt_fppt: sys_props.contains(&Properties::PptFppt),
ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl),
ppt_pl2_sppt: sys_props.contains(&Properties::PptPl2Sppt),
ppt_platform_sppt: sys_props.contains(&Properties::PptPlatformSppt),
throttle_thermal_policy: sys_props.contains(&Properties::ThrottlePolicy),
};
if sys_props.contains(&Properties::ChargeControlEndThreshold) {
ui.global::<SystemPageData>()
.set_charge_control_end_threshold(60.0);
}
}
ui.global::<SystemPageData>().set_available(props);
macro_rules! convert_value {
(bool, $value:expr) => {
$value == 1
};
(i32, $value:expr) => {
$value as i32
};
(f32, $value:expr) => {
$value as f32
};
}
macro_rules! convert_to_dbus {
(bool, $value:expr) => {
if $value {
1
} else {
0
}
};
(i32, $value:expr) => {
$value as i32
};
(f32, $value:expr) => {
$value as i32
};
}
macro_rules! init_property {
($property:ident, $handle:expr, $value:expr, $type:tt) => {{
concat_idents!(setter = set_, $property {
$handle.global::<SystemPageData>().setter(convert_value!($type, $value));
});
}};
}
// For initial setup of min/max/val values
macro_rules! init_minmax_property {
($property:ident, $handle:expr, $attr:expr) => {
let proxy_copy = $attr.clone();
let handle_copy = $handle.as_weak();
tokio::spawn(async move {
let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap();
let val = proxy_copy.current_value().await.unwrap() as f32;
handle_copy
.upgrade_in_event_loop(move |handle| {
concat_idents!(setter = set_, $property {
handle
.global::<SystemPageData>()
.setter(AttrMinMax { min, max, val });
});
})
.ok();
});
};
}
// For handling callbacks from UI value changes
macro_rules! setup_callback {
($property:ident, $handle:expr, $attr:expr, $type:tt) => {
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
concat_idents!(on_callback = on_cb_, $property {
$handle
.global::<SystemPageData>()
.on_callback(move |v| {
let handle_copy = handle_copy.clone();
let proxy_copy = proxy_copy.clone();
tokio::spawn(async move {
show_toast(
format!("{} successfully set to {}", stringify!($property), v).into(),
format!("Setting {} failed", stringify!($property)).into(),
handle_copy,
proxy_copy.set_current_value(convert_to_dbus!($type, v)).await,
);
});
});
});
};
}
// For handling callbacks from UI value changes
macro_rules! setup_callback_restore_default {
($property:ident, $handle:expr, $attr:expr) => {
let proxy_copy = $attr.clone();
concat_idents!(on_callback = on_cb_default_, $property {
$handle
.global::<SystemPageData>()
.on_callback(move || {
let proxy_copy = proxy_copy.clone();
tokio::spawn(async move {
proxy_copy.restore_default().await.ok();
});
});
});
};
}
macro_rules! setup_external {
($property:ident, $type:tt, $handle:expr, $attr:expr, $value:expr) => {{
// EXTERNAL CHANGES
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
concat_idents!(setter = set_, $property {
tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await;
use zbus::export::futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
handle_copy
.upgrade_in_event_loop(move |handle| {
handle
.global::<SystemPageData>()
.setter(convert_value!($type, out));
})
.ok();
}
}
});
});
}};
}
// For handling external value changes
macro_rules! setup_minmax_external {
($property:ident, $handle:expr, $attr:expr, $platform:expr) => {
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await;
use zbus::export::futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
concat_idents!(getter = get_, $property {
handle_copy
.upgrade_in_event_loop(move |handle| {
let mut tmp: AttrMinMax =
handle.global::<SystemPageData>().getter();
tmp.val = out as f32;
concat_idents!(setter = set_, $property {
handle.global::<SystemPageData>().setter(tmp);
});
})
.ok();
});
}
}
});
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
let platform_proxy_copy = $platform.clone();
tokio::spawn(async move {
let mut x = platform_proxy_copy.receive_platform_profile_changed().await;
use zbus::export::futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(_) = e.get().await {
debug!("receive_platform_profile_changed, getting new {}", stringify!(attr));
let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap();
let val = proxy_copy.current_value().await.unwrap() as f32;
handle_copy
.upgrade_in_event_loop(move |handle| {
concat_idents!(setter = set_, $property {
handle
.global::<SystemPageData>()
.setter(AttrMinMax { min, max, val });
});
})
.ok();
}
}
});
};
}
// This macro expects are consistent naming between proxy calls and slint
// globals
#[macro_export]
macro_rules! set_ui_props_async {
($ui:ident, $proxy:ident, $global:ident, $proxy_fn:ident) => {
if let Ok(value) = $proxy.$proxy_fn().await {
$ui.upgrade_in_event_loop(move |handle| {
concat_idents::concat_idents!(set = set_, $proxy_fn {
handle.global::<$global>().set(value.into());
});
}).ok();
}
};
}
pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
@@ -53,190 +257,207 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
SystemPageData,
charge_control_end_threshold
);
set_ui_props_async!(handle, platform, SystemPageData, throttle_thermal_policy);
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_linked_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_balanced_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_performance_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_quiet_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_battery);
set_ui_props_async!(handle, platform, SystemPageData, platform_profile);
set_ui_props_async!(
handle,
platform,
SystemPageData,
change_throttle_policy_on_battery
platform_profile_linked_epp
);
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_ac);
set_ui_props_async!(handle, platform, SystemPageData, profile_balanced_epp);
set_ui_props_async!(handle, platform, SystemPageData, profile_performance_epp);
set_ui_props_async!(handle, platform, SystemPageData, profile_quiet_epp);
set_ui_props_async!(
handle,
platform,
SystemPageData,
change_throttle_policy_on_ac
platform_profile_on_battery
);
set_ui_props_async!(
handle,
platform,
SystemPageData,
change_platform_profile_on_battery
);
set_ui_props_async!(handle, platform, SystemPageData, platform_profile_on_ac);
set_ui_props_async!(
handle,
platform,
SystemPageData,
change_platform_profile_on_ac
);
set_ui_props_async!(handle, platform, SystemPageData, panel_od);
set_ui_props_async!(handle, platform, SystemPageData, boot_sound);
set_ui_props_async!(handle, platform, SystemPageData, mini_led_mode);
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl1_spl);
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl2_sppt);
set_ui_props_async!(handle, platform, SystemPageData, ppt_fppt);
set_ui_props_async!(handle, platform, SystemPageData, ppt_apu_sppt);
set_ui_props_async!(handle, platform, SystemPageData, ppt_platform_sppt);
set_ui_props_async!(handle, platform, SystemPageData, nv_dynamic_boost);
set_ui_props_async!(handle, platform, SystemPageData, nv_temp_target);
let sys_props = platform.supported_properties().await.unwrap();
log::debug!("Available system properties: {sys_props:?}");
let props = AvailableSystemProperties {
ac_command: true,
bat_command: true,
charge_control_end_threshold: sys_props
.contains(&Properties::ChargeControlEndThreshold),
disable_nvidia_powerd_on_battery: true,
mini_led_mode: sys_props.contains(&Properties::MiniLedMode),
nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost),
nv_temp_target: sys_props.contains(&Properties::NvTempTarget),
panel_od: sys_props.contains(&Properties::PanelOd),
boot_sound: sys_props.contains(&Properties::PostAnimationSound),
ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt),
ppt_fppt: sys_props.contains(&Properties::PptFppt),
ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl),
ppt_pl2_sppt: sys_props.contains(&Properties::PptPl2Sppt),
ppt_platform_sppt: sys_props.contains(&Properties::PptPlatformSppt),
throttle_thermal_policy: sys_props.contains(&Properties::ThrottlePolicy),
};
// TODO: move the fail/sucess messages to slint
let platform_copy = platform.clone();
handle
.upgrade_in_event_loop(move |handle| {
handle.global::<SystemPageData>().set_available(props);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.charge_control_end_threshold(as u8),
platform_copy.charge_control_end_threshold(as u8),
"Charge limit successfully set to {}",
"Setting Charge limit failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform.panel_od(),
"Panel OverDrive successfully set to {}",
"Setting Panel OverDrive failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform.boot_sound(),
"POST Animation sound successfully set to {}",
"Setting POST Animation sound failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform.mini_led_mode(),
"MiniLED mode successfully set to {}",
"Setting MiniLED mode failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_thermal_policy(.into()),
platform_copy.platform_profile(.into()),
"Throttle policy set to {}",
"Setting Throttle policy failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_balanced_epp(.into()),
platform_copy.profile_balanced_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_performance_epp(.into()),
platform_copy.profile_performance_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_quiet_epp(.into()),
platform_copy.profile_quiet_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform.throttle_policy_linked_epp(),
platform_copy.platform_profile_linked_epp(),
"Throttle policy linked to EPP: {}",
"Setting Throttle policy linked to EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_policy_on_ac(.into()),
platform_copy.platform_profile_on_ac(.into()),
"Throttle policy on AC set to {}",
"Setting Throttle policy on AC failed"
);
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform.change_throttle_policy_on_ac(.into()),
platform_copy.change_platform_profile_on_ac(.into()),
"Throttle policy on AC enabled: {}",
"Setting Throttle policy on AC failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_policy_on_battery(.into()),
platform_copy.platform_profile_on_battery(.into()),
"Throttle policy on abttery set to {}",
"Setting Throttle policy on battery failed"
);
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform.change_throttle_policy_on_battery(.into()),
platform_copy.change_platform_profile_on_battery(.into()),
"Throttle policy on battery enabled: {}",
"Setting Throttle policy on AC failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_pl1_spl(as u8),
"ppt_pl1_spl successfully set to {}",
"Setting ppt_pl1_spl failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_pl2_sppt(as u8),
"ppt_pl2_sppt successfully set to {}",
"Setting ppt_pl2_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_fppt(as u8),
"ppt_fppt successfully set to {}",
"Setting ppt_fppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_apu_sppt(as u8),
"ppt_apu_sppt successfully set to {}",
"Setting ppt_apu_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_platform_sppt(as u8),
"ppt_platform_sppt successfully set to {}",
"Setting ppt_platform_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.nv_temp_target(as u8),
"nv_temp_target successfully set to {}",
"Setting nv_temp_target failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.nv_dynamic_boost(as u8),
"nv_dynamic_boost successfully set to {}",
"Setting nv_dynamic_boost failed"
);
})
.unwrap();
.ok();
let armoury_attrs;
if let Ok(attrs) = find_iface_async::<AsusArmouryProxy>("xyz.ljones.AsusArmoury").await {
armoury_attrs = attrs;
handle
.upgrade_in_event_loop(|ui| {
ui.global::<SystemPageData>().set_asus_armoury_loaded(true)
})
.ok();
} else {
error!(
"The kernel module asus-armoury is required, if you do not have this you will \
need to either build or install a kernel which includes the patchwork. This \
driver is in process of being upstreamed"
);
return;
}
for attr in armoury_attrs {
if let Ok(value) = attr.current_value().await {
let name = attr.name().await.unwrap();
let platform = platform.clone();
handle
.upgrade_in_event_loop(move |handle| match name {
FirmwareAttribute::ApuMem => {}
FirmwareAttribute::CoresPerformance => {}
FirmwareAttribute::CoresEfficiency => {}
FirmwareAttribute::PptPl1Spl => {
init_minmax_property!(ppt_pl1_spl, handle, attr);
setup_callback!(ppt_pl1_spl, handle, attr, i32);
setup_callback_restore_default!(ppt_pl1_spl, handle, attr);
setup_minmax_external!(ppt_pl1_spl, handle, attr, platform);
}
FirmwareAttribute::PptPl2Sppt => {
init_minmax_property!(ppt_pl2_sppt, handle, attr);
setup_callback!(ppt_pl2_sppt, handle, attr, i32);
setup_callback_restore_default!(ppt_pl2_sppt, handle, attr);
setup_minmax_external!(ppt_pl2_sppt, handle, attr, platform);
}
FirmwareAttribute::PptPl3Fppt => {
init_minmax_property!(ppt_pl3_fppt, handle, attr);
setup_callback!(ppt_pl3_fppt, handle, attr, i32);
setup_callback_restore_default!(ppt_pl3_fppt, handle, attr);
setup_minmax_external!(ppt_pl3_fppt, handle, attr, platform);
}
FirmwareAttribute::PptFppt => {
init_minmax_property!(ppt_fppt, handle, attr);
setup_callback!(ppt_fppt, handle, attr, i32);
setup_callback_restore_default!(ppt_fppt, handle, attr);
setup_minmax_external!(ppt_fppt, handle, attr, platform);
}
FirmwareAttribute::PptApuSppt => {
init_minmax_property!(ppt_apu_sppt, handle, attr);
setup_callback!(ppt_apu_sppt, handle, attr, i32);
setup_callback_restore_default!(ppt_apu_sppt, handle, attr);
setup_minmax_external!(ppt_apu_sppt, handle, attr, platform);
}
FirmwareAttribute::PptPlatformSppt => {
init_minmax_property!(ppt_platform_sppt, handle, attr);
setup_callback!(ppt_platform_sppt, handle, attr, i32);
setup_callback_restore_default!(ppt_platform_sppt, handle, attr);
setup_minmax_external!(ppt_platform_sppt, handle, attr, platform);
}
FirmwareAttribute::NvDynamicBoost => {
init_minmax_property!(nv_dynamic_boost, handle, attr);
setup_callback!(nv_dynamic_boost, handle, attr, i32);
setup_callback_restore_default!(nv_dynamic_boost, handle, attr);
setup_minmax_external!(nv_dynamic_boost, handle, attr, platform);
}
FirmwareAttribute::NvTempTarget => {
init_minmax_property!(nv_temp_target, handle, attr);
setup_callback!(nv_temp_target, handle, attr, i32);
setup_callback_restore_default!(nv_temp_target, handle, attr);
setup_minmax_external!(nv_temp_target, handle, attr, platform);
}
FirmwareAttribute::DgpuBaseTgp => {}
FirmwareAttribute::DgpuTgp => {}
FirmwareAttribute::ChargeMode => {}
FirmwareAttribute::BootSound => {
init_property!(boot_sound, handle, value, i32);
setup_callback!(boot_sound, handle, attr, i32);
setup_external!(boot_sound, i32, handle, attr, value)
}
FirmwareAttribute::McuPowersave => {}
FirmwareAttribute::PanelOverdrive => {
init_property!(panel_overdrive, handle, value, i32);
setup_callback!(panel_overdrive, handle, attr, i32);
setup_external!(panel_overdrive, i32, handle, attr, value)
}
FirmwareAttribute::PanelHdMode => {}
FirmwareAttribute::EgpuConnected => {}
FirmwareAttribute::EgpuEnable => {}
FirmwareAttribute::DgpuDisable => {}
FirmwareAttribute::GpuMuxMode => {}
FirmwareAttribute::MiniLedMode => {
init_property!(mini_led_mode, handle, value, i32);
setup_callback!(mini_led_mode, handle, attr, i32);
setup_external!(mini_led_mode, i32, handle, attr, value);
}
FirmwareAttribute::PendingReboot => {}
FirmwareAttribute::None => {}
})
.ok();
}
}
});
}

View File

@@ -1,68 +0,0 @@
use std::sync::{Arc, Mutex};
use zbus::zvariant::{OwnedValue, Type, Value};
use zbus::{interface, proxy};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Type, Value, OwnedValue)]
#[zvariant(signature = "u")]
pub enum AppState {
MainWindowOpen = 0,
/// If the app is running, open the main window
MainWindowShouldOpen = 1,
MainWindowClosed = 2,
StartingUp = 3,
QuitApp = 4,
LockFailed = 5,
}
pub struct ROGCCZbus {
state: Arc<Mutex<AppState>>,
}
impl ROGCCZbus {
pub fn new() -> Self {
Self {
state: Arc::new(Mutex::new(AppState::StartingUp)),
}
}
pub fn clone_state(&self) -> Arc<Mutex<AppState>> {
self.state.clone()
}
}
pub const ZBUS_PATH: &str = "/xyz/ljones/rogcc";
pub const ZBUS_IFACE: &str = "xyz.ljones.rogcc";
#[interface(name = "xyz.ljones.rogcc")]
impl ROGCCZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
async fn state(&self) -> AppState {
if let Ok(lock) = self.state.try_lock() {
return *lock;
}
AppState::LockFailed
}
#[zbus(property)]
async fn set_state(&self, state: AppState) {
if let Ok(mut lock) = self.state.try_lock() {
*lock = state;
}
}
}
#[proxy(
interface = "xyz.ljones.rogcc",
default_service = "xyz.ljones.rogcc",
default_path = "/xyz/ljones/rogcc"
)]
pub trait ROGCCZbus {
/// EnableDisplay property
#[zbus(property)]
fn state(&self) -> zbus::Result<AppState>;
#[zbus(property)]
fn set_state(&self, state: AppState) -> zbus::Result<()>;
}

View File

@@ -0,0 +1,150 @@
use std::sync::{Arc, Mutex};
use zbus::blocking::proxy::ProxyImpl;
use zbus::blocking::{fdo, Connection};
use zbus::zvariant::{OwnedValue, Type, Value};
use zbus::{interface, proxy};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Type, Value, OwnedValue)]
#[zvariant(signature = "u")]
pub enum AppState {
MainWindowOpen = 0,
/// If the app is running, open the main window
MainWindowShouldOpen = 1,
MainWindowClosed = 2,
StartingUp = 3,
QuitApp = 4,
LockFailed = 5
}
pub struct ROGCCZbus {
state: Arc<Mutex<AppState>>
}
impl ROGCCZbus {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self {
state: Arc::new(Mutex::new(AppState::StartingUp))
}
}
pub fn clone_state(&self) -> Arc<Mutex<AppState>> {
self.state.clone()
}
}
pub const ZBUS_PATH: &str = "/xyz/ljones/rogcc";
pub const ZBUS_IFACE: &str = "xyz.ljones.rogcc";
#[interface(name = "xyz.ljones.rogcc")]
impl ROGCCZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
async fn state(&self) -> AppState {
if let Ok(lock) = self.state.try_lock() {
return *lock;
}
AppState::LockFailed
}
#[zbus(property)]
async fn set_state(&self, state: AppState) {
if let Ok(mut lock) = self.state.try_lock() {
*lock = state;
}
}
}
#[proxy(
interface = "xyz.ljones.rogcc",
default_service = "xyz.ljones.rogcc",
default_path = "/xyz/ljones/rogcc"
)]
pub trait ROGCCZbus {
/// EnableDisplay property
#[zbus(property)]
fn state(&self) -> zbus::Result<AppState>;
#[zbus(property)]
fn set_state(&self, state: AppState) -> zbus::Result<()>;
}
pub fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>
{
let conn = Connection::system().unwrap();
let f = fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
let interfaces = f.get_managed_objects().unwrap();
let mut paths = Vec::new();
for v in interfaces.iter() {
// let o: Vec<zbus::names::OwnedInterfaceName> = v.1.keys().map(|e|
// e.to_owned()).collect(); println!("{}, {:?}", v.0, o);
for k in v.1.keys() {
if k.as_str() == iface_name {
// println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone());
}
}
}
if paths.len() > 1 {
println!("Multiple asusd interfaces devices found");
}
if !paths.is_empty() {
let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(b));
for path in paths {
ctrl.push(
T::builder(&conn)
.path(path.clone())?
.destination("xyz.ljones.Asusd")?
.build()?
);
}
return Ok(ctrl);
}
Err("No Aura interface".into())
}
pub async fn find_iface_async<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where
T: zbus::proxy::ProxyImpl<'static> + From<zbus::Proxy<'static>>
{
let conn = zbus::Connection::system().await.unwrap();
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/")
.await
.unwrap();
let interfaces = f.get_managed_objects().await.unwrap();
let mut paths = Vec::new();
for v in interfaces.iter() {
// let o: Vec<zbus::names::OwnedInterfaceName> = v.1.keys().map(|e|
// e.to_owned()).collect(); println!("{}, {:?}", v.0, o);
for k in v.1.keys() {
if k.as_str() == iface_name {
// println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone());
}
}
}
if paths.len() > 1 {
println!("Multiple asusd interfaces devices found");
}
if !paths.is_empty() {
let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(b));
for path in paths {
ctrl.push(
T::builder(&conn)
.path(path.clone())?
.destination("xyz.ljones.Asusd")?
.build()
.await?
);
}
return Ok(ctrl);
}
Err("No interface".into())
}

View File

@@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-12-24 22:29+0000\n"
"POT-Creation-Date: 2025-01-19 10:35+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -12,157 +12,233 @@ msgstr ""
"Language: \n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: rog-control-center/ui/pages/system.slint:26
#: rog-control-center/ui/pages/system.slint:19
msgctxt "SystemPageData"
msgid "Balanced"
msgstr ""
#: rog-control-center/ui/pages/system.slint:26 rog-control-center/ui/pages/system.slint:30
#: rog-control-center/ui/pages/system.slint:19 rog-control-center/ui/pages/system.slint:23
msgctxt "SystemPageData"
msgid "Performance"
msgstr ""
#: rog-control-center/ui/pages/system.slint:26
#: rog-control-center/ui/pages/system.slint:19
msgctxt "SystemPageData"
msgid "Quiet"
msgstr ""
#: rog-control-center/ui/pages/system.slint:29
#: rog-control-center/ui/pages/system.slint:22
msgctxt "SystemPageData"
msgid "Default"
msgstr ""
#: rog-control-center/ui/pages/system.slint:31
#: rog-control-center/ui/pages/system.slint:24
msgctxt "SystemPageData"
msgid "BalancePerformance"
msgstr ""
#: rog-control-center/ui/pages/system.slint:32
#: rog-control-center/ui/pages/system.slint:25
msgctxt "SystemPageData"
msgid "BalancePower"
msgstr ""
#: rog-control-center/ui/pages/system.slint:33
#: rog-control-center/ui/pages/system.slint:26
msgctxt "SystemPageData"
msgid "Power"
msgstr ""
#: rog-control-center/ui/pages/system.slint:110
#: rog-control-center/ui/pages/system.slint:139
msgctxt "PageSystem"
msgid "Base system settings"
msgid "Power settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:115
#: rog-control-center/ui/pages/system.slint:144
msgctxt "PageSystem"
msgid "Charge limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:127
#: rog-control-center/ui/pages/system.slint:158
msgctxt "PageSystem"
msgid "Throttle Policy"
msgid "Platform Profile"
msgstr ""
#: rog-control-center/ui/pages/system.slint:137
#: rog-control-center/ui/pages/system.slint:168
msgctxt "PageSystem"
msgid "Advanced"
msgstr ""
#: rog-control-center/ui/pages/system.slint:149
#: rog-control-center/ui/pages/system.slint:186
msgctxt "PageSystem"
msgid "Armoury settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:194
msgctxt "PageSystem"
msgid "Panel Overdrive"
msgstr ""
#: rog-control-center/ui/pages/system.slint:157
#: rog-control-center/ui/pages/system.slint:202
msgctxt "PageSystem"
msgid "MiniLED Mode"
msgstr ""
#: rog-control-center/ui/pages/system.slint:165
#: rog-control-center/ui/pages/system.slint:210
msgctxt "PageSystem"
msgid "POST boot sound"
msgstr ""
#: rog-control-center/ui/pages/system.slint:183
msgctxt "PageSystem"
msgid "System performance settings"
#: rog-control-center/ui/pages/system.slint:224
msgctxt "no_asus_armoury_driver_2"
msgid "The asus-armoury driver is not loaded"
msgstr ""
#: rog-control-center/ui/pages/system.slint:188
#: rog-control-center/ui/pages/system.slint:230
msgctxt "no_asus_armoury_driver_2"
msgid "For advanced features you will require a kernel with this driver added."
msgstr ""
#: rog-control-center/ui/pages/system.slint:241
msgctxt "ppt_warning"
msgid "The following settings may not be safe, please review the help."
msgstr ""
#: rog-control-center/ui/pages/system.slint:246 rog-control-center/ui/pages/system.slint:247
msgctxt "ppt_pl1_spl"
msgid "PL1, sustained power limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:198
msgctxt "ppt_pl2_sppt"
msgid "PL2, turbo power limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:208
msgctxt "ppt_fppt"
msgid "FPPT, Fast Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:218
msgctxt "ppt_apu_sppt"
msgid "SPPT, APU slow power limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:228
msgctxt "ppt_platform_sppt"
msgid "Slow package power tracking limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:238
msgctxt "nv_dynamic_boost"
msgid "dGPU boost overclock"
msgid "CPU Sustained Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:248
msgctxt "nv_temp_target"
msgid "dGPU temperature max"
msgctxt "ppt_pl1_spl_help"
msgid ""
"Long-term CPU power limit that affects sustained workload performance. "
"Higher values may increase heat and power consumption."
msgstr ""
#: rog-control-center/ui/pages/system.slint:294
#: rog-control-center/ui/pages/system.slint:263 rog-control-center/ui/pages/system.slint:264
msgctxt "ppt_pl2_sppt"
msgid "CPU Turbo Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:265
msgctxt "ppt_pl2_sppt_help"
msgid ""
"Short-term CPU power limit for boost periods. Controls maximum power during "
"brief high-performance bursts."
msgstr ""
#: rog-control-center/ui/pages/system.slint:280 rog-control-center/ui/pages/system.slint:281
msgctxt "ppt_pl3_fppt"
msgid "CPU Fast Burst Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:282
msgctxt "ppt_pl3_fppt_help"
msgid ""
"Ultra-short duration power limit for instantaneous CPU bursts. Affects "
"responsiveness during sudden workload spikes."
msgstr ""
#: rog-control-center/ui/pages/system.slint:296 rog-control-center/ui/pages/system.slint:297
msgctxt "ppt_fppt"
msgid "Fast Package Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:298
msgctxt "ppt_fppt_help"
msgid ""
"Ultra-short duration power limit for system package. Controls maximum power "
"during millisecond-scale load spikes."
msgstr ""
#: rog-control-center/ui/pages/system.slint:313 rog-control-center/ui/pages/system.slint:314
msgctxt "ppt_apu_sppt"
msgid "APU Sustained Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:315
msgctxt "ppt_apu_sppt_help"
msgid ""
"Long-term power limit for integrated graphics and CPU combined. Affects "
"sustained performance of APU-based workloads."
msgstr ""
#: rog-control-center/ui/pages/system.slint:330 rog-control-center/ui/pages/system.slint:331
msgctxt "ppt_platform_sppt"
msgid "Platform Sustained Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:332
msgctxt "ppt_platform_sppt_help"
msgid ""
"Overall system power limit for sustained operations. Controls total platform "
"power consumption over extended periods."
msgstr ""
#: rog-control-center/ui/pages/system.slint:347 rog-control-center/ui/pages/system.slint:348
msgctxt "nv_dynamic_boost"
msgid "GPU Power Boost"
msgstr ""
#: rog-control-center/ui/pages/system.slint:349
msgctxt "nv_dynamic_boost_help"
msgid ""
"Additional power allocation for GPU dynamic boost. Higher values increase "
"GPU performance but generate more heat."
msgstr ""
#: rog-control-center/ui/pages/system.slint:364 rog-control-center/ui/pages/system.slint:365
msgctxt "nv_temp_target"
msgid "GPU Temperature Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:366
msgctxt "nv_temp_target_help"
msgid ""
"Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain "
"temperature below this limit."
msgstr ""
#: rog-control-center/ui/pages/system.slint:417
msgctxt "PageSystem"
msgid "Energy Performance Preference linked to Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:298
#: rog-control-center/ui/pages/system.slint:421
msgctxt "PageSystem"
msgid "Change EPP based on Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:306
#: rog-control-center/ui/pages/system.slint:429
msgctxt "PageSystem"
msgid "EPP for Balanced Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:316
#: rog-control-center/ui/pages/system.slint:439
msgctxt "PageSystem"
msgid "EPP for Performance Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:326
#: rog-control-center/ui/pages/system.slint:449
msgctxt "PageSystem"
msgid "EPP for Quiet Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:344
#: rog-control-center/ui/pages/system.slint:467
msgctxt "PageSystem"
msgid "Throttle Policy for power state"
msgstr ""
#: rog-control-center/ui/pages/system.slint:350
#: rog-control-center/ui/pages/system.slint:473
msgctxt "PageSystem"
msgid "Throttle Policy on Battery"
msgstr ""
#: rog-control-center/ui/pages/system.slint:360 rog-control-center/ui/pages/system.slint:381
#: rog-control-center/ui/pages/system.slint:483 rog-control-center/ui/pages/system.slint:504
msgctxt "PageSystem"
msgid "Enabled"
msgstr ""
#: rog-control-center/ui/pages/system.slint:371
#: rog-control-center/ui/pages/system.slint:494
msgctxt "PageSystem"
msgid "Throttle Policy on AC"
msgstr ""
@@ -647,6 +723,11 @@ msgctxt "AuraPowerGroupOld"
msgid "Sleep"
msgstr ""
#: rog-control-center/ui/widgets/common.slint:133
msgctxt "confirm_reset"
msgid "Are you sure you want to reset this?"
msgstr ""
#: rog-control-center/ui/main_window.slint:51
msgctxt "MainWindow"
msgid "ROG"

View File

@@ -1,6 +1,6 @@
import { Palette, Button, VerticalBox } from "std-widgets.slint";
import { AppSize } from "globals.slint";
import { PageSystem, AvailableSystemProperties, SystemPageData } from "pages/system.slint";
import { PageSystem, SystemPageData, AttrMinMax } from "pages/system.slint";
import { SideBar } from "widgets/sidebar.slint";
import { PageAbout } from "pages/about.slint";
import { PageFans } from "pages/fans.slint";
@@ -15,14 +15,14 @@ import { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones,
export { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect }
import { PageAppSettings, AppSettingsPageData } from "pages/app_settings.slint";
export { AppSize, AvailableSystemProperties, SystemPageData, AnimePageData, AppSettingsPageData }
export { AppSize, AttrMinMax, SystemPageData, AnimePageData, AppSettingsPageData }
export component MainWindow inherits Window {
title: "ROG Control";
default-font-family: "DejaVu Sans";
in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true];
private property <bool> show-notif;
private property <bool> fade-cover;
private property <bool> show_notif;
private property <bool> fade_cover;
private property <bool> toast: false;
private property <string> toast_text: "I show when something is waiting";
callback show_toast(string);
@@ -31,10 +31,10 @@ export component MainWindow inherits Window {
toast_text = text;
}
callback exit-app();
callback show-notification(bool);
show-notification(yes) => {
show-notif = yes;
fade-cover = yes;
callback show_notification(bool);
show_notification(yes) => {
show_notif = yes;
fade_cover = yes;
}
callback external_colour_change();
external_colour_change() => {
@@ -109,7 +109,7 @@ export component MainWindow inherits Window {
}
}
if fade-cover: Rectangle {
if fade_cover: Rectangle {
x: 0px;
y: 0px;
width: root.width;
@@ -121,10 +121,10 @@ export component MainWindow inherits Window {
width: 100%;
clicked => {
// toolbar-dropdown.close();
if (show-notif) {
show-notif = false;
if (show_notif) {
show_notif = false;
}
fade-cover = false;
fade_cover = false;
}
}
}
@@ -134,7 +134,8 @@ export component MainWindow inherits Window {
y: 0px;
width: root.width;
height: 32px;
opacity: 0.8;
opacity: 1.0;
background: Colors.grey;
TouchArea {
height: 100%;
width: 100%;
@@ -155,7 +156,7 @@ export component MainWindow inherits Window {
}
// // TODO: or use Dialogue
if show-notif: Rectangle {
if show_notif: Rectangle {
x: root.width / 8;
y: root.height / 8;
height: (root.height / 8) * 6;
@@ -164,7 +165,7 @@ export component MainWindow inherits Window {
height: 100%;
width: 100%;
clicked => {
show-notif = false;
show_notif = false;
exit-app();
}
}

View File

@@ -17,7 +17,7 @@ export component PageAbout inherits VerticalLayout {
Text {
wrap: TextWrap.word-wrap;
text: "You will require these patches: https://lore.kernel.org/platform-driver-x86/20240404001652.86207-1-luke@ljones.dev/, they have been merged upstream for kernel 6.10. The main thing is that the PPT settings will apply without them, but the read/back will fail";
text: "You will require a kernel built with my work from here: https://github.com/flukejones/linux";
}
Text {
@@ -28,19 +28,7 @@ export component PageAbout inherits VerticalLayout {
}
Text {
text: "- [x] Theme the widgets";
}
Text {
text: "- [x] Add a fullscreen mode (cli arg)";
}
Text {
text: "- [x] Disable aura items depending if mode supports or not";
}
Text {
text: "- [x] Add fan curve graph controls";
text: "- [ ] Theme the widgets";
}
Text {
@@ -48,11 +36,15 @@ export component PageAbout inherits VerticalLayout {
}
Text {
text: "- [ ] Supergfx control";
text: "- [ ] Include fan speeds, temps in a bottom bar";
}
Text {
text: "- [ ] Include fan speeds, temps in a bottom bar";
text: "- [ ] Slash control";
}
Text {
text: "- [ ] Supergfx control";
}
Text {

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