Skip to content

Instantly share code, notes, and snippets.

@4Ply
Created June 9, 2025 01:04
Show Gist options
  • Select an option

  • Save 4Ply/3aafeabc4f2b81f64c28a4c5c23a6f0e to your computer and use it in GitHub Desktop.

Select an option

Save 4Ply/3aafeabc4f2b81f64c28a4c5c23a6f0e to your computer and use it in GitHub Desktop.
Show /etc/fancontrol in a more human-readable format
#!/bin/bash
awk '
BEGIN {
FS = "=";
section_order[1] = "CURRENT";
section_order[2] = "MINTEMP";
section_order[3] = "MAXTEMP";
section_order[4] = "MINPWM";
section_order[5] = "MINSTART";
section_order[6] = "MINSTOP";
section_order[7] = "FCTEMPS";
section_order[8] = "FCFANS";
COMMENT["MINTEMP"] = "Below this, the fan can run at minimum speed";
COMMENT["MAXTEMP"] = "Fan reaches full speed at this point"
COMMENT["MINPWM"] = "Fan’s lowest reliable speed without stalling";
COMMENT["MINSTART"] = "PWM value needed to reliably start the fan from a stop";
COMMENT["MINSTOP"] = "PWM below this stops the fan. This should be a bit lower than MINSTART";
}
{
if ($1 ~ /^#/) next;
if ($1 ~ /^INTERVAL/) next;
section = $1;
value = substr($0, index($0, "=")+1);
n = split(value, arr, " ");
for (i = 1; i <= n; i++) {
split(arr[i], kv, "=");
if (length(kv[2]) > 0) {
data[kv[1]][section] = kv[2];
} else {
data[kv[1]][section] = ""; # for single values
}
}
}
END {
print "==== device list ====\n";
for (dev in data) {
if (dev ~ /\//) continue; # exclude fans
print dev ":";
for (section in data[dev]) {
printf " %-10s -> %s\n", section, data[dev][section];
}
print "";
}
print "==== fan configuration ====\n";
for (fan in data) {
if (fan !~ /\//) continue; # only show fan data
desc=""
if (fan == "hwmon3/pwm2") desc=" (CPU)";
if (fan == "hwmon3/pwm7") desc=" (MOBO)";
if (fan == "hwmon3/pwm3") desc=" (Back of case)";
if (fan == "hwmon3/pwm4") desc=" (Side wall - top)";
if (fan == "hwmon3/pwm5") desc=" (Side wall - bottom)";
if (fan == "hwmon3/pwm6") desc=" (Side wall - middle)";
# get the current fan speed
cmd="cat /sys/class/hwmon/" fan;
cmd | getline current_value;
close(cmd);
data[fan]["CURRENT"]=sprintf("%d (%d%% power)", current_value, current_value/255*100);
print fan desc ":";
for (so = 1; so in section_order; so++) {
sec = section_order[so];
if (sec in data[fan]) {
if (sec == "FCTEMPS" || sec == "FCFANS") {
# get the value of the temp monitor
cmd="cat /sys/class/hwmon/" data[fan][sec];
cmd | getline current_value;
close(cmd);
if (sec == "FCTEMPS") {
current_value=current_value/1000
current_value=sprintf("%d °C", current_value)
}
line = sprintf("%-10s -> %s (%s)", sec, data[fan][sec], current_value);
} else {
line = sprintf("%-10s -> %s", sec, data[fan][sec]);
}
if (COMMENT[sec] != "") {
printf " %-42s # %s\n", line, COMMENT[sec];
} else {
printf " %-42s\n", line;
}
}
}
for (section in data[fan]) {
found = 0;
for (so = 1; so in section_order; so++) {
if (section == section_order[so]) {
found = 1;
break;
}
}
if (!found) {
printf " %-10s -> %s\n", section, data[fan][section];
}
}
print "";
}
}
' /etc/fancontrol
@4Ply
Copy link
Copy Markdown
Author

4Ply commented Jun 9, 2025

example output:

==== device list ====

hwmon1:
  DEVNAME    -> k10temp
  DEVPATH    -> devices/pci0000:00/0000:00:18.3

hwmon3:
  DEVNAME    -> nct6797
  DEVPATH    -> devices/platform/nct6775.2592

==== fan configuration ====

hwmon3/pwm6 (Side wall - middle):
  CURRENT    -> 177 (69% power)             
  MINTEMP    -> 40                           # Below this, the fan can run at minimum speed
  MAXTEMP    -> 90                           # Fan reaches full speed at this point
  MINSTART   -> 150                          # PWM value needed to reliably start the fan from a stop
  MINSTOP    -> 60                           # PWM below this stops the fan. This should be a bit lower than MINSTART
  FCTEMPS    -> hwmon1/temp1_input (68 °C)  
  FCFANS     -> hwmon3/fan6_input (1206)    

hwmon3/pwm7 (MOBO):
  CURRENT    -> 0 (0% power)                
  MINTEMP    -> 45                           # Below this, the fan can run at minimum speed
  MAXTEMP    -> 90                           # Fan reaches full speed at this point
  MINSTART   -> 40                           # PWM value needed to reliably start the fan from a stop
  MINSTOP    -> 30                           # PWM below this stops the fan. This should be a bit lower than MINSTART
  FCTEMPS    -> hwmon3/temp1_input (32 °C)  
  FCFANS     -> hwmon3/fan7_input (0)       

hwmon3/pwm2 (CPU):
  CURRENT    -> 149 (58% power)             
  MINTEMP    -> 55                           # Below this, the fan can run at minimum speed
  MAXTEMP    -> 90                           # Fan reaches full speed at this point
  MINPWM     -> 34                           # Fan’s lowest reliable speed without stalling
  MINSTART   -> 75                           # PWM value needed to reliably start the fan from a stop
  MINSTOP    -> 70                           # PWM below this stops the fan. This should be a bit lower than MINSTART
  FCTEMPS    -> hwmon1/temp1_input (68 °C)  
  FCFANS     -> hwmon3/fan2_input (1785)    

hwmon3/pwm3 (Back of case):
  CURRENT    -> 169 (66% power)             
  MINTEMP    -> 40                           # Below this, the fan can run at minimum speed
  MAXTEMP    -> 90                           # Fan reaches full speed at this point
  MINSTART   -> 50                           # PWM value needed to reliably start the fan from a stop
  MINSTOP    -> 40                           # PWM below this stops the fan. This should be a bit lower than MINSTART
  FCTEMPS    -> hwmon1/temp1_input (68 °C)  
  FCFANS     -> hwmon3/fan3_input (1272)    

hwmon3/pwm4 (Side wall - top):
  CURRENT    -> 169 (66% power)             
  MINTEMP    -> 40                           # Below this, the fan can run at minimum speed
  MAXTEMP    -> 90                           # Fan reaches full speed at this point
  MINSTART   -> 50                           # PWM value needed to reliably start the fan from a stop
  MINSTOP    -> 40                           # PWM below this stops the fan. This should be a bit lower than MINSTART
  FCTEMPS    -> hwmon1/temp1_input (68 °C)  
  FCFANS     -> hwmon3/fan4_input (1451)    

hwmon3/pwm5 (Side wall - bottom):
  CURRENT    -> 169 (66% power)             
  MINTEMP    -> 40                           # Below this, the fan can run at minimum speed
  MAXTEMP    -> 90                           # Fan reaches full speed at this point
  MINSTART   -> 50                           # PWM value needed to reliably start the fan from a stop
  MINSTOP    -> 40                           # PWM below this stops the fan. This should be a bit lower than MINSTART
  FCTEMPS    -> hwmon1/temp1_input (68 °C)  
  FCFANS     -> hwmon3/fan5_input (1112)    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment