From 612e4fbeb14001d5eef0bb0e3e19ea65eb47cef2 Mon Sep 17 00:00:00 2001 From: hhvn Date: Sun, 14 Apr 2024 13:49:18 +0100 Subject: Tidy up the status block api a bit Handle (nearly) all the plumbing (sleeps, goroutines and comms) in register() --- status/02-cpu.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'status/02-cpu.go') diff --git a/status/02-cpu.go b/status/02-cpu.go index f67d908..7128661 100644 --- a/status/02-cpu.go +++ b/status/02-cpu.go @@ -42,9 +42,7 @@ func getcpus(c chan [][]string, e chan error) { } } -func cpu(name string) error { - u := newUpdate(name) - +func cpu(u *Block) error { cpus := [2]chan [][]string{ make(chan [][]string), make(chan [][]string) } @@ -127,10 +125,10 @@ func cpu(name string) error { u.drawText(cx, blendGYR(int(cp)), fmt.Sprintf("%d°C", temps / ncores)) - updates <- u return nil } func init() { - register("cpu", cpu) + // 0 second interval, as there is already a 1 second sleep in cpu() + register("cpu", cpu, 0) } -- cgit v1.2.3