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. --- config/config.go | 55 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 8 deletions(-) (limited to 'config') diff --git a/config/config.go b/config/config.go index 4a93998..71c377c 100644 --- a/config/config.go +++ b/config/config.go @@ -1,16 +1,55 @@ package config // import "hhvn.uk/hbspbar/config" +import "image/color" + // Bar height var H uint = 17 -// Colours -var Bg uint32 = 0xff050a10 -var UnselMon uint32 = 0xff0c1726 -var Status uint32 = 0xff0a2126 -var Fg uint32 = 0xffeeeeee -var FgDark uint32 = 0xff444444 -var Sel uint32 = 0xff1b364b -var Urg uint32 = 0xff90222b +const ( + // Bar colours + xBg = 0xff050a10 + xUnselMon = 0xff0c1726 + xStatus = 0xff0a2126 + xFg = 0xffeeeeee + xFgDark = 0xff444444 + xSel = 0xff1b364b + xUrg = 0xff90222b + + // Status colours + xRed = 0xffaa2222 + xOrange = 0xffaa7700 + xGreen = 0xff00aa00 + xBlack = 0xff000000 + xGrey = 0xff888888 + xYellow = 0xffaaaa00 + xWhite = 0xffcccccc +) + +func int2rgb(argb uint32) (color.Color) { + return color.RGBA{ + B: uint8( argb & 0x000000ff), + G: uint8((argb & 0x0000ff00) >> 8), + R: uint8((argb & 0x00ff0000) >> 16), + A: uint8((argb & 0xff000000) >> 24) } +} + +var ( + Bg = int2rgb(xBg) + UnselMon = int2rgb(xUnselMon) + Status = int2rgb(xStatus) + Fg = int2rgb(xFg) + FgDark = int2rgb(xFgDark) + Sel = int2rgb(xSel) + Urg = int2rgb(xUrg) + + Red = int2rgb(xRed) + Orange = int2rgb(xOrange) + Green = int2rgb(xGreen) + Black = int2rgb(xBlack) + Grey = int2rgb(xGrey) + Yellow = int2rgb(xYellow) + White = int2rgb(xWhite) +) var Font string = "/usr/share/fonts/TTF/DejaVuSansMono.ttf" var FontSize float64 = 11.0 -- cgit v1.2.3