Fix: Further refine the CLI for fan curve control

Should close #385
This commit is contained in:
Luke D. Jones
2023-08-01 19:30:33 +12:00
parent 2cce83d164
commit 11483b28a6
5 changed files with 40 additions and 13 deletions

View File

@@ -678,10 +678,13 @@ fn handle_fan_curve(
return Ok(());
}
if (cmd.enabled.is_some() || cmd.fan.is_some() || cmd.data.is_some())
if (cmd.enable_fan_curves.is_some() || cmd.fan.is_some() || cmd.data.is_some())
&& cmd.mod_profile.is_none()
{
println!("--enabled, --fan, and --data options require --mod-profile");
println!(
"--enable-fan-curves, --enable-fan-curve, --fan, and --data options require \
--mod-profile"
);
return Ok(());
}
@@ -698,18 +701,31 @@ fn handle_fan_curve(
}
if let Some(profile) = cmd.mod_profile {
if cmd.enabled.is_none() && cmd.data.is_none() {
if cmd.enable_fan_curves.is_none() && cmd.data.is_none() {
let data = dbus.proxies().profile().fan_curve_data(profile)?;
let data = toml::to_string(&data)?;
println!("\nFan curves for {:?}\n\n{}", profile, data);
}
if let Some(enabled) = cmd.enabled {
if let Some(enabled) = cmd.enable_fan_curves {
dbus.proxies()
.profile()
.set_fan_curves_enabled(profile, enabled)?;
}
if let Some(enabled) = cmd.enable_fan_curve {
if let Some(fan) = cmd.fan {
dbus.proxies()
.profile()
.set_profile_fan_curve_enabled(profile, fan, enabled)?;
} else {
println!(
"--enable-fan-curves, --enable-fan-curve, --fan, and --data options require \
--mod-profile"
);
}
}
if let Some(mut curve) = cmd.data.clone() {
let fan = cmd.fan.unwrap_or_default();
curve.set_fan(fan);

View File

@@ -39,20 +39,28 @@ pub struct FanCurveCommand {
#[options(
meta = "",
help = "enable or disable <true/false> fan curve. `mod_profile` required"
help = "enable or disable <true/false> fan all curves for a profile. `--mod_profile` \
required"
)]
pub enabled: Option<bool>,
pub enable_fan_curves: Option<bool>,
#[options(
meta = "",
help = "select fan <cpu/gpu/mid> to modify. `mod_profile` required"
help = "enable or disable <true/false> a single fan curve for a profile. `--mod_profile` \
and `--fan` required"
)]
pub enable_fan_curve: Option<bool>,
#[options(
meta = "",
help = "select fan <cpu/gpu/mid> to modify. `--mod_profile` required"
)]
pub fan: Option<FanCurvePU>,
#[options(
meta = "",
help = "data format = 30c:1%,49c:2%,59c:3%,69c:4%,79c:31%,89c:49%,99c:56%,109c:58%.
`--mod-profile` required. If '%' is omitted the fan range is 0-255"
help = "data format = 30c:1%,49c:2%,59c:3%,69c:4%,79c:31%,89c:49%,99c:56%,109c:58%. \
`--mod-profile` required. If '%' is omitted the fan range is 0-255"
)]
pub data: Option<CurveData>,
}