Polybar battery module not loading

Hi everyone; sorry to make this post since I’ve seen my fair share of Reddit and forum posts here on how to fix it but nothing’s worked yet…so here I am!

Like a lot of other people, I’m struggling with getting Polybar to recognize the battery module in the config.ini file.

Here’s what the battery portion looks like in my file:

type = internal/battery
full-at = 100
low-at = 20
battery = BAT1
adapter = AC
poll-interval = 5
time-format = %H:%M
format-charging = <label-charging>
format-discharging = <label-discharging>

And here’s what the ls -1 /sys/class/power_supply/ command retrieves:

$ ls -1 /sys/class/power_supply/

This is the specific error I’m getting from Polybar:

error: Disabling module "battery" (reason: No suitable way to get current charge state)

And yes, I promise it’s in the module list!

modules-left = xworkspaces xwindow
modules-right = battery filesystem pulseaudio xkeyboard memory cpu wlan eth date

In a Reddit post I stumbled across someone asked the OP if their battery folder had a file called energy_now, which mine does have. But OP had a different problem that was fixed through different means, so I’m at a loss again.

I’m new to Linux so apologies if this is a pretty straight-forward answer, I just don’t have much of a background. Here’s to learning though!

It could be a polybar issue with new laptop models. Please, post info about your system.

I would suggest you post a bug report at polybar bug tracker.

Thanks for replying, I appreciate it! My laptop is a refurbed Panasonic Let’s Note NX4. According to backmarket these are from 2012? The laptop uses an intel i5-5300U processor (not sure if that’s relevant here but just in case…)

I’ll make a bug report in case this doesn’t help. :slight_smile:

I have nothing to comment, apart from this vendor is not exactly a traditional PC company, whatever might that can mean. :person_shrugging:

Unless you can do a good troubleshooting, inspecting journal and other logs, I would suggest you use some alternative solution, like cbatticon.

I think that you must define <label-charging> and <label-discharging> with something like :

label-charging = " %percentage%% "
label-discharging = " %percentage%% "

You can even add custom icons or text in this label.

I tried this out, sadly it didn’t work, but thanks for the suggestion. I’ll probably try my hand at the troubleshooting thing later and submit a bug report.

EDIT (this specific part isn’t applicable to your response but I didn’t want to double post): This specific model looks like it has the ability to swap out the external battery kind of like the earlier ThinkPads could, could that have something to do with it??

Does it work with this module (you will probably need to install acpi) ?

exec=acpi | cut -d ' ' -f 4 |grep -E "*%" 2>/dev/null

I think this fixed it!! Thank you so much. The order of the modules seems kind of weird, but that’s a task for later.


Also, cbatticon works perfectly.

Thank you everyone!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.