blob: 71fb6f17838267c02529b5690c995d8a57b02aa8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package widgets
import (
"log"
psHost "github.com/shirou/gopsutil/host"
"github.com/cjbassi/gotop/utils"
)
func (self *TempWidget) update() {
sensors, err := psHost.SensorsTemperatures()
if err != nil {
log.Printf("failed to get sensors from gopsutil: %v", err)
return
}
for _, sensor := range sensors {
if sensor.Temperature != 0 {
switch self.TempScale {
case Fahrenheit:
self.Data[sensor.SensorKey] = utils.CelsiusToFahrenheit(int(sensor.Temperature))
case Celsius:
self.Data[sensor.SensorKey] = int(sensor.Temperature)
}
}
}
}
|