Custom battery module for polybar
I made this hack as the built-in battery module failed to display the battery status correctly after waking up from suspend.
[module/custom-battery] type = custom/script exec = acpi -b | cut -d' ' -f3-5 | sed 's/Unknown/Charging/g' | sed 's/^/ /' tail = true interval = 30
This updates the battery status every 30 seconds (as set by
sed 's/Unknown/Charging/g' was needed because on my system
Unknown instead of
Charging for some reason.
Don't forget to add
custom-battery to the list of modules in use. Example:
[bar/it] ; ... modules-right = wireless-network wired-network cpu memory pulseaudio custom-battery date
On my system, the output looks like:
Charging, 95%, 00:14:04
Discharging, 94%, 01:54:47