From 39f53d76aca5d9a2de92970d928cc85c1a4bf294 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Wed, 22 Mar 2023 22:15:36 -0400 Subject: [PATCH] Move to libryzenadj from my custom bindings --- backend/Cargo.lock | 374 ++++++++++++++++++++- backend/Cargo.toml | 4 +- backend/src/api/general.rs | 16 + backend/src/api/handler.rs | 4 +- backend/src/main.rs | 7 +- backend/src/settings/generic_amd/gpu.rs | 41 ++- backend/src/settings/steam_deck/battery.rs | 6 +- backend/src/state/steam_deck/cpu.rs | 2 +- backend/src/state/steam_deck/gpu.rs | 2 +- package.json | 2 +- src/backend.ts | 4 + src/index.tsx | 12 + 12 files changed, 441 insertions(+), 33 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 22f4d10..67dcd52 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -68,6 +68,15 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "async-recursion" version = "1.0.2" @@ -104,9 +113,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "bindgen" -version = "0.63.0" +version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36d860121800b2a9a94f9b5604b332d5cffb234ce17609ea479d723dbc9d3885" +checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" dependencies = [ "bitflags", "cexpr", @@ -159,6 +168,18 @@ dependencies = [ "safemem", ] +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "bytecount" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" + [[package]] name = "byteorder" version = "1.4.3" @@ -192,6 +213,21 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits", + "time 0.1.45", + "wasm-bindgen", + "winapi", +] + [[package]] name = "cipher" version = "0.3.0" @@ -212,6 +248,31 @@ dependencies = [ "libloading", ] +[[package]] +name = "cmake" +version = "0.1.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db34956e100b30725f2eb215f90d4871051239535632f84fea3bc92722c66b7c" +dependencies = [ + "cc", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "cpufeatures" version = "0.2.5" @@ -249,6 +310,50 @@ dependencies = [ "cipher", ] +[[package]] +name = "cxx" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "digest" version = "0.10.6" @@ -453,7 +558,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -595,6 +700,30 @@ dependencies = [ "want", ] +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "idna" version = "0.3.0" @@ -640,6 +769,15 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -668,6 +806,29 @@ dependencies = [ "winapi", ] +[[package]] +name = "libryzenadj" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a805571abbf0729e3641b825b734948ce84ccbb54b9f08afae0b860bb12af971" +dependencies = [ + "errno", + "libryzenadj-sys", + "num_enum", + "thiserror", +] + +[[package]] +name = "libryzenadj-sys" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b72f39d32e246ce0db7b4dd2430ddb5bb4dfa27681bce696a8746ac88892de1" +dependencies = [ + "bindgen", + "cmake", + "patch", +] + [[package]] name = "limits_core" version = "0.1.0" @@ -676,6 +837,15 @@ dependencies = [ "serde_json", ] +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + [[package]] name = "linux-raw-sys" version = "0.1.4" @@ -736,7 +906,7 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.45.0", ] @@ -768,6 +938,36 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nom_locate" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e299bf5ea7b212e811e71174c5d1a5d065c4c0ad0c8691ecb1f97e3e66025e" +dependencies = [ + "bytecount", + "memchr", + "nom", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.15.0" @@ -778,6 +978,27 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "num_threads" version = "0.1.6" @@ -805,6 +1026,17 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "patch" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c07fdcdd8b05bdcf2a25bc195b6c34cbd52762ada9dba88bf81e7686d14e7a" +dependencies = [ + "chrono", + "nom", + "nom_locate", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -863,13 +1095,13 @@ dependencies = [ [[package]] name = "powertools" -version = "1.2.0-beta4" +version = "1.3.0-alpha" dependencies = [ "async-trait", + "libryzenadj", "limits_core", "log", "regex", - "ryzenadj-rs", "serde", "serde_json", "simplelog", @@ -884,6 +1116,16 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.51" @@ -999,15 +1241,6 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" -[[package]] -name = "ryzenadj-rs" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc77f2824d9c46759ba4907c8d3c3ca7131593a41fc389335bcdfda339a866bd" -dependencies = [ - "bindgen", -] - [[package]] name = "safemem" version = "0.3.3" @@ -1020,6 +1253,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +[[package]] +name = "scratch" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" + [[package]] name = "serde" version = "1.0.152" @@ -1099,7 +1338,7 @@ checksum = "acee08041c5de3d5048c8b3f6f13fafb3026b24ba43c6a695a0c76179b844369" dependencies = [ "log", "termcolor", - "time", + "time 0.3.20", ] [[package]] @@ -1180,6 +1419,17 @@ dependencies = [ "syn", ] +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + [[package]] name = "time" version = "0.3.20" @@ -1278,6 +1528,23 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml_datetime" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" + +[[package]] +name = "toml_edit" +version = "0.19.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc18466501acd8ac6a3f615dd29a3438f8ca6bb3b19537138b3106e575621274" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -1375,6 +1642,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + [[package]] name = "universal-hash" version = "0.4.1" @@ -1494,12 +1767,72 @@ dependencies = [ "tracing", ] +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + [[package]] name = "which" version = "4.4.0" @@ -1623,6 +1956,15 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +[[package]] +name = "winnow" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d020b441f92996c80d94ae9166e8501e59c7bb56121189dc9eab3bd8216966" +dependencies = [ + "memchr", +] + [[package]] name = "zeroize" version = "1.3.0" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 14072fa..1c5195d 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "powertools" -version = "1.2.0-beta4" +version = "1.3.0-alpha" edition = "2021" authors = ["NGnius (Graham) "] description = "Backend (superuser) functionality for PowerTools" @@ -27,7 +27,7 @@ simplelog = "0.12" # limits & driver functionality limits_core = { version = "0.1.0", path = "./limits_core" } regex = "1" -ryzenadj-rs = { version = "0.1" } +libryzenadj = { version = "0.12" } # ureq's tls feature does not like musl targets ureq = { version = "2.5", features = ["json", "gzip", "brotli", "charset"], default-features = false, optional = true } diff --git a/backend/src/api/general.rs b/backend/src/api/general.rs index aae871b..25aaa59 100644 --- a/backend/src/api/general.rs +++ b/backend/src/api/general.rs @@ -248,3 +248,19 @@ fn log_msg_by_level(level: u8, msg: &str) { } } +/// Generate set battery charge rate web method +pub fn force_apply( + sender: Sender, +) -> impl Fn(super::ApiParameterType) -> super::ApiParameterType { + let sender = Mutex::new(sender); // Sender is not Sync; this is required for safety + let setter = move |_: ()| + sender.lock() + .unwrap() + .send(ApiMessage::General(GeneralMessage::ApplyNow)) + .expect("force_apply send failed"); + move |_params_in: super::ApiParameterType| { + setter(()); + vec![true.into()] + } +} + diff --git a/backend/src/api/handler.rs b/backend/src/api/handler.rs index 7d3e7f9..fc5f0ed 100644 --- a/backend/src/api/handler.rs +++ b/backend/src/api/handler.rs @@ -194,6 +194,7 @@ pub enum GeneralMessage { SetPersistent(bool), GetPersistent(Callback), GetCurrentProfileName(Callback), + ApplyNow, } impl GeneralMessage { @@ -203,12 +204,13 @@ impl GeneralMessage { Self::SetPersistent(val) => *settings.persistent() = val, Self::GetPersistent(cb) => cb(*settings.persistent()), Self::GetCurrentProfileName(cb) => cb(settings.get_name().to_owned()), + Self::ApplyNow => {}, } dirty } fn is_modify(&self) -> bool { - matches!(self, Self::SetPersistent(_)) + matches!(self, Self::SetPersistent(_) | Self::ApplyNow) } } diff --git a/backend/src/main.rs b/backend/src/main.rs index 0971965..6adbc46 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -227,7 +227,12 @@ fn main() -> Result<(), ()> { "GENERAL_get_provider", api::general::get_provider(api_sender.clone()) ) - .register("GENERAL_idk", api::general::gunter); + .register("GENERAL_idk", api::general::gunter) + // general API functions + .register( + "GENERAL_apply_now", + api::general::force_apply(api_sender.clone()) + ); if let Err(e) = loaded_settings.on_set() { e.iter().for_each(|e| log::error!("Startup Settings.on_set() error: {}", e)); diff --git a/backend/src/settings/generic_amd/gpu.rs b/backend/src/settings/generic_amd/gpu.rs index 6d35bb1..cb3fb49 100644 --- a/backend/src/settings/generic_amd/gpu.rs +++ b/backend/src/settings/generic_amd/gpu.rs @@ -1,5 +1,5 @@ use std::sync::Mutex; -use ryzenadj_rs::RyzenAccess; +use libryzenadj::RyzenAdj; use crate::persist::GpuJson; use crate::settings::MinMax; @@ -7,8 +7,8 @@ use crate::settings::generic::Gpu as GenericGpu; use crate::settings::{OnResume, OnSet, SettingError, SettingVariant}; use crate::settings::TGpu; -fn ryzen_adj_or_log() -> Option> { - match RyzenAccess::new() { +fn ryzen_adj_or_log() -> Option> { + match RyzenAdj::new() { Ok(x) => Some(Mutex::new(x)), Err(e) => { log::error!("RyzenAdj init error: {}", e); @@ -17,13 +17,24 @@ fn ryzen_adj_or_log() -> Option> { } } -#[derive(Debug)] +unsafe impl Send for Gpu {} // implementor (RyzenAdj) may be unsafe + +//#[derive(Debug)] pub struct Gpu { generic: GenericGpu, - implementor: Option>, + implementor: Option>, state: crate::state::generic::Gpu, // NOTE this is re-used for simplicity } +impl std::fmt::Debug for Gpu { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Gpu") + .field("generic", &self.generic) + .field("state", &self.state) + .finish_non_exhaustive() + } +} + impl Gpu { pub fn from_limits(limits: limits_core::json::GenericGpuLimit) -> Self { Self { @@ -63,7 +74,15 @@ impl Gpu { let mut errors = Vec::new(); if let Some(fast_ppt) = &self.generic.fast_ppt { if self.state.old_fast_ppt.is_none() { - self.state.old_fast_ppt = Some(lock.get_fast_value() as _); + match lock.get_fast_value() { + Ok(val) => self.state.old_fast_ppt = Some(val as _), + Err(e) => errors.push( + SettingError { + msg: format!("RyzenAdj get_fast_value() err: {}", e), + setting: SettingVariant::Gpu, + } + ) + } } lock.set_fast_limit(*fast_ppt as _).map_err(|e| SettingError { msg: format!("RyzenAdj set_fast_limit({}) err: {}", *fast_ppt, e), @@ -78,7 +97,15 @@ impl Gpu { } if let Some(slow_ppt) = &self.generic.slow_ppt { if self.state.old_slow_ppt.is_none() { - self.state.old_slow_ppt = Some(lock.get_slow_value() as _); + match lock.get_slow_value() { + Ok(val) => self.state.old_fast_ppt = Some(val as _), + Err(e) => errors.push( + SettingError { + msg: format!("RyzenAdj get_slow_value() err: {}", e), + setting: SettingVariant::Gpu, + } + ) + } } lock.set_slow_limit(*slow_ppt as _).map_err(|e| SettingError { msg: format!("RyzenAdj set_slow_limit({}) err: {}", *slow_ppt, e), diff --git a/backend/src/settings/steam_deck/battery.rs b/backend/src/settings/steam_deck/battery.rs index e4c9574..532e56a 100644 --- a/backend/src/settings/steam_deck/battery.rs +++ b/backend/src/settings/steam_deck/battery.rs @@ -20,9 +20,9 @@ const BATTERY_VOLTAGE: f64 = 7.7; const BATTERY_CHARGE_RATE_PATH: &str = "/sys/class/hwmon/hwmon5/maximum_battery_charge_rate"; // write-only const BATTERY_CURRENT_NOW_PATH: &str = "/sys/class/power_supply/BAT1/current_now"; // read-only -const BATTERY_CHARGE_NOW_PATH: &str = "/sys/class/hwmon/hwmon2/device/charge_now"; // read-only -const BATTERY_CHARGE_FULL_PATH: &str = "/sys/class/hwmon/hwmon2/device/charge_full"; // read-only -const BATTERY_CHARGE_DESIGN_PATH: &str = "/sys/class/hwmon/hwmon2/device/charge_full_design"; // read-only +const BATTERY_CHARGE_NOW_PATH: &str = "/sys/class/power_supply/BAT1/charge_now"; // read-only +const BATTERY_CHARGE_FULL_PATH: &str = "/sys/class/power_supply/BAT1/charge_full"; // read-only +const BATTERY_CHARGE_DESIGN_PATH: &str = "/sys/class/power_supply/BAT1/charge_full_design"; // read-only impl Battery { #[inline] diff --git a/backend/src/state/steam_deck/cpu.rs b/backend/src/state/steam_deck/cpu.rs index 54b423f..d16ab15 100644 --- a/backend/src/state/steam_deck/cpu.rs +++ b/backend/src/state/steam_deck/cpu.rs @@ -8,7 +8,7 @@ pub struct Cpu { impl std::default::Default for Cpu { fn default() -> Self { Self { - clock_limits_set: false, + clock_limits_set: true, is_resuming: false, do_set_online: true, } diff --git a/backend/src/state/steam_deck/gpu.rs b/backend/src/state/steam_deck/gpu.rs index fd3e6de..3091f70 100644 --- a/backend/src/state/steam_deck/gpu.rs +++ b/backend/src/state/steam_deck/gpu.rs @@ -7,7 +7,7 @@ pub struct Gpu { impl std::default::Default for Gpu { fn default() -> Self { Self { - clock_limits_set: false, + clock_limits_set: true, is_resuming: false, } } diff --git a/package.json b/package.json index deb4dbd..0949532 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "PowerTools", - "version": "1.2.0-beta4", + "version": "1.3.0-alpha", "description": "Power tweaks for power users", "scripts": { "build": "shx rm -rf dist && rollup -c", diff --git a/src/backend.ts b/src/backend.ts index 0d7da44..669519c 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -272,3 +272,7 @@ export async function log(level: LogLevel, msg: string): Promise { export async function idk(): Promise { return (await call_backend("GENERAL_idk", []))[0]; } + +export async function forceApplySettings(): Promise { + return (await call_backend("GENERAL_apply_now", []))[0]; +} diff --git a/src/index.tsx b/src/index.tsx index 6606435..09f9cfe 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -264,6 +264,18 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({}) => { + + { + backend.log(backend.LogLevel.Debug, "Reapplying PowerTools settings"); + backend.forceApplySettings(); + }} + > + {tr("Reapply settings")} + + +