Monday, June 30, 2008

Battey Stats

There are ready made panel applets available for viewing your battery remaining, current state and others.. Well here I give you more geekier an efficient way of doing that .. CLI ofcourse :
  1. Know your battery's specification :
    $ cat /proc/acpi/battery/BAT0/info

  2. Know your current battery status :
    $ cat /proc/acpi/battery/BAT0/state
    NOTE: BAT0 may differ as per your Laptop model, look for what you have got in /proc/acpi/battery directory.


I have made a small script for Battery Status :
#!/bin/bash
# Battery Status by GNUger

current=`grep remaining /proc/acpi/battery/BAT0/state | awk {'print $3'}`
total=`grep "design capacity:" /proc/acpi/battery/BAT0/info | awk {'print $3'}`

percent=$[100*$current/$total]

echo `grep charging /proc/acpi/battery/BAT0/state | awk {'print $3'}` $percent%
Attached the script file here

TIP: You can add this script in conkyrc file

No comments: