Skip to content

Commit c7ac67a

Browse files
committed
autofanctrl: Allow specifying fan index
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent ca1f347 commit c7ac67a

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

EXAMPLES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ Accelerometers:
441441
F75303_DDR: 38 C
442442
APU: 42 C
443443
Fan Speed: 0 RPM
444+
445+
# Or just for a specific fan (e.g. on Framework Desktop)
446+
> sudo framework_tool --autofanctrl 0
447+
> sudo framework_tool --autofanctrl 1
444448
```
445449

446450
## Check expansion bay (Framework 16)

framework_lib/src/commandline/clap_std.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct ClapCli {
6969

7070
/// Turn on automatic fan speed control
7171
#[arg(long)]
72-
autofanctrl: bool,
72+
autofanctrl: Option<Option<u8>>,
7373

7474
/// Show information about USB-C PD ports
7575
#[arg(long)]

framework_lib/src/commandline/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub struct Cli {
167167
pub sensors: bool,
168168
pub fansetduty: Option<(Option<u32>, u32)>,
169169
pub fansetrpm: Option<(Option<u32>, u32)>,
170-
pub autofanctrl: bool,
170+
pub autofanctrl: Option<Option<u8>>,
171171
pub pdports: bool,
172172
pub privacy: bool,
173173
pub pd_info: bool,
@@ -1184,7 +1184,9 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
11841184
print_err(ec.fan_set_duty(fan, percent));
11851185
} else if let Some((fan, rpm)) = args.fansetrpm {
11861186
print_err(ec.fan_set_rpm(fan, rpm));
1187-
} else if args.autofanctrl {
1187+
} else if let Some(Some(fan_id)) = args.autofanctrl {
1188+
print_err(ec.autofanctrl(Some(fan_id)));
1189+
} else if let Some(None) = args.autofanctrl {
11881190
print_err(ec.autofanctrl(None));
11891191
} else if args.pdports {
11901192
power::get_and_print_pd_info(&ec);
@@ -1457,7 +1459,7 @@ Options:
14571459
--sensors Print sensor information (ALS, G-Sensor)
14581460
--fansetduty Set fan duty cycle (0-100%)
14591461
--fansetrpm Set fan RPM (limited by EC fan table max RPM)
1460-
--autofanctrl Turn on automatic fan speed control
1462+
--autofanctrl [<FANID>]Turn on automatic fan speed control (optionally provide fan index)
14611463
--pdports Show information about USB-C PD ports
14621464
--info Show info from SMBIOS (Only on UEFI)
14631465
--pd-info Show details about the PD controllers

framework_lib/src/commandline/uefi.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn parse(args: &[String]) -> Cli {
3939
sensors: false,
4040
fansetduty: None,
4141
fansetrpm: None,
42-
autofanctrl: false,
42+
autofanctrl: None,
4343
pdports: false,
4444
pd_info: false,
4545
pd_reset: None,
@@ -195,7 +195,19 @@ pub fn parse(args: &[String]) -> Cli {
195195
};
196196
found_an_option = true;
197197
} else if arg == "--autofanctrol" {
198-
cli.autofanctrl = true;
198+
cli.autofanctrl = if args.len() > i + 1 {
199+
if let Ok(fan_id) = args[i + 1].parse::<u8>() {
200+
Some(Some(fan_id))
201+
} else {
202+
println!(
203+
"Invalid value for --autofanctrl: '{}'. Must be integer < 256.",
204+
args[i + 1]
205+
);
206+
None
207+
}
208+
} else {
209+
Some(None)
210+
};
199211
found_an_option = true;
200212
} else if arg == "--pdports" {
201213
cli.pdports = true;

0 commit comments

Comments
 (0)