mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Fleshing out functions and zbus controls
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use log::warn;
|
||||
use rog_profiles::fan_curves::CurveData;
|
||||
use rog_profiles::fan_curves::FanCurveSet;
|
||||
use rog_profiles::Profile;
|
||||
|
||||
@@ -47,7 +48,7 @@ impl ProfileZbus {
|
||||
fn active_profile(&mut self) -> zbus::fdo::Result<Profile> {
|
||||
if let Ok(mut ctrl) = self.inner.try_lock() {
|
||||
ctrl.config.read();
|
||||
return Ok(ctrl.config.active);
|
||||
return Ok(ctrl.config.active_profile);
|
||||
}
|
||||
Err(Error::Failed(
|
||||
"Failed to get active profile name".to_string(),
|
||||
@@ -62,7 +63,7 @@ impl ProfileZbus {
|
||||
Profile::set_profile(profile)
|
||||
.map_err(|e| warn!("Profile::set_profile, {}", e))
|
||||
.ok();
|
||||
ctrl.config.active = profile;
|
||||
ctrl.config.active_profile = profile;
|
||||
|
||||
ctrl.save_config();
|
||||
}
|
||||
@@ -74,7 +75,21 @@ impl ProfileZbus {
|
||||
if let Ok(mut ctrl) = self.inner.try_lock() {
|
||||
ctrl.config.read();
|
||||
if let Some(curves) = &ctrl.config.fan_curves {
|
||||
return Ok(curves.get_enabled_curve_names().to_vec());
|
||||
return Ok(curves.get_enabled_curve_profiles().to_vec());
|
||||
}
|
||||
return Err(Error::Failed(UNSUPPORTED_MSG.to_string()));
|
||||
}
|
||||
Err(Error::Failed(
|
||||
"Failed to get enabled fan curve names".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
/// Get a list of profiles that have fan-curves enabled.
|
||||
fn set_enabled_fan_profiles(&mut self, profiles: Vec<Profile>) -> zbus::fdo::Result<()> {
|
||||
if let Ok(mut ctrl) = self.inner.try_lock() {
|
||||
ctrl.config.read();
|
||||
if let Some(curves) = &mut ctrl.config.fan_curves {
|
||||
curves.set_enabled_curve_profiles(profiles);
|
||||
}
|
||||
return Err(Error::Failed(UNSUPPORTED_MSG.to_string()));
|
||||
}
|
||||
@@ -108,12 +123,13 @@ impl ProfileZbus {
|
||||
}
|
||||
|
||||
/// Set this fan-curve data
|
||||
fn set_fan_curve(&self, curve: FanCurveSet) -> zbus::fdo::Result<()> {
|
||||
fn set_fan_curve(&self, curve: CurveData) -> zbus::fdo::Result<()> {
|
||||
if let Ok(mut ctrl) = self.inner.try_lock() {
|
||||
ctrl.config.read();
|
||||
let profile = ctrl.config.active_profile;
|
||||
if let Some(mut device) = ctrl.get_device() {
|
||||
if let Some(curves) = &mut ctrl.config.fan_curves {
|
||||
curves.set_fan_curve(curve, &mut device);
|
||||
curves.write_and_set_fan_curve(curve, profile, &mut device);
|
||||
}
|
||||
} else {
|
||||
return Err(Error::Failed(UNSUPPORTED_MSG.to_string()));
|
||||
@@ -132,7 +148,7 @@ impl ProfileZbus {
|
||||
impl ProfileZbus {
|
||||
fn do_notification(&self) {
|
||||
if let Ok(ctrl) = self.inner.try_lock() {
|
||||
self.notify_profile(&ctrl.config.active)
|
||||
self.notify_profile(&ctrl.config.active_profile)
|
||||
.unwrap_or_else(|err| warn!("{}", err));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user