Le Wednesday 06 May 2015 à 14:22 +0200, Jean Delvare a écrit :
The following should work except for the "rate" which isn't mentioned in the sysfs interface. I seem to understand that this isn't considered a property of the battery so you have to derive it yourself from the the other numbers over an arbitrary period.
Would that work for you? #!/bin/bash # Sample time in seconds SAMPLE_TIME=10 declare -a energy_full_design energy_full energy_now sum() { local v=$1 shift s=0; printf "%18s = " "$v" while [ $# -gt 0 ]; do i=$(($1/1000)) printf "%5s " "$i" s=$(($s+$i)) shift done printf " = %s\n" "$s" save=$s } energy_full_design=(`cat /sys/class/power_supply/BAT*/energy_full_design`) energy_full=(`cat /sys/class/power_supply/BAT*/energy_full`) energy_now=(`cat /sys/class/power_supply/BAT*/energy_now`) sum "design capacity" "$energy_full_design" sum "last full capacity" "$energy_full" sum "remaining capacity" "$energy_now" sum_then=$save sleep $SAMPLE_TIME energy_now=(`cat /sys/class/power_supply/BAT*/energy_now`) sum "remaining capacity" "$energy_now" sum_now=$save rate=$((($sum_now-$sum_then)/$SAMPLE_TIME)) printf "%18s = %5s\n" "rate" "$rate" (I'm not necessarily proud of everything in this script.) -- Jean Delvare SUSE L3 Support -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org