Quote:
Originally Posted by isarl
That should work. It doesn't have to be in .adds/ in particular, but that seems like a logical place.
|
Success! Thanks for all the help.

If anyone's interested, here's the script:
Code:
# Battery Statistics Calculator 1.0 (2023-05-18) by Aleron Ives
#
# This script calculates battery statistics for the Kobo Libra 2.
# Check the contents of /sys/class/power_supply/ if you use a different
# model to ensure that the statistics you want to track are available.
#
# You can use NickelMenu to invoke this script like so:
# menu_item :main :Battery :cmd_output :500 :/mnt/onboard/.adds/battcalc.sh
# Gather the necessary statistics
meter=$(cat /sys/class/power_supply/battery/capacity)
v_now=$(cat /sys/class/power_supply/battery/voltage_now)
v_min=$(cat /sys/class/power_supply/battery/voltage_min)
v_max=$(cat /sys/class/power_supply/battery/voltage_max)
c_now=$(cat /sys/class/power_supply/battery/charge_now)
c_full=$(cat /sys/class/power_supply/battery/charge_full)
c_dfull=$(cat /sys/class/power_supply/battery/charge_full_design)
let v_now/=1000; let v_min/=1000; let v_max/=1000 # Convert to V
let c_now/=1000; let c_full/=1000; let c_dfull/=1000 # Convert to mAh
let v_nowr=$v_now%1000; let v_now/=1000 # Simulate floating-point arithmetic
let v_minr=$v_min%1000; let v_min/=1000 # "
let v_maxr=$v_max%1000; let v_max/=1000 # "
let charge=$c_now*100/$c_full # Calculate charge percentage from mAh
let c_health=$c_full*100/$c_dfull # Calculate health percentage from mAh
# Format and display the results
echo Capacity: $c_now mAh / $meter% / $charge%
echo Voltage: $v_min.$v_minr V / $v_now.$v_nowr V / $v_max.$v_maxr V
echo Health: $c_full mAh / $c_dfull mAh / $c_health%
Now you get lots of new inaccurate statistics!

Kobo is using BusyBox with ash, so I had to do some research on how it works, but it seems to be mostly the same as bash. I've attached a picture of the output on the Kobo.
You get the current battery capacity in mAh, the current percentage that the battery icon reports, the current percentage as calculated by the current / maximum mAh, the minimum, current, and maximum battery voltage, and the battery health calculated from the maximum vs the design capacity.