Compare commits

...

3 Commits

Author SHA1 Message Date
Luke D. Jones 36bba75c50 bugfix: fix profile fan modes and creating 2021-05-26 09:24:18 +12:00
Luke Jones b2dc610c0b Merge branch 'fluke/extras' into 'main'
bugfix: fix profile cycling

See merge request asus-linux/asusctl!60
2021-05-25 09:46:26 +00:00
Luke D. Jones 42d0eb0aba bugfix: fix profile cycling 2021-05-25 21:44:01 +12:00
8 changed files with 69 additions and 65 deletions
+10 -1
View File
@@ -6,7 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
# [3.6.0] - 2021-05-15 # [3.6.1] - 2021-05-25
### Changed
- Bugfix: write correct fan modes for profiles
- Bugfix: apply created profiles
# [3.6.1] - 2021-05-25
### Changed
- Bugfix for cycling through profiles
# [3.6.0] - 2021-05-24
### Changed ### Changed
- Add GX550L led modes - Add GX550L led modes
- Don't save compute/vfio modes. Option in config for this is removed. - Don't save compute/vfio modes. Option in config for this is removed.
Generated
+1 -1
View File
@@ -207,7 +207,7 @@ dependencies = [
[[package]] [[package]]
name = "daemon" name = "daemon"
version = "3.6.0" version = "3.6.2"
dependencies = [ dependencies = [
"env_logger", "env_logger",
"log", "log",
+2 -2
View File
@@ -473,8 +473,8 @@ fn handle_profile(
} }
if cmd.profiles_data { if cmd.profiles_data {
println!("Profiles:"); println!("Profiles:");
for s in dbus.proxies().profile().all_profile_data()?.lines() { for s in dbus.proxies().profile().all_profile_data()? {
println!("{}", s); println!("{:?}", s);
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "daemon" name = "daemon"
version = "3.6.0" version = "3.6.2"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
authors = ["Luke <luke@ljones.dev>"] authors = ["Luke <luke@ljones.dev>"]
+34 -32
View File
@@ -43,57 +43,59 @@ impl CtrlFanAndCpu {
} }
/// Toggle to next profile in list /// Toggle to next profile in list
pub(super) fn do_next_profile(&mut self, config: &mut Config) -> Result<(), RogError> { pub(super) fn do_next_profile(&mut self) -> Result<(), RogError> {
config.read(); if let Ok(mut config) = self.config.clone().try_lock() {
config.read();
let mut i = config let mut i = config
.toggle_profiles .toggle_profiles
.iter() .binary_search(&config.active_profile)
.position(|x| x == &config.active_profile) .unwrap_or(0)
.map(|i| i + 1) + 1;
.unwrap_or(0); if i >= config.toggle_profiles.len() {
if i >= config.toggle_profiles.len() { i = 0;
i = 0; }
let profile = config.toggle_profiles[i].clone();
if let Some(existing) = config.power_profiles.get(&profile) {
existing.set_system_all()?;
config.active_profile = existing.name.clone();
config.write();
info!("Profile was changed to: {}", profile);
}
} }
let new_profile = config
.toggle_profiles
.get(i)
.unwrap_or(&config.active_profile)
.clone();
self.set_active(&new_profile)?;
info!("Profile was changed: {}", &new_profile);
Ok(()) Ok(())
} }
pub(super) fn set_active(&mut self, profile: &str) -> Result<(), RogError> { pub(super) fn set_active(&mut self, profile: &str) -> Result<(), RogError> {
if let Ok(mut cfg) = self.config.clone().try_lock() { if let Ok(mut config) = self.config.clone().try_lock() {
cfg.read(); config.read();
if let Some(existing) = config.power_profiles.get(profile) {
if let Some(existing) = cfg.power_profiles.get_mut(profile) {
existing.set_system_all()?; existing.set_system_all()?;
cfg.active_profile = existing.name.clone(); config.active_profile = existing.name.clone();
cfg.write(); config.write();
info!("Profile was changed to: {}", profile);
} }
} }
Ok(()) Ok(())
} }
pub(super) fn new_or_modify(&mut self, profile: &Profile) -> Result<(), RogError> { pub(super) fn new_or_modify(&mut self, profile: &Profile) -> Result<(), RogError> {
if let Ok(mut cfg) = self.config.clone().try_lock() { if let Ok(mut config) = self.config.clone().try_lock() {
cfg.read(); config.read();
if let Some(existing) = cfg.power_profiles.get_mut(&profile.name) { if let Some(existing) = config.power_profiles.get_mut(&profile.name) {
*existing = profile.clone(); *existing = profile.clone();
existing.set_system_all()?; existing.set_system_all()?;
} else { } else {
cfg.power_profiles config.power_profiles
.insert(profile.name.clone(), profile.clone()); .insert(profile.name.clone(), profile.clone());
profile.set_system_all()?;
} }
cfg.active_profile = profile.name.clone();
cfg.write(); config.active_profile = profile.name.clone();
config.write();
} }
Ok(()) Ok(())
} }
+18 -25
View File
@@ -25,15 +25,8 @@ impl FanAndCpuZbus {
if let Ok(mut ctrl) = self.inner.try_lock() { if let Ok(mut ctrl) = self.inner.try_lock() {
ctrl.set_active(&profile) ctrl.set_active(&profile)
.unwrap_or_else(|err| warn!("{}", err)); .unwrap_or_else(|err| warn!("{}", err));
// Do notification
if let Ok(cfg) = ctrl.config.clone().try_lock() {
// Do notify
if let Some(profile) = cfg.power_profiles.get(&cfg.active_profile) {
self.notify_profile(&profile)
.unwrap_or_else(|err| warn!("{}", err));
}
}
} }
self.do_notification();
} }
/// New or modify profile details and make active, will create if it does not exist /// New or modify profile details and make active, will create if it does not exist
@@ -41,30 +34,17 @@ impl FanAndCpuZbus {
if let Ok(mut ctrl) = self.inner.try_lock() { if let Ok(mut ctrl) = self.inner.try_lock() {
ctrl.new_or_modify(&profile) ctrl.new_or_modify(&profile)
.unwrap_or_else(|err| warn!("{}", err)); .unwrap_or_else(|err| warn!("{}", err));
// Do notification
if let Ok(cfg) = ctrl.config.clone().try_lock() {
// Do notify
if let Some(profile) = cfg.power_profiles.get(&cfg.active_profile) {
self.notify_profile(&profile)
.unwrap_or_else(|err| warn!("{}", err));
}
}
} }
self.do_notification();
} }
/// Fetch the active profile name /// Fetch the active profile name
fn next_profile(&mut self) { fn next_profile(&mut self) {
if let Ok(mut ctrl) = self.inner.try_lock() { if let Ok(mut ctrl) = self.inner.try_lock() {
if let Ok(mut cfg) = ctrl.config.clone().try_lock() { ctrl.do_next_profile()
cfg.read(); .unwrap_or_else(|err| warn!("{}", err));
ctrl.do_next_profile(&mut cfg)
.unwrap_or_else(|err| warn!("{}", err));
if let Some(profile) = cfg.power_profiles.get(&cfg.active_profile) {
self.notify_profile(&profile)
.unwrap_or_else(|err| warn!("{}", err));
}
}
} }
self.do_notification();
} }
/// Fetch the active profile name /// Fetch the active profile name
@@ -154,6 +134,19 @@ impl FanAndCpuZbus {
fn notify_profile(&self, profile: &Profile) -> zbus::Result<()> {} fn notify_profile(&self, profile: &Profile) -> zbus::Result<()> {}
} }
impl FanAndCpuZbus {
fn do_notification(&self) {
if let Ok(ctrl) = self.inner.try_lock() {
if let Ok(cfg) = ctrl.config.clone().try_lock() {
if let Some(profile) = cfg.power_profiles.get(&cfg.active_profile) {
self.notify_profile(&profile)
.unwrap_or_else(|err| warn!("{}", err));
}
}
}
}
}
impl crate::ZbusAdd for FanAndCpuZbus { impl crate::ZbusAdd for FanAndCpuZbus {
fn add_to_server(self, server: &mut zbus::ObjectServer) { fn add_to_server(self, server: &mut zbus::ObjectServer) {
server server
+2 -2
View File
@@ -39,7 +39,7 @@ trait Daemon {
fn active_data(&self) -> zbus::Result<Profile>; fn active_data(&self) -> zbus::Result<Profile>;
/// Profiles method /// Profiles method
fn profiles(&self) -> zbus::Result<String>; fn profiles(&self) -> zbus::Result<Vec<Profile>>;
/// ProfileNames method /// ProfileNames method
fn profile_names(&self) -> zbus::Result<Vec<String>>; fn profile_names(&self) -> zbus::Result<Vec<String>>;
@@ -78,7 +78,7 @@ impl<'a> ProfileProxy<'a> {
} }
#[inline] #[inline]
pub fn all_profile_data(&self) -> Result<String> { pub fn all_profile_data(&self) -> Result<Vec<Profile>> {
self.0.profiles() self.0.profiles()
} }
+1 -1
View File
@@ -112,7 +112,7 @@ impl Profile {
pub fn set_system_all(&self) -> Result<(), ProfileError> { pub fn set_system_all(&self) -> Result<(), ProfileError> {
self.set_system_pstate()?; self.set_system_pstate()?;
if !self.fan_curve.is_empty() { if self.fan_curve.is_empty() {
self.set_system_fan_mode()?; self.set_system_fan_mode()?;
} else { } else {
self.set_system_fan_curve()?; self.set_system_fan_curve()?;