Fan curve enablement

- Add CtrlProfileTask
- Add method to reset active profile curve to platform default
- Wrap the zbus methods for profiles + fan curves
- Enable CLI args for fan curves
- CLI mod and save curves
This commit is contained in:
Luke D. Jones
2021-09-13 11:46:22 +12:00
parent 7041d77256
commit ab195e1d84
22 changed files with 783 additions and 328 deletions

View File

@@ -21,7 +21,10 @@
use std::sync::mpsc::Sender;
use rog_profiles::{fan_curve_set::FanCurveSet, Profile};
use rog_profiles::{
fan_curve_set::{CurveData, FanCurveSet},
Profile,
};
use zbus::{dbus_proxy, Connection, Result};
#[dbus_proxy(
@@ -29,29 +32,37 @@ use zbus::{dbus_proxy, Connection, Result};
default_path = "/org/asuslinux/Profile"
)]
trait Daemon {
/// Get the active `Profile` data
fn active_fan_curve_data(&self) -> zbus::Result<FanCurveSet>;
/// Get the fan-curve data for the currently active Profile
fn fan_curve_data(&self, profile: Profile) -> zbus::Result<FanCurveSet>;
/// Profile, get the active profile
/// Fetch the active profile name
fn active_profile(&self) -> zbus::Result<Profile>;
/// Get enabled fan curves
/// Get a list of profiles that have fan-curves enabled.
fn enabled_fan_profiles(&self) -> zbus::Result<Vec<Profile>>;
/// Get all fan curve data
fn fan_curves(&self) -> zbus::Result<Vec<FanCurveSet>>;
/// NextProfile method
/// Toggle to next platform_profile. Names provided by `Profiles`.
/// If fan-curves are supported will also activate a fan curve for profile.
fn next_profile(&self) -> zbus::Result<()>;
/// Profiles method
/// Fetch profile names
fn profiles(&self) -> zbus::Result<Vec<Profile>>;
/// Set the specific profile as active
/// Set this platform_profile name as active
fn set_active_profile(&self, profile: Profile) -> zbus::Result<()>;
/// Set a fan curve. If a field is empty then the exisiting saved curve is used
fn set_fan_curve(&self, curve: FanCurveSet) -> zbus::Result<()>;
/// Set a profile fan curve enabled status. Will also activate a fan curve.
fn set_fan_curve_enabled(&self, profile: Profile, enabled: bool) -> zbus::Result<()>;
/// Set the fan curve for the specified profile, or the profile the user is
/// currently in if profile == None. Will also activate the fan curve.
fn set_fan_curve(&self, profile: Profile, curve: CurveData) -> zbus::Result<()>;
/// Reset the stored (self) and device curve to the defaults of the platform.
///
/// Each platform_profile has a different default and the defualt can be read
/// only for the currently active profile.
fn set_active_curve_to_defaults(&self) -> zbus::Result<()>;
/// NotifyProfile signal
#[dbus_proxy(signal)]
@@ -72,8 +83,18 @@ impl<'a> ProfileProxy<'a> {
}
#[inline]
pub fn profiles(&self) -> Result<Vec<Profile>> {
self.0.profiles()
pub fn active_profile(&self) -> zbus::Result<Profile> {
self.0.active_profile()
}
#[inline]
pub fn enabled_fan_profiles(&self) -> zbus::Result<Vec<Profile>> {
self.0.enabled_fan_profiles()
}
#[inline]
pub fn fan_curve_data(&self, profile: Profile) -> zbus::Result<FanCurveSet> {
self.0.fan_curve_data(profile)
}
#[inline]
@@ -81,6 +102,31 @@ impl<'a> ProfileProxy<'a> {
self.0.next_profile()
}
#[inline]
pub fn profiles(&self) -> Result<Vec<Profile>> {
self.0.profiles()
}
#[inline]
pub fn set_active_profile(&self, profile: Profile) -> zbus::Result<()> {
self.0.set_active_profile(profile)
}
#[inline]
pub fn set_fan_curve_enabled(&self, profile: Profile, enabled: bool) -> zbus::Result<()> {
self.0.set_fan_curve_enabled(profile, enabled)
}
#[inline]
pub fn set_fan_curve(&self, curve: CurveData, profile: Profile) -> zbus::Result<()> {
self.0.set_fan_curve(profile, curve)
}
#[inline]
pub fn set_active_curve_to_defaults(&self) -> zbus::Result<()> {
self.0.set_active_curve_to_defaults()
}
#[inline]
pub fn connect_notify_profile(&self, send: Sender<Profile>) -> zbus::fdo::Result<()> {
self.0.connect_notify_profile(move |data| {