Adjust profile task to help TUF laptops notify

This commit is contained in:
Luke D. Jones
2022-12-09 10:03:45 +13:00
parent 245c035dc9
commit b1ee449b97
7 changed files with 76 additions and 19 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@
vendor.tar.xz vendor.tar.xz
cargo-config cargo-config
.idea .idea
vendor
vendor-* vendor-*
vendor_* vendor_*
.vscode-ctags .vscode-ctags

View File

@@ -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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [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 - 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] ## [v4.5.5]
### Changed
- remove an unwrap() causing panic on main ROGCC thread - remove an unwrap() causing panic on main ROGCC thread
## [v4.5.4] ## [v4.5.4]

40
Cargo.lock generated
View File

@@ -930,10 +930,20 @@ dependencies = [
"wio", "wio",
] ]
[[package]]
name = "ecolor"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b601108bca3af7650440ace4ca55b2daf52c36f2635be3587d77b16efd8d0691"
dependencies = [
"bytemuck",
]
[[package]] [[package]]
name = "eframe" name = "eframe"
version = "0.19.0" version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8128828b785ecf1552917330354ab2eb9d2c48fbe2ad075fa75f93d4a099a9f1"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"egui", "egui",
@@ -953,8 +963,9 @@ dependencies = [
[[package]] [[package]]
name = "egui" name = "egui"
version = "0.19.0" version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a4daecd807bfd4e30ad92f049b03d92f506a3fddfad852babaa03cba180adfa"
dependencies = [ dependencies = [
"accesskit", "accesskit",
"ahash", "ahash",
@@ -965,8 +976,9 @@ dependencies = [
[[package]] [[package]]
name = "egui-winit" name = "egui-winit"
version = "0.19.0" version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2217c2c1e63b7b793753efd23dc68efb86bb09bd298e5de8010e9a82dc63f0a9"
dependencies = [ dependencies = [
"accesskit_winit", "accesskit_winit",
"arboard", "arboard",
@@ -980,8 +992,9 @@ dependencies = [
[[package]] [[package]]
name = "egui_glow" name = "egui_glow"
version = "0.19.0" version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67655a7138ce9d9617811622a3d81577fb477f4447f1a330e89814f16ad35574"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"egui", "egui",
@@ -994,8 +1007,9 @@ dependencies = [
[[package]] [[package]]
name = "emath" name = "emath"
version = "0.19.0" version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5277249c8c3430e7127e4f2c40a77485e7baf11ae132ce9b3253a8ed710df0a0"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
] ]
@@ -1080,13 +1094,15 @@ dependencies = [
[[package]] [[package]]
name = "epaint" name = "epaint"
version = "0.19.0" version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de14b65fe5e423e0058f77a8beb2c863b056d0566d6c4ce0d097aa5814cb705a"
dependencies = [ dependencies = [
"ab_glyph", "ab_glyph",
"ahash", "ahash",
"atomic_refcell", "atomic_refcell",
"bytemuck", "bytemuck",
"ecolor",
"emath", "emath",
"nohash-hasher", "nohash-hasher",
"parking_lot", "parking_lot",

View File

@@ -2,7 +2,7 @@
members = ["asusctl", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"] members = ["asusctl", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"]
[workspace.package] [workspace.package]
version = "4.5.6-RC1" version = "4.5.6-RC2"
[workspace.dependencies] [workspace.dependencies]
async-trait = "^0.1" async-trait = "^0.1"

View File

@@ -200,8 +200,36 @@ impl CtrlTask for ProfileZbus {
} }
async fn create_tasks(&self, signal_ctxt: SignalContext<'static>) -> Result<(), RogError> { 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 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 { tokio::spawn(async move {
let mut buffer = [0; 32]; let mut buffer = [0; 32];
@@ -210,13 +238,15 @@ impl CtrlTask for ProfileZbus {
.unwrap() .unwrap()
.for_each(|_| async { .for_each(|_| async {
let mut lock = ctrl.lock().await; 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 { if new_profile != lock.config.active_profile {
lock.config.active_profile = new_profile; lock.config.active_profile = new_profile;
lock.write_profile_curve_to_platform().unwrap(); lock.write_profile_curve_to_platform().unwrap();
lock.save_config(); 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 .await
.ok(); .ok();
}) })

View File

@@ -10,7 +10,7 @@ mocking = []
[dependencies] [dependencies]
egui = { git = "https://github.com/flukejones/egui", branch = "wayland_dark_theme" } 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 libappindicator = "0.7" # Tray icon
gtk = "0.15.5" gtk = "0.15.5"
@@ -22,7 +22,6 @@ rog_aura = { path = "../rog-aura" }
rog_profiles = { path = "../rog-profiles" } rog_profiles = { path = "../rog-profiles" }
rog_platform = { path = "../rog-platform" } rog_platform = { path = "../rog-platform" }
supergfxctl = { git = "https://gitlab.com/asus-linux/supergfxctl.git", default-features = false } supergfxctl = { git = "https://gitlab.com/asus-linux/supergfxctl.git", default-features = false }
#supergfxctl = { path = "../../supergfxctl", default-features = false }
log.workspace = true log.workspace = true
env_logger.workspace = true env_logger.workspace = true

View File

@@ -72,6 +72,14 @@ impl Profile {
file.write_all(<&str>::from(profile).as_bytes())?; file.write_all(<&str>::from(profile).as_bytes())?;
Ok(()) Ok(())
} }
pub fn from_throttle_thermal_policy(num: u8) -> Self {
match num {
1 => Self::Performance,
2 => Self::Quiet,
_ => Self::Balanced,
}
}
} }
impl Default for Profile { impl Default for Profile {