Polybar: Dynamic background color (battery)

Created on 5 Feb 2017  ·  4Comments  ·  Source: polybar/polybar

Is there any option of having different background color of a label depending on battery percentage?
I know can have different background colors with a ramp, but I cannot display a percentage value on top of that:

ramp-capacity-0-background = #75D18581
ramp-capacity-1-background = #75D48F81
...
ramp-capacity-0 = "%percentage%" ; no way :(
configuration feature

Most helpful comment

If anyone is still interested for this, I have been using this workaround:

[module/battery]
type = internal/battery
...
format-charging = <ramp-capacity> <label-charging>%{B-}
format-discharging = <ramp-capacity> <label-discharging>%{B-}
ramp-capacity-0 = %{B#e01212}
ramp-capacity-1 = %{B#e06912}
ramp-capacity-2 = %{B#e0b412}
ramp-capacity-3 = %{B#b7e012}
ramp-capacity-4 = %{B#3be012}
...

2019-10-10-021157_65x36_scrot 2019-10-10-021330_62x31_scrot

As you can see, it is possible to achieve the desired behavior by combining format-tags with ramps.

All 4 comments

That's currently not supported, but it's a good idea to add it.

It would be actually great to have this for other values as well - cpu, memory, etc.

If anyone is still interested for this, I have been using this workaround:

[module/battery]
type = internal/battery
...
format-charging = <ramp-capacity> <label-charging>%{B-}
format-discharging = <ramp-capacity> <label-discharging>%{B-}
ramp-capacity-0 = %{B#e01212}
ramp-capacity-1 = %{B#e06912}
ramp-capacity-2 = %{B#e0b412}
ramp-capacity-3 = %{B#b7e012}
ramp-capacity-4 = %{B#3be012}
...

2019-10-10-021157_65x36_scrot 2019-10-10-021330_62x31_scrot

As you can see, it is possible to achieve the desired behavior by combining format-tags with ramps.

Closing in favor of #1752 and #2223

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eoli3n picture eoli3n  ·  3Comments

oquinena picture oquinena  ·  4Comments

nahson picture nahson  ·  4Comments

faminee picture faminee  ·  4Comments

szymonmaszke picture szymonmaszke  ·  3Comments