hbspbar

[WIP] bspwm status bar
git clone https://hhvn.uk/hbspbar
git clone git://hhvn.uk/hbspbar
Log | Files | Refs

commit e2011ebed72d891ccddfa5863e370ceb5ba8267c
parent ec83d2780491159c4425ee1a5816c2bd4d6e6245
Author: hhvn <dev@hhvn.uk>
Date:   Sat, 30 Dec 2023 15:00:19 +0000

make bar.Cleanup() actually work

Diffstat:
Mbar/bar.go | 19++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/bar/bar.go b/bar/bar.go @@ -163,10 +163,12 @@ type handle struct { Err chan error } -var cleanup chan bool - var Handle handle +// Store the state for when bar.Cleanup() is called +// This is a bit hacky but I don't really see any alternative +var finalstate *bspc.State = nil + func init() { var state *bspc.State state = nil @@ -175,7 +177,6 @@ func init() { Handle.Destroy = make(chan int) Handle.NewState = make(chan *bspc.State) Handle.Err = make(chan error) - cleanup = make(chan bool) go func() { defer func() { @@ -217,16 +218,12 @@ func init() { Handle.Err <- fmt.Errorf("Couldn't create window: %s\n", err) return } - case <- cleanup: - for _, b := range bars { - go b.destroy(state) - } - return case <- status.Updated: for _, b := range bars { go b.draw(state) } case state = <- Handle.NewState: + finalstate = state for _, b := range bars { go b.draw(state) } @@ -256,5 +253,9 @@ func create(state *bspc.State, id int) (error) { } func Cleanup() { - cleanup <- true + if finalstate != nil { + for _, b := range bars { + b.destroy(finalstate) + } + } }