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/03-mem.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'status/03-mem.go') diff --git a/status/03-mem.go b/status/03-mem.go index e33b879..2ae7bef 100644 --- a/status/03-mem.go +++ b/status/03-mem.go @@ -15,9 +15,7 @@ func checkMemField(m map[string]int, k string) error { return nil } -func mem(name string) error { - u := newUpdate(name) - +func mem(u *Block) error { mem := make(map[string]int) lines, err := common.FileAsLines("/proc/meminfo") @@ -44,13 +42,9 @@ func mem(name string) error { cx += u.drawPercentBar(cx, p) _, err = u.drawText(cx, blendGYR(p), fmt.Sprintf("%d%%", p)) - updates <- u - - sleep(1) - return nil } func init() { - register("mem", mem) + register("mem", mem, 1) } -- cgit v1.2.3