Battery information inside terminal

ยท 1 min read

To check your battery details in the terminal, use upower and create an alias for it.

This is a helpful hack if you want to trigger events on low battery, or if you use a minimal desktop environment without a battery indicator.

The upower command gives battery stats:

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

Grep for the details you need:

upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "state|time|per"

Create an alias; after this you can run the command using the alias bat:

alias bat='upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "state|time|per"'

Add the alias to ~/.bashrc or ~/.zshrc to make it permanent.

terminalbatteryubuntulinux mint