From b1ee449b97a03d14cdd204c7edc7ba8870230261 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Fri, 9 Dec 2022 10:03:45 +1300 Subject: [PATCH] Adjust profile task to help TUF laptops notify --- .gitignore | 1 + CHANGELOG.md | 5 +++- Cargo.lock | 40 +++++++++++++++++-------- Cargo.toml | 2 +- daemon/src/ctrl_profiles/trait_impls.rs | 36 ++++++++++++++++++++-- rog-control-center/Cargo.toml | 3 +- rog-profiles/src/lib.rs | 8 +++++ 7 files changed, 76 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 06c82ba2..047fdb52 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ vendor.tar.xz cargo-config .idea +vendor vendor-* vendor_* .vscode-ctags diff --git a/CHANGELOG.md b/CHANGELOG.md index c4a76949..c220b921 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -## [v4.5.6-RC1] +## [v4.5.6-RC2] +### Changed - Fix tasks not always running correctly on boot/sleep/wake/shutdown by finishing the move to async +- Change how the profile/fan change task monitors changes due to TUF laptops behaving slightly different ## [v4.5.5] +### Changed - remove an unwrap() causing panic on main ROGCC thread ## [v4.5.4] diff --git a/Cargo.lock b/Cargo.lock index 7277920f..c43e842e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -930,10 +930,20 @@ dependencies = [ "wio", ] +[[package]] +name = "ecolor" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b601108bca3af7650440ace4ca55b2daf52c36f2635be3587d77b16efd8d0691" +dependencies = [ + "bytemuck", +] + [[package]] name = "eframe" -version = "0.19.0" -source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8128828b785ecf1552917330354ab2eb9d2c48fbe2ad075fa75f93d4a099a9f1" dependencies = [ "bytemuck", "egui", @@ -953,8 +963,9 @@ dependencies = [ [[package]] name = "egui" -version = "0.19.0" -source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a4daecd807bfd4e30ad92f049b03d92f506a3fddfad852babaa03cba180adfa" dependencies = [ "accesskit", "ahash", @@ -965,8 +976,9 @@ dependencies = [ [[package]] name = "egui-winit" -version = "0.19.0" -source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2217c2c1e63b7b793753efd23dc68efb86bb09bd298e5de8010e9a82dc63f0a9" dependencies = [ "accesskit_winit", "arboard", @@ -980,8 +992,9 @@ dependencies = [ [[package]] name = "egui_glow" -version = "0.19.0" -source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67655a7138ce9d9617811622a3d81577fb477f4447f1a330e89814f16ad35574" dependencies = [ "bytemuck", "egui", @@ -994,8 +1007,9 @@ dependencies = [ [[package]] name = "emath" -version = "0.19.0" -source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5277249c8c3430e7127e4f2c40a77485e7baf11ae132ce9b3253a8ed710df0a0" dependencies = [ "bytemuck", ] @@ -1080,13 +1094,15 @@ dependencies = [ [[package]] name = "epaint" -version = "0.19.0" -source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de14b65fe5e423e0058f77a8beb2c863b056d0566d6c4ce0d097aa5814cb705a" dependencies = [ "ab_glyph", "ahash", "atomic_refcell", "bytemuck", + "ecolor", "emath", "nohash-hasher", "parking_lot", diff --git a/Cargo.toml b/Cargo.toml index 9ff25330..48baf92e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ members = ["asusctl", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"] [workspace.package] -version = "4.5.6-RC1" +version = "4.5.6-RC2" [workspace.dependencies] async-trait = "^0.1" diff --git a/daemon/src/ctrl_profiles/trait_impls.rs b/daemon/src/ctrl_profiles/trait_impls.rs index 2e083c0b..6451bb9b 100644 --- a/daemon/src/ctrl_profiles/trait_impls.rs +++ b/daemon/src/ctrl_profiles/trait_impls.rs @@ -200,8 +200,36 @@ impl CtrlTask for ProfileZbus { } async fn create_tasks(&self, signal_ctxt: SignalContext<'static>) -> Result<(), RogError> { + // let ctrl = self.0.clone(); + // let mut watch = self.0.lock().await.platform.monitor_platform_profile()?; + // let sig_ctx = signal_ctxt.clone(); + // tokio::spawn(async move { + // let mut buffer = [0; 32]; + // watch + // .event_stream(&mut buffer) + // .unwrap() + // .for_each(|_| async { + // let mut lock = ctrl.lock().await; + // let new_profile = Profile::get_active_profile().unwrap(); + // if new_profile != lock.config.active_profile { + // lock.config.active_profile = new_profile; + // lock.write_profile_curve_to_platform().unwrap(); + // lock.save_config(); + // } + // Self::notify_profile(&sig_ctx, lock.config.active_profile) + // .await + // .ok(); + // }) + // .await; + // }); + let ctrl = self.0.clone(); - let mut watch = self.0.lock().await.platform.monitor_platform_profile()?; + let mut watch = self + .0 + .lock() + .await + .platform + .monitor_throttle_thermal_policy()?; tokio::spawn(async move { let mut buffer = [0; 32]; @@ -210,13 +238,15 @@ impl CtrlTask for ProfileZbus { .unwrap() .for_each(|_| async { let mut lock = ctrl.lock().await; - let new_profile = Profile::get_active_profile().unwrap(); + let new_thermal = lock.platform.get_throttle_thermal_policy().unwrap(); + let new_profile = Profile::from_throttle_thermal_policy(new_thermal); if new_profile != lock.config.active_profile { lock.config.active_profile = new_profile; lock.write_profile_curve_to_platform().unwrap(); lock.save_config(); + Profile::set_profile(lock.config.active_profile).unwrap(); } - Self::notify_profile(&signal_ctxt.clone(), lock.config.active_profile) + Self::notify_profile(&signal_ctxt, lock.config.active_profile) .await .ok(); }) diff --git a/rog-control-center/Cargo.toml b/rog-control-center/Cargo.toml index fed90f6b..c9fff538 100644 --- a/rog-control-center/Cargo.toml +++ b/rog-control-center/Cargo.toml @@ -10,7 +10,7 @@ mocking = [] [dependencies] egui = { git = "https://github.com/flukejones/egui", branch = "wayland_dark_theme" } -eframe= { git = "https://github.com/flukejones/egui", branch = "wayland_dark_theme" } +eframe = { git = "https://github.com/flukejones/egui", branch = "wayland_dark_theme" } libappindicator = "0.7" # Tray icon gtk = "0.15.5" @@ -22,7 +22,6 @@ rog_aura = { path = "../rog-aura" } rog_profiles = { path = "../rog-profiles" } rog_platform = { path = "../rog-platform" } supergfxctl = { git = "https://gitlab.com/asus-linux/supergfxctl.git", default-features = false } -#supergfxctl = { path = "../../supergfxctl", default-features = false } log.workspace = true env_logger.workspace = true diff --git a/rog-profiles/src/lib.rs b/rog-profiles/src/lib.rs index f1105782..00667c74 100644 --- a/rog-profiles/src/lib.rs +++ b/rog-profiles/src/lib.rs @@ -72,6 +72,14 @@ impl Profile { file.write_all(<&str>::from(profile).as_bytes())?; Ok(()) } + + pub fn from_throttle_thermal_policy(num: u8) -> Self { + match num { + 1 => Self::Performance, + 2 => Self::Quiet, + _ => Self::Balanced, + } + } } impl Default for Profile {