mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
Fix: prevent multiple notifications from profile change
This commit is contained in:
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Move FX506LH to FX506L in arua DB to catch full series of this range
|
||||
- Remove notification handle tracking limit, fixes KDE issue with profile notif
|
||||
- Rename daemon and daemon-user crates to asusd and asusd-user to not be confusing in workspace naming
|
||||
- Prevent the multiple notifications from a profile change from occuring (too many functions with side effects!)
|
||||
### BREAKING
|
||||
- All Anime related DBUS methods/notifs are changed
|
||||
|
||||
|
||||
@@ -101,7 +101,13 @@ impl CtrlPlatformProfile {
|
||||
// For each profile we need to switch to it before we
|
||||
// can read the existing values from hardware. The ACPI method used
|
||||
// for this is what limits us.
|
||||
controller.set_next_profile()?;
|
||||
let next =
|
||||
Profile::get_next_profile(controller.profile_config.active_profile);
|
||||
Profile::set_profile(next)
|
||||
.map_err(|e| warn!("{MOD_NAME}: set_profile, {}", e))
|
||||
.ok();
|
||||
controller.profile_config.active_profile = next;
|
||||
|
||||
// Make sure to set the baseline to default
|
||||
controller.set_active_curve_to_defaults()?;
|
||||
let active = Profile::get_active_profile().unwrap_or(Profile::Balanced);
|
||||
@@ -141,28 +147,6 @@ impl CtrlPlatformProfile {
|
||||
}
|
||||
}
|
||||
|
||||
/// Toggle to next profile in list. This will first read the config, switch,
|
||||
/// then write out
|
||||
pub(super) fn set_next_profile(&mut self) -> Result<(), RogError> {
|
||||
// Read first just incase the user has modified the config before calling this
|
||||
match self.profile_config.active_profile {
|
||||
Profile::Balanced => {
|
||||
Profile::set_profile(Profile::Performance)?;
|
||||
self.profile_config.active_profile = Profile::Performance;
|
||||
}
|
||||
Profile::Performance => {
|
||||
Profile::set_profile(Profile::Quiet)?;
|
||||
self.profile_config.active_profile = Profile::Quiet;
|
||||
}
|
||||
Profile::Quiet => {
|
||||
Profile::set_profile(Profile::Balanced)?;
|
||||
self.profile_config.active_profile = Profile::Balanced;
|
||||
}
|
||||
}
|
||||
self.write_profile_curve_to_platform()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the curve for the active profile active
|
||||
pub(super) fn write_profile_curve_to_platform(&mut self) -> Result<(), RogError> {
|
||||
if let Some(curves) = &mut self.fan_curves {
|
||||
|
||||
@@ -40,8 +40,11 @@ impl ProfileZbus {
|
||||
/// If fan-curves are supported will also activate a fan curve for profile.
|
||||
async fn next_profile(&mut self, #[zbus(signal_context)] ctxt: SignalContext<'_>) {
|
||||
let mut ctrl = self.0.lock().await;
|
||||
ctrl.set_next_profile()
|
||||
.unwrap_or_else(|err| warn!("{MOD_NAME}: {}", err));
|
||||
let next = Profile::get_next_profile(ctrl.profile_config.active_profile);
|
||||
Profile::set_profile(next)
|
||||
.map_err(|e| warn!("{MOD_NAME}: set_profile, {}", e))
|
||||
.ok();
|
||||
ctrl.profile_config.active_profile = next;
|
||||
ctrl.save_config();
|
||||
|
||||
Self::notify_profile(&ctxt, ctrl.profile_config.active_profile)
|
||||
@@ -236,10 +239,11 @@ impl CtrlTask for ProfileZbus {
|
||||
error!("Profile::set_profile() error: {e}");
|
||||
})
|
||||
.ok();
|
||||
|
||||
Self::notify_profile(&sig_ctx, lock.profile_config.active_profile)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
Self::notify_profile(&sig_ctx, lock.profile_config.active_profile)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
})
|
||||
.await;
|
||||
@@ -271,13 +275,14 @@ impl CtrlTask for ProfileZbus {
|
||||
error!("Profile::set_profile() error: {e}");
|
||||
})
|
||||
.ok();
|
||||
|
||||
Self::notify_profile(
|
||||
&signal_ctxt,
|
||||
lock.profile_config.active_profile,
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
Self::notify_profile(
|
||||
&signal_ctxt,
|
||||
lock.profile_config.active_profile,
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -71,6 +71,15 @@ impl Profile {
|
||||
_ => Self::Balanced,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_next_profile(current: Profile) -> Profile {
|
||||
// Read first just incase the user has modified the config before calling this
|
||||
match current {
|
||||
Profile::Balanced => Profile::Performance,
|
||||
Profile::Performance => Profile::Quiet,
|
||||
Profile::Quiet => Profile::Balanced,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Profile {
|
||||
|
||||
Reference in New Issue
Block a user