Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

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.

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 interval).

sed 's/Unknown/Charging/g' was needed because on my system acpi outputs Unknown instead of Charging for some reason.

Don't forget to add custom-battery to the list of modules in use. Example:

; ...
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.