0

I am using the command upower -i /org/freedesktop/UPower/devices/battery_BAT0 and acpi -V to check the battery current status. It shows it has history and statistics.

How can I check the history?

I knew there are some apps which can produce a nice graph of the battery history, but that is not what I am looking for. I would like to see the history in a text log. I want to examine the text log with some scripts and editor to determine when the battery status changed etc..

Thanks a lot.

Edited:

If the question is not possible, how to monitor battery state change event? I need to record the battery information whenever the battery/ac state changes. So checking upower or acpi output at a interval time is not sufficient. Thanks.

1 Answer 1

0

I’m not sure whether past data is easily readable, but you can write the current status to a file like this:

upower -i `upower -e | grep 'BAT'` >> history.txt

If you were to put this into a cron job that ran at regular intervals, it may give you what you’re looking for.

1
  • Thanks for this reply. I knew I could do that. But sorry that it is not what I am looking for. Even for logging the current satus, I need to log all change status information. So setting an interval will not satisfy my requirement. I need to log whenever the battery change from discharing to charging, charging to discharging etc.. Basically, I need to monitor the battery status change event. Thanks.
    – sgon00
    Dec 6, 2020 at 15:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .