From c6014adff2d320a7623bb24da733ae211369d75c Mon Sep 17 00:00:00 2001
From: Kevin Lyda <kevin@lyda.ie>
Date: Wed, 28 Dec 2022 20:17:46 +0000
Subject: [PATCH] Fix battery colours.

---
 modules/battery.go | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/modules/battery.go b/modules/battery.go
index 24fdf1b..ea76045 100644
--- a/modules/battery.go
+++ b/modules/battery.go
@@ -47,34 +47,34 @@ func NewBattery(m *Module) *BatteryMod {
 
 // SetDefaults sets defaults.
 func (b *BatteryMod) SetDefaults() {
-	if b.StatusEmp != "" {
+	if b.StatusEmp == "" {
 		b.StatusEmp = "---"
 	}
-	if b.StatusChr != "" {
+	if b.StatusChr == "" {
 		b.StatusChr = "CHR"
 	}
-	if b.StatusBat != "" {
+	if b.StatusBat == "" {
 		b.StatusBat = "BAT"
 	}
-	if b.StatusUnk != "" {
+	if b.StatusUnk == "" {
 		b.StatusUnk = "UNK"
 	}
-	if b.StatusFull != "" {
+	if b.StatusFull == "" {
 		b.StatusFull = "FULL"
 	}
-	if b.OnError != "" {
+	if b.OnError == "" {
 		b.OnError = "No BAT"
 	}
-	if b.ColorOK != "" {
+	if b.ColorOK == "" {
 		b.ColorOK = "#11ff11"
 	}
-	if b.Color20 != "" {
+	if b.Color20 == "" {
 		b.Color20 = "#ffa500"
 	}
-	if b.Color10 != "" {
+	if b.Color10 == "" {
 		b.Color10 = "#ffff00"
 	}
-	if b.ColorError != "" {
+	if b.ColorError == "" {
 		b.ColorError = "#ff1111"
 	}
 }
@@ -128,11 +128,10 @@ func (b *BatteryMod) Render() string {
 	color := b.ColorOK
 	percent := 100 * (batt.Current / batt.Design)
 	if percent < 20 {
-		if percent < 10 {
-			color = b.Color10
-		} else {
-			color = b.Color20
-		}
+		color = b.Color20
+	}
+	if percent < 10 {
+		color = b.Color10
 	}
 
 	if b.Battery > 0 {
-- 
GitLab