summaryrefslogtreecommitdiffstats
path: root/devices/devices.go
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-04-23 10:41:20 -0500
committerSean E. Russell <ser@ser1.net>2020-04-23 10:41:20 -0500
commit5ada5315d940038fcd83777b1e73797bbbada108 (patch)
tree14af5297197ecc43e50ff7cafa8154fda55dd72f /devices/devices.go
parent3fcab5a42054c84895c4f6da5097360d35414fde (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/devices.go')
-rw-r--r--devices/devices.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/devices/devices.go b/devices/devices.go
index 91a8815..efdc404 100644
--- a/devices/devices.go
+++ b/devices/devices.go
@@ -2,7 +2,13 @@ package devices
import "log"
+const (
+ Temperatures = "Temperatures"
+)
+
+var Domains []string = []string{Temperatures}
var shutdownFuncs []func() error
+var _devs map[string][]string
// RegisterShutdown stores a function to be called by gotop on exit, allowing
// extensions to properly release resources. Extensions should register a
@@ -24,3 +30,18 @@ func Shutdown() {
}
}
}
+
+func RegisterDeviceList(typ string, f func() []string) {
+ if _devs == nil {
+ _devs = make(map[string][]string)
+ }
+ if ls, ok := _devs[typ]; ok {
+ _devs[typ] = append(ls, f()...)
+ return
+ }
+ _devs[typ] = f()
+}
+
+func Devices(domain string) []string {
+ return _devs[domain]
+}