Skip to content

Make battery module update on plugging/unplugging again (refs #2519) - #3474

Merged
Alexays merged 1 commit into
Alexays:masterfrom
schmop:battery-plugging-instant-updates
Jan 25, 2025
Merged

Alexays merged 1 commit into
Alexays:masterfrom
schmop:battery-plugging-instant-updates

Conversation

@schmop

@schmop schmop commented Jul 24, 2024

Copy link
Copy Markdown
Contributor

When switching how you listen for battery plugging status events, the battery status will instantly update again!
Instead of inotify events on the /sys/class/.../ files, it is recommended to listen to udev netlink kernel events.

Closes #2444
Closes #2519

I need aid implementing this, because I'm new to this project.
I will try to make this code look more like the backlight_backend, which also uses the udev netlink interfaces.

@schmop schmop changed the title PoC: Use udev polling of netlink kernel events for battery plugging events (refs #2519) PoC: Make battery module update on plugging/unplugging again (refs #2519) Jul 24, 2024
Historically we listened to /sys/class/poewr_supply inotify events,
which does not seem to work anymore.
We switched now to udev netlink kernel events.
@schmop
schmop force-pushed the battery-plugging-instant-updates branch from a519c0c to f4608b3 Compare July 26, 2024 23:19
@schmop schmop changed the title PoC: Make battery module update on plugging/unplugging again (refs #2519) Make battery module update on plugging/unplugging again (refs #2519) Jul 26, 2024
@schmop

schmop commented Jul 26, 2024

Copy link
Copy Markdown
Contributor Author

So it seems, that the udev kernel events are sent very early. The battery status "Charging" might return just a bit later from the /sys/class/powersupply/BAT0/status path, than the last event is received.
For my setup, this will result in a "Plugged in" (but not charging) state :(

When implementing some sleep(1) this race condition does not occur anymore, but this cannot be a solution.

@Alexays
Alexays force-pushed the master branch 2 times, most recently from d623a89 to a4d31ab Compare September 13, 2024 07:40
@schmop

schmop commented Nov 27, 2024

Copy link
Copy Markdown
Contributor Author

Might also
Closes #3726
Closes #3603
Closes #3471

@Jajasek

Jajasek commented Jan 24, 2025

Copy link
Copy Markdown

Hi, this looks awesome. @Alexays would you consider accepting this PR?

@Alexays

Alexays commented Jan 25, 2025

Copy link
Copy Markdown
Owner

LGTM.

@Alexays

Alexays commented Jan 25, 2025

Copy link
Copy Markdown
Owner

Reverted, FreeBSD is failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Battery module no longer instantly updates Battery state doesn't change unless explicitly refreshed with a click event

3 participants