How to check your laptop battery from the Linux command-line
Battery Top is an excellent application that Linux users can install to monitor their laptop’s battery status. In this guide, we’ll go over how to install Battery Top on Linux and how to use it too.
Installing Battop on Linux
Before you can use Battery Top (Battop) to check the health of your Linux PC, you’ll need to install the program on your computer. Three ways to set up the Battop application on Linux are Arch Linux AUR, from source, and a downloadable binary. We’ll cover all three in this guide.
To start the installation process for Battop, begin by opening up a terminal window. You can launch a terminal window by pressing Ctrl + Alt + T on the keyboard. Alternatively, search for “Terminal” in the app menu and launch it that way.
With the terminal window open and ready to use, it is time to install Battop. Follow the installation instructions below that corresponds with the Linux method you prefer.
Arch Linux AUR
If you’re an Arch Linux user, you’ll be able to install Battop from the Arch Linux User Repository. To start the installation process, install the “git” and “base-devel” packages using the pacman -S command.
sudo pacman -S git base-devel
With the two packages set up, you’ll need to use the git clone command to download the latest release of Trizen. The Trizen application will make setting up Battop easier on your Linux PC, so you do not have to do it manually.
git clone https://aur.archlinux.org/trizen.git
After downloading the Trizen release package to your Arch Linux system, use the cd command to move into the “trizen” folder. This folder has all of the Trizen AUR installation files.
cd trizen/
Once inside the “trizen” folder, use the makepkg command to install the Trizen software on your Linux PC.
makepkg -sri
With the Trizen application set up, you can use the trizen -S command to install the Battop app.
trizen -S battop
From source
The Battop application is built with the Rust programming language. As a result, it is straightforward to compile the program on any Linux OS system. To start the compilation, use the git clone command to download the software.
Note: if you do not have the “git” tool installed, install it here. You’ll also need Rust.
Once you’ve got both Git and Rust set up, use the git clone command to download the software to your computer.
git clone https://github.com/svartalf/rust-battop.git
After downloading the software to your computer, use the cd command to move into the “rust-battop” folder on your computer.
cd rust-battop
Finally, compile the software on your system using the cargo command.
cargo build --release
Binary
There’s a pre-compiled binary of Battop available on the “releases” page. This binary is best to use if you can’t get the AUR or the compiled release of Battop working.
To get your hands on Battop, use the following wget command.
wget https://github.com/svartalf/rust-battop/releases/download/v0.2.4/battop-v0.2.4-x86_64-unknown-linux-gnu -O battop
After downloading the software to your computer, install it to the /usr/bin/ directory.
sudo mv battop /usr/bin/
Update the permissions of the file with the chmod command.
sudo chmod +x /usr/bin/battop
How to check your laptop battery with Battop
You’ll need a terminal window to check your laptop battery with the Battop application. Open up a terminal window on the Linux desktop by pressing Ctrl + Alt + T on the keyboard.
Once the terminal window is open and ready to use, follow the step-by-step instructions below.
Step 1: Using the terminal window, run the sudo -s command. This command will allow you to gain a root shell. A root shell is essential, as it will allow the Battop application to access all system-level hardware.
sudo -s
Step 2: After gaining root access, you can run the battop command to start monitoring your battery. The default operation for the Battery Top application is human-readable numbers. If you wish to change these numbers, you can run battop -u si instead.
battop
Or
battop -u si
Step 3: Allow the Battop application to run for a while. As you do, it will start to fill out graphs about your battery’s health. After leaving it to sit for a while, maximize the terminal to fit the entire screen on your Linux PC.
Step 4: After selecting the “Maximize” button with the mouse, the terminal window will fill the entire screen. Now, find the Prnt Scrn button on the keyboard and select it to take a screenshot of your battery information.
Step 5: Upon selecting the Prnt Scrn button with the mouse, the screenshot app on the Linux desktop will save an image of the desktop. Save this image for your records, so you can regularly view your battery health.
Alternatively, re-run the battop command anytime you wish to check your battery.