You must check up on your laptop’s battery often, after all, your battery is what makes your laptop portable. When new, batteries run longer, but over time, it may not be the case. If not looked after properly, your battery may drain faster due to poor usage. This article covers how you can use Ubuntu 20.04 to create detailed battery usage reports.
Viewing the battery report using the Ubuntu UI
You can view your battery report through the UI using Power Statistics. This a very helpful tool that lets you see how much power you use, along with the different trends
The Power Statistics tool comes installed with most Linux distributions, if you don’t have it, you can install it using Ubuntu Software, or using the gnome-power-manager package using the command:
sudo apt-get install gnome-power-manager
You can look for the Power Statistics tool using the Applications Menu.
Search for Power Statistics.
Click the Power Statistics icon. This will take you to the tool.
Click on Laptop Battery to view details.
To view battery history, switch to the History tab. You can view different graphs here by selecting the graph type and data length.
The Statistics tab shows graphs for charge profile, charge accuracy, discharge profile, and discharge accuracy.
Viewing the battery report using the Ubuntu Command Line
Using upower
Run:
$ upower -i `upower -e | grep 'BAT'`
As you can see in the image below, this command shows all the battery details including the model, vendor, serial number, voltage, state, etc.
Another command that shows similar results is:
upower -i /org/freedesktop/UPower/devices/battery_BAT0
To learn more about upower, use
man upower
This will take you to the upower manual where you can view all the different options and their descriptions.
Using acpi
Another command that you can use is the acpi command. You may need to install it first. The command for installing acpi is:
sudo apt-get install acpi
To view battery details, run
acpi –V
You can view the following as a result:
To view the details on a battery charge, use:
acpi
To check the cooling information of your battery, use:
acpi –c
You can check if AC power is connected using:
acpi –a
To learn more about acpi, use:
man acpi
This will take you to the acpi manual where you can view all the different options and their descriptions.
Using TLP
Another tool is TLP. It is free and open-source. To download TLP, use:
sudo apt install tlp
To view battery related information, use:
sudo tlp-stat –b
To view more information, use:
sudo tlp-stat –s
Sysfs File system
The sysfs file system provides information on kernel modules, devices, and other kernel components.
To view battery information, run:
cat /sys/class/power_supply/BAT0/*
In this article, we covered the ways in which you can view detailed information on your battery using both the command line and UI.