Check Laptop Battery Status on Linux

Check Laptop Battery Status on Linux

Laptops have become an integral part of our daily lives, providing us with the flexibility to work and play on the go. Monitoring the laptop's battery status is crucial to ensure uninterrupted usage. This tutorial demonstrates how to check laptop battery status on Linux.

On Linux operating systems, the /sys/class/power_supply/BAT?/capacity file provides information about the current battery capacity of a laptop or other portable device.

Here's a breakdown of the components in the path:

  • /sys - is the base directory for the sysfs file system, which provides an interface for interacting with kernel and device parameters in a hierarchical manner.
  • class/power_supply - subdirectory contains information about various power supply devices on the system, including batteries.
  • BAT? - is a placeholder representing the battery name. On most Linux systems, there will be a directory named BAT0, BAT1, and so on, for each battery present. The ? is a wildcard that gets replaced by the specific battery index.
  • capacity - is a file that holds the current capacity level of the battery. The capacity is usually represented as a percentage, ranging from 0% (empty) to 100% (fully charged).

You can read the content of the capacity file using various commands such as cat:

cat /sys/class/power_supply/BAT?/capacity

This will output a numerical value representing the current battery capacity percentage. This information can be helpful for monitoring your battery's health and deciding when to charge your device.

Leave a Comment

Cancel reply

Your email address will not be published.