- Spawn tasks on individual threads
- Don't force a default of fan-curve on reload
- Add missing profile commands
- Begin obsoleting the graphics switch command in favour of supergfxctl
- Slim down the notification daemon to pure ASUS notifications

Bad behaviour in fan-curve new function that was forcing a re-init
to default on reload. Remove this and only save config again after
loading the config file and writing a curve (hidden side effect of
write is that a zeroed array is defaulted to read-from-system - this
needs to be changed too).

Closes #140, #139
This commit is contained in:
Luke D. Jones
2021-09-21 23:10:20 +12:00
parent 7d47faba0e
commit 3aa6eee306
16 changed files with 164 additions and 355 deletions

View File

@@ -56,7 +56,10 @@ impl crate::Reloadable for CtrlPlatformProfile {
fn reload(&mut self) -> Result<(), RogError> {
if let Some(curves) = &mut self.config.fan_curves {
if let Ok(mut device) = FanCurveProfiles::get_device() {
// There is a possibility that the curve was default zeroed, so this call initialises
// the data from system read and we need to save it after
curves.write_profile_curve_to_platform(self.config.active_profile, &mut device)?;
self.config.write();
}
}
Ok(())
@@ -64,17 +67,13 @@ impl crate::Reloadable for CtrlPlatformProfile {
}
impl CtrlPlatformProfile {
pub fn new(mut config: ProfileConfig) -> Result<Self, RogError> {
pub fn new(config: ProfileConfig) -> Result<Self, RogError> {
if Profile::is_platform_profile_supported() {
info!("Device has profile control available");
if let Ok(ref device) = FanCurveProfiles::get_device() {
let profile = config.active_profile;
if let Some(curve) = config.fan_curves.as_mut() {
curve.read_from_dev_profile(profile, device);
}
if FanCurveProfiles::get_device().is_ok() {
info!("Device has fan curves available");
}
config.write();
return Ok(CtrlPlatformProfile { config });
}
@@ -143,6 +142,7 @@ impl CtrlTask for CtrlProfileTask {
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()?;
lock.save_config();
}
}

View File

@@ -94,7 +94,7 @@ impl ProfileZbus {
fn set_fan_curve_enabled(&mut self, profile: Profile, enabled: bool) -> zbus::fdo::Result<()> {
if let Ok(mut ctrl) = self.inner.try_lock() {
ctrl.config.read();
if let Some(curves) = &mut ctrl.config.fan_curves {
return if let Some(curves) = &mut ctrl.config.fan_curves {
curves.set_profile_curve_enabled(profile, enabled);
ctrl.write_profile_curve_to_platform()
@@ -102,10 +102,10 @@ impl ProfileZbus {
.ok();
ctrl.save_config();
return Ok(());
Ok(())
} else {
return Err(Error::Failed(UNSUPPORTED_MSG.to_string()));
}
Err(Error::Failed(UNSUPPORTED_MSG.to_string()))
};
}
Err(Error::Failed(
"Failed to get enabled fan curve names".to_string(),