hs7sv
  
 
 
  
 
 
Group: Members 
Posts: 247 
Joined: June 2005 | 
  | 
Posted: Mar. 07 2006,02:38 | 
   | 
 
 
  
I searched for torsmo ACPI and found ACPI Battery stats for the command line. It is written in perl script. I tested it on my laptop. It works!  
  This script is a modified version of battstate.pl that I'm using:-
 | Code Sample  |  #!/usr/bin/perl # # This is somem messy Perl script, but hey, # it works. If you somehow stuble upon this # code, then please note that you may have to # change certain paths, such as BAT0, depending # on how many batteries you have. Also, note # that this script has only been tested with # ACPI and not APM. # # Enjoy! :-) # # written by ateam (derek@backdrifts.net) # # modified for DSL-2.1b by hs7sv (paphons@gmail.com)
  chop (@info = `cat /proc/acpi/battery/BAT0/state`); chop (@capacity = `cat /proc/acpi/battery/BAT0/info`);
  chop ($left = @info[4]); chop ($left = `echo \"$left\" | awk '{ print \$3 }'`);
  $state = @info[2]; chop ($state = `echo \"$state\" | awk '{ print \$3 }'`);
  chop ($full = @capacity[1]); chop ($full = `echo \"$full\" | awk '{ print \$3 }'`);
  $remain = $left / $full * 100; $remain = int ($remain);
  chop (@time = `cat /proc/acpi/battery/BAT0/state`); chop (@time2 = `cat /proc/acpi/battery/BAT0/info`);
  $rcap = @time[4]; chop ($rcap = `echo \"$rcap\" | awk '{ print \$3 }'`);
  $prate = @time[3]; chop ($prate = `echo \"$prate\" | awk '{ print \$3 }'`);
  if ($prate > 0) {    if ($state eq "discharging")    {          $seconds = $rcap / $prate * 60 * 60;    }
     elsif ($state eq "charging")    {          $seconds = ($full - $rcap) / $prate * 60 * 60;    }
      $minutes = sprintf("%.2f", $minutes);
      $hours = $seconds / 60 / 60;     $hours = sprintf("%.2f", $hours);
      chop ($singhour = $hours);     chop ($singhour);     chop ($singhour);
      $hourmins = $hours;
      $hourmins =~ s/^.//;     $hourmins =~ s/^.//;
      $hourmins = $hourmins * .6;     $hourmins = sprintf("%.0f", $hourmins); } else {     $seconds = 0; }
  if ($singhour >= 1) {     print " $singhour"; }
  if ($hourmins >= 1) {     if ($singhour < 1)     {         print " 0";     }
      if ($hourmins < 10)     {         print ":0$hourmins";     }     else     {         print ":$hourmins";     }     print " remains" } else {     print " A:C"; }
  print "\n";
  if ($state eq "charged") {     $printstate = "AC on-line"; } elsif ($state eq "discharging" and $rcap eq $full) {     $printstate = "AC on-line"; } elsif ($state eq "charging") {     $printstate = "AC on-line and charging"; } elsif ($state eq "discharging") {     $printstate = "AC unplugged"; }
  print " $remain%, $printstate"; |  
  It can be executed in your ~/.torsmorc file quite simply.   | Code Sample  |  | ${color grey}Battery:  $color${exec perl /home/dsl/battstate.pl} |    
  -------------- "My advice is to just  return hardware that does not work with a plain Linux kernel, right to the place where you bought it, and ask for your money back..." 
  Klaus Knopper
 |