mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-28 14:07:47 -04:00
The battery popout already surfaces the UPower energy rate, but the bar widget could only show percentage and remaining time, so telling how fast the battery is charging or draining meant opening the popout (or running a third-party plugin that polls /sys/class/power_supply). Add two independent, opt-in toggles to the battery widget - "Show Charge Rate" and "Show Discharge Rate" - that render the signed rate next to the existing text, e.g. "+28W" while charging and "77% (2h 11m) -19W" while draining. Both default to off, and follow the established pattern: a global default in SettingsData plus a per-widget-instance override. The value comes from BatteryService.changeRate, so there is no extra process or polling. It hides itself when the rate is below 0.05W (idle, fully charged, or sitting at a charge limit) so it costs no bar space unless it has something to say. Precision adapts to keep the pill narrow: one decimal below 10W, whole watts above; vertical bars get a whole-watt line.