blob: 38e3cce94a5cc452dde769bf1f55a1547c0ece72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package widgets
import (
"strings"
psHost "github.com/shirou/gopsutil/host"
)
func (self *Temp) update() {
sensors, _ := psHost.SensorsTemperatures()
for _, sensor := range sensors {
// only sensors with input in their name are giving us live temp info
if strings.Contains(sensor.SensorKey, "input") && sensor.Temperature != 0 {
// removes '_input' from the end of the sensor name
label := sensor.SensorKey[:strings.Index(sensor.SensorKey, "_input")]
if self.Fahrenheit {
self.Data[label] = int(sensor.Temperature*9/5 + 32)
} else {
self.Data[label] = int(sensor.Temperature)
}
}
}
}
|