diff options
author | Sean E. Russell <ser@ser1.net> | 2020-04-23 10:41:20 -0500 |
---|---|---|
committer | Sean E. Russell <ser@ser1.net> | 2020-04-23 10:41:20 -0500 |
commit | 5ada5315d940038fcd83777b1e73797bbbada108 (patch) | |
tree | 14af5297197ecc43e50ff7cafa8154fda55dd72f /devices/temp_linux.go | |
parent | 3fcab5a42054c84895c4f6da5097360d35414fde (diff) |
Fixes #92, configurable temps; help text & docs clean-up; versions are now built into binaries at compile time; clean up old extensions params; adds --list command; adds --write-config command; fixes bug in colorscheme loading; fixes bug in Colorschemes -- all had empty Name attrs; adds ability to list devices.
Diffstat (limited to 'devices/temp_linux.go')
-rw-r--r-- | devices/temp_linux.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/devices/temp_linux.go b/devices/temp_linux.go index ec4ff95..2ca01f5 100644 --- a/devices/temp_linux.go +++ b/devices/temp_linux.go @@ -10,6 +10,7 @@ import ( func init() { RegisterTemp(getTemps) + RegisterDeviceList(Temperatures, devs) } func getTemps(temps map[string]int) map[string]error { @@ -18,12 +19,31 @@ func getTemps(temps map[string]int) map[string]error { return map[string]error{"psHost": err} } for _, sensor := range sensors { + // removes '_input' from the end of the sensor name + idx := strings.Index(sensor.SensorKey, "_input") + if idx >= 0 { + label := sensor.SensorKey[:idx] + if _, ok := temps[label]; ok { + temps[label] = int(sensor.Temperature) + } + } + } + return nil +} + +func devs() []string { + sensors, err := psHost.SensorsTemperatures() + if err != nil { + return []string{} + } + rv := make([]string, 0, len(sensors)) + 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")] - temps[label] = int(sensor.Temperature) + rv = append(rv, label) } } - return nil + return rv } |