Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #181357

Re: Issue with notebook (maybe the battery?)

From David Wright <deblis@lionunicorn.co.uk>
Newsgroups linux.debian.user
Subject Re: Issue with notebook (maybe the battery?)
Date 2017-05-25 03:30 +0200
Message-ID <tKPLb-1uq-7@gated-at.bofh.it> (permalink)
References (5 earlier) <tq4lP-3iY-9@gated-at.bofh.it> <tq4Yy-3SP-23@gated-at.bofh.it> <tKEd4-2Lr-31@gated-at.bofh.it> <tKOP8-TD-3@gated-at.bofh.it> <tKPi9-14X-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Issue with notebook (maybe the battery?) Daniel Bareiro <daniel-listas@gmx.net> - 2017-05-24 15:10 +0200
  Re: Issue with notebook (maybe the battery?) Fungi4All <fungilife@protonmail.com> - 2017-05-24 17:20 +0200
    Re: Issue with notebook (maybe the battery?) David Wright <deblis@lionunicorn.co.uk> - 2017-05-25 03:00 +0200
  Re: Issue with notebook (maybe the battery?) David Wright <deblis@lionunicorn.co.uk> - 2017-05-25 02:30 +0200
    Re: Issue with notebook (maybe the battery?) Daniel Bareiro <daniel-listas@gmx.net> - 2017-05-25 03:00 +0200
      Re: Issue with notebook (maybe the battery?) David Wright <deblis@lionunicorn.co.uk> - 2017-05-25 03:30 +0200
        Re: Issue with notebook (maybe the battery?) Daniel Bareiro <daniel-listas@gmx.net> - 2017-05-28 03:00 +0200
          Re: Issue with notebook (maybe the battery?) David Wright <deblis@lionunicorn.co.uk> - 2017-06-02 21:40 +0200

csiph-web