Battery information inside terminal

If you want to know your battery details in terminal use upower and create an alias to it.

This is helpful hack if you want to trigger events on low battery or if you are someone who uses really light desktop managers without a battery indicator.

Upower command can be used to get stats on battery.

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

Grep for the required details.

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

Create an alias, after this step 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 alias to ~/.bashrc or ~/.zshrc file and make it permemanent.

comments powered by Disqus