diff options
| author | hhvn <dev@hhvn.uk> | 2023-11-18 19:50:26 +0000 |
|---|---|---|
| committer | hhvn <dev@hhvn.uk> | 2023-11-18 19:56:13 +0000 |
| commit | 19781aeb974bd20c421a6b4677ffab348df8faf9 (patch) | |
| tree | 22bde9a97fdc36f6d412203319f797cf168986d9 /bar | |
| parent | 505685c6d546cab46f919f6b5296ca73b80d09b2 (diff) | |
Statuses
Diffstat (limited to 'bar')
| -rw-r--r-- | bar/bar.go | 36 |
1 files changed, 34 insertions, 2 deletions
@@ -8,6 +8,7 @@ import ( "hhvn.uk/hbspbar/config" "hhvn.uk/hbspbar/common" + "hhvn.uk/hbspbar/status" "hhvn.uk/hbspbar/bspc" "hhvn.uk/hbspbar/drw" ) @@ -71,7 +72,7 @@ func (b *bar) draw() { if b.Mon.Focused { bg = config.Sel } else { - bg = config.Bg2 + bg = config.UnselMon } b.drawRect(cx, 0, monw, h, bg, true) @@ -106,7 +107,34 @@ func (b *bar) draw() { ax, _ := b.drawText(cx, config.Fg, d.Name) cx += ax + 2 } - cx += 5 + + status.Mutex.Lock() + cx = int(b.Mon.Rectangle.Width) - 6 + for i := len(status.Status) - 1; i >= 0; i -= 1 { + s, ok := status.Status[i] + if ok { + cx -= s.W + cx -= config.StatusPad + } + } + cx += config.StatusPad + cx -= 6 + + b.drawRect(cx, 0, int(b.Mon.Rectangle.Width) - cx, int(config.H), + config.Status, true) + + cx = int(b.Mon.Rectangle.Width) - 6 + for i := len(status.Status) - 1; i >= 0; i -= 1 { + s, ok := status.Status[i] + if ok { + cx -= s.W + + drw.AddImg(b.i, cx, s.W, s.I) + + cx -= config.StatusPad + } + } + status.Mutex.Unlock() b.w.Paint(b.i) @@ -178,6 +206,10 @@ func init() { Handle.Err <- fmt.Errorf("Couldn't create window: %s\n", err) return } + case <- status.Updated: + for _, b := range bars { + go b.draw() + } case state = <- Handle.NewState: for _, b := range bars { b.Mon = state.GetMon(b.Mon.ID) |