From 737f649e6bb356ef9aab5d21510b569cc638b3f9 Mon Sep 17 00:00:00 2001 From: piotr Date: Sat, 17 Jun 2023 00:54:15 +0200 Subject: [PATCH 1/3] support `coretemp` --- gopsuinfo.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gopsuinfo.go b/gopsuinfo.go index d9c0a0d..6a4110e 100644 --- a/gopsuinfo.go +++ b/gopsuinfo.go @@ -57,23 +57,35 @@ func temperatures(asIcon bool) string { output += g.glyphTemp } vals := make(map[string]int) - vals["acpitz"] = 0 + temps, _ := host.SensorsTemperatures() for _, temp := range temps { if vals["acpitz"] == 0 && temp.SensorKey == "acpitz_input" { vals["acpitz"] = int(temp.Temperature) } + if vals["coretemp"] == 0 && temp.SensorKey == "coretemp_packageid0_input" { + vals["coretemp"] = int(temp.Temperature) + } + if vals["coretemp"] == 0 && 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 } From 65e24f52877bcdb157ddeff66035b0e658f536a1 Mon Sep 17 00:00:00 2001 From: piotr Date: Sat, 17 Jun 2023 01:42:22 +0200 Subject: [PATCH 2/3] comment for future reference --- gopsuinfo.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gopsuinfo.go b/gopsuinfo.go index 6a4110e..52fe9dc 100644 --- a/gopsuinfo.go +++ b/gopsuinfo.go @@ -60,6 +60,7 @@ func temperatures(asIcon bool) string { 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) } From e7f09efac79f995cc1a9417218cc1cb27f3a5432 Mon Sep 17 00:00:00 2001 From: piotr Date: Sat, 17 Jun 2023 01:47:30 +0200 Subject: [PATCH 3/3] simplify coretemp --- gopsuinfo.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gopsuinfo.go b/gopsuinfo.go index 52fe9dc..04552b4 100644 --- a/gopsuinfo.go +++ b/gopsuinfo.go @@ -64,10 +64,7 @@ func temperatures(asIcon bool) string { if vals["acpitz"] == 0 && temp.SensorKey == "acpitz_input" { vals["acpitz"] = int(temp.Temperature) } - if vals["coretemp"] == 0 && temp.SensorKey == "coretemp_packageid0_input" { - vals["coretemp"] = int(temp.Temperature) - } - if vals["coretemp"] == 0 && temp.SensorKey == "coretemp_core0_input" { + 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" {