From 4722a069233b35efd0b600c973e7a7e9bca01d16 Mon Sep 17 00:00:00 2001 From: hhvn Date: Sun, 19 Nov 2023 13:49:28 +0000 Subject: Do int2rgb conversions once. In config.go. --- status/01-bat.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'status/01-bat.go') diff --git a/status/01-bat.go b/status/01-bat.go index 4566398..5eb9295 100644 --- a/status/01-bat.go +++ b/status/01-bat.go @@ -5,6 +5,7 @@ import ( "path" "errors" "strings" + "image/color" // "hhvn.uk/hbspbar/drw" "hhvn.uk/hbspbar/config" @@ -58,13 +59,13 @@ func bat(name string) error { avgcap := (usedcap * 100) / totalcap - var c uint32 + var c color.Color // Colour of outline = charge indicator switch stati { case nothing: c = config.Fg - case charging: c = Green - case discharging: c = Red + case charging: c = config.Green + case discharging: c = config.Red } var iw int = 20 @@ -78,8 +79,8 @@ func bat(name string) error { u.drawRect(4, 3, iw + 2, ih + 2, c, false) switch { - case avgcap < 25: c = Red - case avgcap >= 99: c = Green + case avgcap < 25: c = config.Red + case avgcap >= 99: c = config.Green default: c = config.FgDark } -- cgit v1.2.3