From 67831ac97c8a4c45ee08d438214da41372be10df Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Tue, 26 Jan 2021 13:15:27 -0600 Subject: [PATCH] Errors on any battery stopped display of all battery information --- widgets/battery.go | 3 +++ widgets/batterygauge.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/widgets/battery.go b/widgets/battery.go index d8334bb..4a8dcbf 100644 --- a/widgets/battery.go +++ b/widgets/battery.go @@ -91,6 +91,9 @@ func (b *BatteryWidget) update() { } } for i, battery := range batteries { + if battery.Full == 0.0 { + continue + } id := makeID(i) perc := battery.Current / battery.Full percentFull := math.Abs(perc) * 100.0 diff --git a/widgets/batterygauge.go b/widgets/batterygauge.go index 20d92d4..3a89590 100644 --- a/widgets/batterygauge.go +++ b/widgets/batterygauge.go @@ -49,7 +49,6 @@ func (b *BatteryGauge) update() { log.Printf("error setting up batteries: %v", err) errLogged = true } - return } if len(bats) < 1 { b.Label = fmt.Sprintf("N/A") @@ -60,6 +59,9 @@ func (b *BatteryGauge) update() { charging := "%d%% ⚡%s" rate := 0.0 for _, bat := range bats { + if bat.Full == 0.0 { + continue + } mx += bat.Full cu += bat.Current if rate < bat.ChargeRate {