Thursday, September 20, 2012

Battery details using Terminal

Recently I installed Xubuntu which being awesome and far better than Ubuntu' s Gnome lacks some of the features like showing estimated battery time remaining.

I tried a lot to  find out a solution for this recently came across a ask Ubuntu thread which describes a way to obtain battery details using Terminal.

Using upower you can get all the battery details.

To view all the details you can use

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

Use grep to remove the unwanted details from the above result

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

You can create alias for the same command so that you can run it using just the alias that you gave

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

To permanently add this to your system terminal just copy paste the same command to .bashrc or /etc/rc.local