WinWidgets icon indicating copy to clipboard operation
WinWidgets copied to clipboard

Request for feature: More battery information

Open beyenilmez opened this issue 1 year ago • 2 comments
trafficstars

I noticed onNativeBatteryLevelEvent only returns battery level. However, upon reviewing the code, it appears that additional information such as charging status, full lifetime of battery in seconds, remaining battery life in seconds and power line status can be retrieved too. More detailed widgets can be created with these.

A new event called onNativeBatteryEvent can return a JSON like this. (onNativeBatteryLevelEvent can be renamed to onNativeBatteryEvent too.)

{
batteryChargeStatus: "Charging",
batteryFullLifetime: 18000,
batteryLifePercent: 58,
batteryLifeRemaining : -1,
powerLineStatus: "Online",
}

The template battery widget can be updated to show charging status and remaining battery time with this new event.

I'm willing to create a pull request to implement this.

beyenilmez avatar Dec 13 '23 14:12 beyenilmez

It would be great if you could create a PR! I currently don't have a windows laptop which I can use to test the battery feature.

Doing this would break existing user widgets, but since there's no automatic updates; I think it's ok. I can add a warning to the patch notes that widgets relying on this feature will need to be tweaked.

beyluta avatar Dec 13 '23 17:12 beyluta

I've merged into development for now. Code looks good but I sadly can't test it right now since I don't have a windows laptop at hand. But I will try to get one soon.

beyluta avatar Dec 14 '23 20:12 beyluta