Explicitly set color and background attributes for all <span> tags

This commit is contained in:
eleksir
2024-01-16 21:59:04 +03:00
parent 95356ed547
commit 5770f9106e
3 changed files with 65 additions and 25 deletions

View File

@@ -57,17 +57,20 @@ func UpdateBatteryInfo() {
case ch > 85: case ch > 85:
if Conf.Battery.ChargeColor.Full == "" { if Conf.Battery.ChargeColor.Full == "" {
chStr = fmt.Sprintf( chStr = fmt.Sprintf(
"<span font='%s' size='%s'>% 3d%%</span>", "<span color='%s' background='%s' font='%s' size='%s'>% 3d%%</span>",
Conf.Battery.Color,
Conf.Battery.Background,
Conf.Battery.Font,
Conf.Battery.FontSize, Conf.Battery.FontSize,
Conf.Battery.ChargeColor.Full,
ch, ch,
) )
} else { } else {
chStr = fmt.Sprintf( chStr = fmt.Sprintf(
`<span font='%s' size='%s' foreground='%s'>% 3d%%</span>`, `<span color='%s' background='%s' font='%s' size='%s'>% 3d%%</span>`,
Conf.Battery.ChargeColor.Full,
Conf.Battery.Background,
Conf.Battery.Font, Conf.Battery.Font,
Conf.Battery.FontSize, Conf.Battery.FontSize,
Conf.Battery.ChargeColor.Full,
ch, ch,
) )
} }
@@ -75,17 +78,20 @@ func UpdateBatteryInfo() {
case ch < 85 && ch > 40: case ch < 85 && ch > 40:
if Conf.Battery.ChargeColor.AlmostFull == "" { if Conf.Battery.ChargeColor.AlmostFull == "" {
chStr = fmt.Sprintf( chStr = fmt.Sprintf(
"<span font='%s' size='%s'>% 3d%%</span>", "<span color='%s' background='%s' font='%s' size='%s'>% 3d%%</span>",
Conf.Battery.Color,
Conf.Battery.Background,
Conf.Battery.Font,
Conf.Battery.FontSize, Conf.Battery.FontSize,
Conf.Battery.ChargeColor.Full,
ch, ch,
) )
} else { } else {
chStr = fmt.Sprintf( chStr = fmt.Sprintf(
`<span font='%s' size='%s' foreground='%s'>% 3d%%</span>`, `<span color='%s' background='%s' font='%s' size='%s'>% 3d%%</span>`,
Conf.Battery.ChargeColor.AlmostFull,
Conf.Battery.Background,
Conf.Battery.Font, Conf.Battery.Font,
Conf.Battery.FontSize, Conf.Battery.FontSize,
Conf.Battery.ChargeColor.AlmostFull,
ch, ch,
) )
} }
@@ -93,17 +99,20 @@ func UpdateBatteryInfo() {
case ch <= 40 && ch >= 10: case ch <= 40 && ch >= 10:
if Conf.Battery.ChargeColor.AlmostEmpty == "" { if Conf.Battery.ChargeColor.AlmostEmpty == "" {
chStr = fmt.Sprintf( chStr = fmt.Sprintf(
"<span font='%s' size='%s'>% 3d%%</span>", "<span color='%s' background='%s' font='%s' size='%s'>% 3d%%</span>",
Conf.Battery.Color,
Conf.Battery.Background,
Conf.Battery.Font,
Conf.Battery.FontSize, Conf.Battery.FontSize,
Conf.Battery.ChargeColor.Full,
ch, ch,
) )
} else { } else {
chStr = fmt.Sprintf( chStr = fmt.Sprintf(
`<span font='%s' size='%s' foreground='%s'>% 3d%%</span>`, `<span color='%s' background='%s' font='%s' size='%s'>% 3d%%</span>`,
Conf.Battery.ChargeColor.AlmostEmpty,
Conf.Battery.Background,
Conf.Battery.Font, Conf.Battery.Font,
Conf.Battery.FontSize, Conf.Battery.FontSize,
Conf.Battery.ChargeColor.AlmostEmpty,
ch, ch,
) )
} }
@@ -111,31 +120,40 @@ func UpdateBatteryInfo() {
case ch < 10: case ch < 10:
if Conf.Battery.ChargeColor.Empty == "" { if Conf.Battery.ChargeColor.Empty == "" {
chStr = fmt.Sprintf( chStr = fmt.Sprintf(
"<span font='%s' size='%s'>% 3d%%</span>", "<span color='%s' background='%s' font='%s' size='%s'>% 3d%%</span>",
Conf.Battery.Color,
Conf.Battery.Background,
Conf.Battery.Font,
Conf.Battery.FontSize, Conf.Battery.FontSize,
Conf.Battery.ChargeColor.Full,
ch, ch,
) )
} else { } else {
chStr = fmt.Sprintf( chStr = fmt.Sprintf(
`<span font='%s' size='%s' foreground='%s'>% 3d%%</span>`, `<span color='%s' background='%s' font='%s' size='%s'>% 3d%%</span>`,
Conf.Battery.ChargeColor.Empty,
Conf.Battery.Background,
Conf.Battery.Font, Conf.Battery.Font,
Conf.Battery.FontSize, Conf.Battery.FontSize,
Conf.Battery.ChargeColor.Empty,
ch, ch,
) )
} }
} }
battsInfo += fmt.Sprintf( battsInfo += fmt.Sprintf(
"<span font='%s' size='%s'>%s</span><span font='%s' size='%s'>B%d </span>%s<span font='%s' size='%s'> %s</span>", "<span color='%s' background='%s' font='%s' size='%s'>%s</span><span color='%s' background='%s' font='%s' size='%s'>B%d </span>%s<span color='%s' background='%s' font='%s' size='%s'> %s</span>",
Conf.Battery.Color,
Conf.Battery.Background,
Conf.Battery.SymbolFont, Conf.Battery.SymbolFont,
Conf.Battery.SymbolFontSize, Conf.Battery.SymbolFontSize,
Conf.Battery.Symbol, Conf.Battery.Symbol,
Conf.Battery.Color,
Conf.Battery.Background,
Conf.Battery.Font, Conf.Battery.Font,
Conf.Battery.FontSize, Conf.Battery.FontSize,
i, i,
chStr, chStr,
Conf.Battery.Color,
Conf.Battery.Background,
Conf.Battery.Font, Conf.Battery.Font,
Conf.Battery.FontSize, Conf.Battery.FontSize,
status, status,

28
main.go
View File

@@ -198,7 +198,9 @@ func main() {
} }
b.FullText += fmt.Sprintf( b.FullText += fmt.Sprintf(
"<span font='%s' size='%s'>CPU: %d°</span>", "<span color='%s' background='%s' font='%s' size='%s'>CPU: %d°</span>",
Conf.CPUTemp.Color,
Conf.CPUTemp.Background,
Conf.CPUTemp.Font, Conf.CPUTemp.Font,
Conf.CPUTemp.FontSize, Conf.CPUTemp.FontSize,
CPUTemperature, CPUTemperature,
@@ -238,7 +240,9 @@ func main() {
if Conf.Mem.ShowSwap { if Conf.Mem.ShowSwap {
b.FullText += fmt.Sprintf( b.FullText += fmt.Sprintf(
"<span font='%s' size='%s'>M:%d%% SHM:%dM SW:%dM</span>", "<span color='%s' background='%s' font='%s' size='%s'>M:%d%% SHM:%dM SW:%dM</span>",
Conf.Mem.Color,
Conf.Mem.Background,
Conf.Mem.Font, Conf.Mem.Font,
Conf.Mem.FontSize, Conf.Mem.FontSize,
Memory.Usedpct, Memory.Usedpct,
@@ -247,7 +251,9 @@ func main() {
) )
} else { } else {
b.FullText += fmt.Sprintf( b.FullText += fmt.Sprintf(
"<span font='%s' size='%s'>M:%d%% SHM:%dM</span>", "<span color='%s' background='%s' font='%s' size='%s'>M:%d%% SHM:%dM</span>",
Conf.Mem.Color,
Conf.Mem.Background,
Conf.Mem.Font, Conf.Mem.Font,
Conf.Mem.FontSize, Conf.Mem.FontSize,
Memory.Usedpct, Memory.Usedpct,
@@ -288,7 +294,9 @@ func main() {
} }
b.FullText += fmt.Sprintf( b.FullText += fmt.Sprintf(
"<span font='%s' size='%s'>LA:%s</span>", "<span color='%s' background='%s' font='%s' size='%s'>LA:%s</span>",
Conf.LA.Color,
Conf.LA.Background,
Conf.LA.Font, Conf.LA.Font,
Conf.LA.FontSize, Conf.LA.FontSize,
La, La,
@@ -327,7 +335,9 @@ func main() {
} }
b.FullText += fmt.Sprintf( b.FullText += fmt.Sprintf(
"<span font='%s' size= '%s'>%s</span>", "<span color='%s' background='%s' font='%s' size= '%s'>%s</span>",
Conf.NetIf.Color,
Conf.NetIf.Background,
Conf.NetIf.Font, Conf.NetIf.Font,
Conf.NetIf.FontSize, Conf.NetIf.FontSize,
IfStatus, IfStatus,
@@ -366,7 +376,9 @@ func main() {
} }
b.FullText += fmt.Sprintf( b.FullText += fmt.Sprintf(
"<span font='%s' size='%s'>%s</span>", "<span color='%s' background='%s' font='%s' size='%s'>%s</span>",
Conf.Vpn.Color,
Conf.Vpn.Background,
Conf.Vpn.Font, Conf.Vpn.Font,
Conf.Vpn.FontSize, Conf.Vpn.FontSize,
VPNStatus, VPNStatus,
@@ -476,7 +488,9 @@ func main() {
} }
b.FullText += fmt.Sprintf( b.FullText += fmt.Sprintf(
"<span font='%s' size='%s'>%s</span>", "<span color='%s' background='%s' font='%s' size='%s'>%s</span>",
Conf.Clock.Color,
Conf.Clock.Background,
Conf.Clock.Font, Conf.Clock.Font,
Conf.Clock.FontSize, Conf.Clock.FontSize,
Clock, Clock,

View File

@@ -68,10 +68,18 @@ func UpdateVolumeInfo() {
} }
SoundVolume = fmt.Sprintf( SoundVolume = fmt.Sprintf(
"<span font='%s' size='%s'>%s</span><span font='%s' size='%s'>:%d%%</span>", "<span color='%s' background='%s' font='%s' size='%s'>%s</span>",
Conf.SimpleVolumePa.Color,
Conf.SimpleVolumePa.Background,
Conf.SimpleVolumePa.SymbolFont, Conf.SimpleVolumePa.SymbolFont,
Conf.SimpleVolumePa.SymbolFontSize, Conf.SimpleVolumePa.SymbolFontSize,
Conf.SimpleVolumePa.Symbol, Conf.SimpleVolumePa.Symbol,
)
SoundVolume += fmt.Sprintf(
"<span color='%s' background='%s' font='%s' size='%s'>:%d%%</span>",
Conf.SimpleVolumePa.Color,
Conf.SimpleVolumePa.Background,
Conf.SimpleVolumePa.Font, Conf.SimpleVolumePa.Font,
Conf.SimpleVolumePa.FontSize, Conf.SimpleVolumePa.FontSize,
int64(vol*100), int64(vol*100),