We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4920 - Wider support for seconds of battery life left on Linux platforms using sys interface
Summary: Wider support for seconds of battery life left on Linux platforms using sys i...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: 2.0.10
Hardware: All Linux
: P2 enhancement
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-27 11:57 UTC by Murad
Modified: 2019-12-30 21:22 UTC (History)
0 users

See Also:


Attachments
wider support for battery lifetime data on Linux platforms using sys interface (1.28 KB, patch)
2019-12-27 11:57 UTC, Murad
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Murad 2019-12-27 11:57:35 UTC
Created attachment 4140 [details]
wider support for battery lifetime data on Linux platforms using sys interface

On my system, SDL_GetPowerInfo() returns -1 seconds of battery life left. I have quickly investigated that in my case SDL uses sys interface to get battery data. It tries to read "time_to_empty_now" file which is not always present. However, it is still possible to calculate remaining lifetime using "energy_now" and "power_now" files. This is what my simple patch (included as attachment) tries to accomplish.
Best wishes.
Comment 1 Murad 2019-12-27 12:05:25 UTC
This is my first contribution to any oss project ever, so, please, point me kindly at any mistake I have made. Thanks!
Comment 2 Sam Lantinga 2019-12-30 21:22:08 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/8a12cc1abc9e