2018-05-16 04:48:26 +08:00
|
|
|
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
|
2018-11-30 09:37:41 +08:00
|
|
|
if strings.Contains(sensor.SensorKey, "input") && sensor.Temperature != 0 {
|
2018-05-16 04:48:26 +08:00
|
|
|
// removes '_input' from the end of the sensor name
|
|
|
|
label := sensor.SensorKey[:strings.Index(sensor.SensorKey, "_input")]
|
2018-11-14 01:29:09 +08:00
|
|
|
if self.Fahrenheit {
|
|
|
|
self.Data[label] = int(sensor.Temperature*9/5 + 32)
|
|
|
|
} else {
|
|
|
|
self.Data[label] = int(sensor.Temperature)
|
|
|
|
}
|
2018-05-16 04:48:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|