1 Replies - 1324 Views - Last Post: 09 November 2008 - 08:49 AM

#1 Nova Dragoon  Icon User is offline

  • The Innocent Shall Suffer, Big Time
  • member icon

Reputation: 36
  • View blog
  • Posts: 6,169
  • Joined: 16-August 01

Battery Life

Posted 06 April 2005 - 07:18 PM

Description: Needs gawk, cut, cat, and grep. Copy to a text file in a directory in your path. Chmod it to executable. You need acpi compiled into your kernel or added as a module. This works for my toshiba satellite running 2.6.8 kernel. Adjust if your device info gets put into /proc differently.Prints out the % of laptop battery remaining.
#/bin/bash
CAPACITY=`cat /proc/acpi/battery/BAT1/info | grep "last full capacity" | cut -d" " -f9`
CURRENT=`cat /proc/acpi/battery/BAT1/state | grep "remaining" | cut -d" " -f8`
PERCENT=`gawk -v CONVFMT="%12.2f" -v OFMT="%.5g"  "BEGIN { print $CURRENT / $CAPACITY * 100; }"`
echo Battery: $PERCENT%



Is This A Good Question/Topic? 0
  • +

Replies To: Battery Life

#2 weespat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-November 08

Re: Battery Life

Posted 09 November 2008 - 08:49 AM

Awesome, I need this XD
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1