Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
6.55k stars 706 forks source link

Battery module no longer instantly updates #2519

Open 7ff04da4aa6ac37197e249299066ac30 opened 1 year ago

7ff04da4aa6ac37197e249299066ac30 commented 1 year ago

Back in version 0.9.17 (I think), the battery module would instantly update whenever I plugged or unplugged the charger on my notebook (I have it set up so that the background color for the module changes on toggling charging). However, through no fault of my own (I assume, since I didn't touch my configuration), this is no longer the case: the module now seems to update at the default interval of 60 seconds.

How do I revert this? Or, at least, change my config so that it goes back to how it was, toggling instantly on plugging/unplugging the charger without setting the interval to something like a few seconds (I don't want constant polling).

aspizu commented 1 year ago

Can recreate on Arch Linux. Waybar v0.9.22

hcur commented 1 year ago

I'm not affiliated with this project but I wrote a bit about what worked for me here: #2444

Lassebq commented 1 year ago

It used to update instantly!?

monomycelium commented 1 year ago

I've been facing the same issue as well… Is there a way to subscribe to changes in the battery state?

timblaktu commented 1 year ago

Same here on:

Waybar v0.9.22-82-g4c0347d9 (branch 'master')
OS: Arch Linux x86_64
Host: 21DCCTO1WW ThinkPad P1 Gen 5
Kernel: 6.5.5-arch1-
Shell: zsh 5.9
Resolution: 3840x2160
DE: Hyprland
WM: sway
CPU: 12th Gen Intel i7-12700H (20) @ 4.600GHz
GPU: NVIDIA RTX A1000 Laptop GPU
Memory: 21135MiB / 64082MiB

In my case, the unplugged event is still handled by waybar within 2-3 sec, but the plugged event is never handled. I have no interval set in my battery config, BTW, of course setting this works around the issue by forcing polling.

I worked around it without polling by reloading waybar from my acpi event handler script, which I have handling button presses on my Thinkpad p1g5 laptop..

kira-bruneau commented 11 months ago

I noticed the same thing, but I don't think the regression was introduced in sway. I'm still seeing it in 0.9.17.

The battery module uses inotify to watch for accesses to the power supply's uevent file:

https://github.com/Alexays/Waybar/blob/48ec834ec9c7cdf146169c8b0f669ce1e9a8849e/src/modules/battery.cpp#L127

but it should be using netlink to listen to changes: https://unix.stackexchange.com/questions/579460/why-doesnt-inotifywait-report-modifications-made-to-battery-capacity-file.

I have a feeling that this used to work because something would trigger an IN_ACCESS event, but doesn't anymore.