Skip to content

Commit

Permalink
Merge pull request #6 from nwg-piotr/coretemp
Browse files Browse the repository at this point in the history
Support `coretemp` sensor
  • Loading branch information
nwg-piotr authored Jun 16, 2023
2 parents b906fbc + e7f09ef commit 886293f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion gopsuinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,33 @@ func temperatures(asIcon bool) string {
output += g.glyphTemp
}
vals := make(map[string]int)
vals["acpitz"] = 0

temps, _ := host.SensorsTemperatures()
for _, temp := range temps {
// Some machines may return multiple sensors of the same name. Let's accept the 1st non-zero temp value.
if vals["acpitz"] == 0 && temp.SensorKey == "acpitz_input" {
vals["acpitz"] = int(temp.Temperature)
}
if vals["coretemp"] == 0 && temp.SensorKey == "coretemp_packageid0_input" || temp.SensorKey == "coretemp_core0_input" {
vals["coretemp"] = int(temp.Temperature)
}
if temp.SensorKey == "k10temp_tctl_input" || temp.SensorKey == "k10temp_tdie_input" {
vals["k10temp"] = int(temp.Temperature)
}
}

if v, ok := vals["k10temp"]; ok {
output += fmt.Sprint(v)
} else {
if v, ok := vals["acpitz"]; ok {
output += fmt.Sprint(v)
} else {
if v, ok := vals["coretemp"]; ok {
output += fmt.Sprint(v)
}
}
}

output += "℃"
return output
}
Expand Down

0 comments on commit 886293f

Please sign in to comment.