…lines 1–71 unchanged (71 lines)
72 }
73 if strings.HasPrefix(temp.SensorKey, "coretemp_core") && strings.HasSuffix(temp.SensorKey, "input") {
74 vals[temp.SensorKey] = temp.Temperature
75 }
76 fmt.Println(temp.SensorKey, temp.Temperature)
77 }
78
79 // in case we still have no temperature value, let's try calculating average per-core value
80 sum := 0.0
81 div := 0
82 for k, v := range vals {
83 if strings.HasPrefix(k, "coretemp_core") {
84 sum += v
85 div += 1
86 }
87 }
88 vals["coretemp_average"] = sum / float64(div)
89
90 for key, value := range vals {
91 fmt.Println("Key:", key, "Value:", value)
92 }
93
94 if v, ok := vals["k10temp"]; ok {
95 output += fmt.Sprint(v)
96 } else {
97 if v, ok = vals["coretemp_packageid0"]; ok {
98 output += fmt.Sprint(v)
99 } else {
100 if v, ok = vals["coretemp_average"]; ok {
101 output += fmt.Sprint(int(math.Round(v)))
102 } else {
103 if v, ok = vals["acpitz"]; ok {
104 output += fmt.Sprint(v)
105 }
106 }
107 }
108 }
109
110 output += "℃"
111 return output
112}
113
…lines 114–292 unchanged (179 lines)