diff options
author | Sean E. Russell <ser@ser1.net> | 2020-06-23 07:12:09 -0500 |
---|---|---|
committer | Sean E. Russell <ser@ser1.net> | 2020-06-23 07:12:09 -0500 |
commit | 050b62a20a6250bac7bf1549e7cfeaf2bb7c5494 (patch) | |
tree | c2544ff7538800607b77c426c9ad62f0d0b781be | |
parent | 0b463d427f7758cca9478bfa6d2c2f8eec758740 (diff) |
Fixes #134, caused by a divide by zero error on systems with no batteries
-rw-r--r-- | widgets/batterygauge.go | 4 |
1 files changed, 4 insertions, 0 deletions
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" |