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/01-bat.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'status/01-bat.go') diff --git a/status/01-bat.go b/status/01-bat.go index 85643f1..12882dc 100644 --- a/status/01-bat.go +++ b/status/01-bat.go @@ -12,7 +12,7 @@ import ( "hhvn.uk/hbspbar/common" ) -func bat(name string) error { +func bat(u *Block) error { dir := "/sys/class/power_supply" const ( @@ -21,8 +21,6 @@ func bat(name string) error { discharging ) - u := newUpdate(name) - dirs, err := os.ReadDir(dir) if dirs == nil { return err } @@ -87,12 +85,9 @@ func bat(name string) error { // Fill u.drawRect(4 + iw - w, 4, w + 1, ih, c, true) - updates <- u - sleep(1) - return nil } func init() { - register("bat", bat) + register("bat", bat, 1) } -- cgit v1.2.3