diff options
Diffstat (limited to 'status')
| -rw-r--r-- | status/00-status.go | 18 | ||||
| -rw-r--r-- | status/01-bat.go | 11 |
2 files changed, 12 insertions, 17 deletions
diff --git a/status/00-status.go b/status/00-status.go index e88011d..809297b 100644 --- a/status/00-status.go +++ b/status/00-status.go @@ -5,6 +5,7 @@ import ( "time" "sync" "image" + "image/color" "hhvn.uk/hbspbar/drw" "hhvn.uk/hbspbar/config" @@ -18,13 +19,6 @@ var Updated chan bool var updates chan *status const ( - Red = 0xffaa2222 - Orange = 0xffaa7700 - Green = 0xff00aa00 - Black = 0xff000000 - Grey = 0xff888888 - Yellow = 0xffaaaa00 - White = 0xffcccccc ) func init() { @@ -83,7 +77,7 @@ func checkError(name string, err error) { common.Error("status \"%s\": %s\n", name, err) u := newUpdate(name) - u.drawText(0, Red, fmt.Sprintf("[err: %s]", name)) + u.drawText(0, config.Red, fmt.Sprintf("[err: %s]", name)) updates <- u sleep(5) @@ -93,8 +87,8 @@ func sleep(s int) { time.Sleep(time.Duration(s) * time.Second) } -func blendGYR(percent int) uint32 { - return drw.Blend3(Green, Yellow, Red, percent) +func blendGYR(percent int) color.Color { + return drw.Blend3(config.Green, config.Yellow, config.Red, percent) } func (s *status) furthest(x int) { @@ -103,13 +97,13 @@ func (s *status) furthest(x int) { } } -func (s *status) drawText(x int, col uint32, text string) (int, error) { +func (s *status) drawText(x int, col color.Color, text string) (int, error) { w, err := drw.DrawText(s.I, x, col, text) s.furthest(x + w) return w, err } -func (s *status) drawRect(x, y, w, h int, c uint32, fill bool) { +func (s *status) drawRect(x, y, w, h int, c color.Color, fill bool) { drw.DrawRect(s.I, x, y, w, h, c, fill) s.furthest(x + w) } 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 } |