[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Issue with notebook (maybe the battery?)



On Wed 24 May 2017 at 21:50:20 (-0300), Daniel Bareiro wrote:

> When you talk about "the numbers", do you mean to see by the console the
> values that are obtained for both batteries (voltage, for example) to
> make a comparison?

Yes, the bash function I use is:

battery () 
{ 
    local BATTERYFILE="/sys/class/power_supply/BAT0/uevent";
    [ ! -r $BATTERYFILE ] && printf '%s\n' "$BATTERYFILE not found!" && return 1;
    date +%Y-%m-%d-%H-%M-%S;
    cat $BATTERYFILE;
    local FILEBATNOW="/sys/class/power_supply/BAT0/charge_now";
    local FILEBATPREV="/sys/class/power_supply/BAT0/charge_full";
    local CHARGE=$(( 100 * $(< $FILEBATNOW) / $(< $FILEBATPREV) ));
    [ $CHARGE -lt 100 ] && printf '%s\n' "Charge: $CHARGE%"
}

AIUI uevent gives you the lot, which varies by model etc.
so just   cat /sys/class/power_supply/BAT0/uevent
should do it, with and without the power supply connected.

(I run a slightly more sophisticated version that also
reads the CPU temperature, has error trapping, and changes
the root window colour according to battery state and,
if frying, temperature.)

Cheers,
David.


Reply to: