From 050b62a20a6250bac7bf1549e7cfeaf2bb7c5494 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Tue, 23 Jun 2020 07:12:09 -0500 Subject: [PATCH] Fixes #134, caused by a divide by zero error on systems with no batteries --- widgets/batterygauge.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/widgets/batterygauge.go b/widgets/batterygauge.go index 135f223..02a8866 100644 --- a/widgets/batterygauge.go +++ b/widgets/batterygauge.go @@ -51,6 +51,10 @@ func (b *BatteryGauge) update() { } return } + if len(bats) < 1 { + b.Label = fmt.Sprintf("N/A") + return + } mx := 0.0 cu := 0.0 charging := "%d%% ⚡%s"