3 tools to display Linux laptop battery information from the command line

This article explains how to display Linux laptop battery information from the command line. Using the tools below, you will be able to check the current battery discharge rate, battery capacity (current, full and design), current battery voltage, temperature, etc.

1. Use battop to get the notebook battery information from the command line.

bat , Or rust-battop is an interactive viewer similar to top, htop and other such utilities, but for battery information/statistics.

The tool can run on Linux, macOS, FreeBSD and DragonflyBSD (Windows is not yet supported), and supports a variety of batteries. As for the information it can display, this includes charging status, voltage, battery discharge rate, temperature (although this does not work for my laptop), battery capacity information (current, full time and complete design), full time/empty, Charge cycle count and so on.

To install battop, get the binaries from the tool’s GitHub Publish page And place it in your home folder.Next, install it to /usr/local/bin :

                        sudo install battop-* /usr/local/bin/battop

You can also install battop from AUR on Arch Linux Manjaro, or use cargo from the source code.Look This page Details.

After installation, to view the battery status and various information, just type battop In a terminal.

You may also like: How to limit battery charging of ASUS laptops on Linux (set charging threshold)

2. Use UPower to get Linux laptop battery information.

UPower is an abstraction used to enumerate power devices, listen to device events, and query historical and statistical information.It comes with a command line tool (also known as power supply ), among other things, allows querying battery history and statistics.

To use the UPower command line tool to get information/statistics about the battery of a Linux laptop, the first thing you need to do is to find out the battery path.This can be done with UPower --enumerate ( -e ) Command line flag, used to enumerate the object path of the device:

                        upower -e

This is the command output from my Asus laptop:

                        $ upower -e/org/freedesktop/UPower/devices/line_power_AC0/org/freedesktop/UPower/devices/battery_BAT0/org/freedesktop/UPower/devices/DisplayDevice

The path you are looking for is that contains BAT Finally (it can be BAT0, BAT1, BATT, etc.), the battery path at this time is /org/freedesktop/UPower/devices/battery_BAT0 .

Now that we know the battery path, we can use the UPower command line tool to display information about the laptop battery (replace the path below with your battery path, as described above):

                        upower -i /org/freedesktop/UPower/devices/battery_BAT0

This is how the output of this command finds my Asus laptop:

                        $ upower -i /org/freedesktop/UPower/devices/battery_BAT0  native-path:          BAT0  vendor:               ASUSTeK  model:                ASUS Battery  power supply:         yes  updated:              Wed 19 May 2021 11:13:41 (35 seconds ago)  has history:          yes  has statistics:       yes  battery    present:             yes    rechargeable:        yes    state:               discharging    warning-level:       none    energy:              36.509 Wh    energy-empty:        0 Wh    energy-full:         42.982 Wh    energy-full-design:  50.002 Wh    energy-rate:         12.969 W    voltage:             11.877 V    time to empty:       2.8 hours    percentage:          84%    capacity:            85.8426%    technology:          lithium-ion    icon-name:          'battery-full-symbolic'  History (charge):    1621412021	84.000	discharging  History (rate):    1621412021	12.969	discharging

You might also like: Bwall is an animated battery wallpaper for Linux (Bash script)

3. Use ACPI to get battery information from the command line.

Another way to display the battery status from the command line on Linux is to use ACPI.This shows from /proc or /sys File system, such as battery status or thermal information.

The acpi command line tool may not be installed by default. To install it, use:

                        sudo apt install acpi

  • Fedora hat:
                        sudo dnf install acpi

  • Arch Linux / Manjaro:
                        sudo pacman -S acpi

To display all available battery information via ACPI, run:

                        acpi -V

This is the command output from my laptop:

                        $ acpi -VBattery 0: Discharging, 81%, 02:35:35 remainingBattery 0: design capacity 4209 mAh, last full capacity 3618 mAh = 85%Adapter 0: off-lineThermal 0: ok, 48.0 degrees CThermal 0: trip point 0 switches to mode critical at temperature 103.0 degrees CCooling 0: Processor 0 of 3Cooling 1: SEN3 no state information availableCooling 2: Processor 0 of 3Cooling 3: pch_cannonlake no state information availableCooling 4: Processor 0 of 3Cooling 5: x86_pkg_temp no state information availableCooling 6: Processor 0 of 3Cooling 7: INT3400 Thermal no state information availableCooling 8: Processor 0 of 3Cooling 9: SEN2 no state information availableCooling 10: Processor 0 of 3Cooling 11: SEN4 no state information availableCooling 12: Processor 0 of 3Cooling 13: B0D4 no state information availableCooling 14: intel_powerclamp no state information availableCooling 15: iwlwifi_1 no state information availableCooling 16: Processor 0 of 3Cooling 17: SEN1 no state information available

Or you can only use acpi to display the current battery status, charge level, design and full capacity, use acpi -i . Sample output:

                        $ acpi -iBattery 0: Discharging, 68%, 03:42:57 remainingBattery 0: design capacity 4209 mAh, last full capacity 3618 mAh = 85%

You can also query ACPI to obtain specific information, such as displaying battery information only using -b , Display thermal information usage -t Wait. For more information, please refer to the ACPI Help ( acpi -h with man acpi ).

More battery related articles from Linux Uprising:

  • auto-cpufreq is a new CPU speed and power optimizer for Linux
  • TLP 1.3 Linux laptop battery extender released
  • TLPUI is the graphical user interface of the TLP power management tool


Related Posts