The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Sys::Ibam - Perl extension for the intellegent battery monitor

SYNOPSIS

  use Sys::Ibam;

  my $ibam = Sys::Ibam->new();

  $ibam->update();
  if ($ibam->valid()) {
    $ibam->update_statistics();
  } else {
    $ibam->ignore_statistics();
  }
  $ibam->save();

DESCRIPTION

Sys::Ibam is a Perl extension for the ingellegent battery monitor by Sebastian Ritterbusch <Sebastian@Ritterbusch.de>. It uses statistical and adaptive linear methods to provide accurate estimations of minutes of battery left or of the time needed until full recharge. It requires /proc/apm or /proc/pmu/.

METHODS

new

  my $ibam = Sys::Ibam->new();
  my $ibam = Sys::Ibam->new($do_second_correction);

Returns a new ibam instance. If $do_second_correction is true then the return value of seconds_{battery,charge}_correction() will be automatically added to when calling seconds_left_{battery,charge}{,_adaptive}().

import_old_data

  $ibam->import_old_data();

Imports version 0.1 data from the current directory.

update_statistics

  $ibam->update_statistics();

Updates statistics of the ibam instance. You should call save() after calling update_statistics() to write the new statistics to disk.

ignore_statistics

  $ibam->ignore_statistics();

Ignores the new data read by update. You should call ignore_statistics() if the ibam data is invalid or if you don't want the data generated with the last update to be part of the statistics, which will be written to disk.

save

  $ibam->save();

Saves the current statistics to disk.

profile_filename

  my $filename = $ibam->profile_filename(4, 'battery');

Takes a profile number (between 0 and 500) and a string. The string tells the type of the profile. 'battery', 'charge', 'full' and '' (no battery) are valid. It returns the correspondent filename of the profile or undef if the type is invalid.

current_profile_number

  my $num = $ibam->current_profile_number();

Returns the current profile number.

current_profile_type

  my $type = $ibam->current_profile_type();

Returns the current profile type in the same format that can be passed to profile_filename().

set_profile_logging

  $ibam->set_profile_logging(1);

Sets the profile_logging attribute. It'll be enabled if the argument is true or disabled if it's false.

profile_logging_setting

  my $logging = $ibam->profile_logging_setting();

Returns the current value of the profile_logging attibute.

seconds_left_battery_bios

  my $bat = $ibam->seconds_left_battery_bios();

Returns the time left for the battery reported by the bios in seconds.

seconds_left_battery

seconds_left_battery_adaptive

percent_battery_bios

  my $percent = $ibam->percent_battery_bios();

Returns the charge state of the battery reported by the bios.

percent_battery

seconds_left_charge

seconds_left_charge_adaptive

percent_charge

seconds_battery_total

seconds_battery_total_adaptive

seconds_battery_correction

seconds_charge_correction

on_battery

  my $bat_status = $ibam->on_battery();

Returns a true value if we're on battery. If not, it returns false.

charging

  my $charge_status = $ibam->charging();

Returns a true value if the battery is charged right now.

valid

  my $valid = $ibam->valid();

Checks if the data generated by the last update() call is valid. If it is, you should call update_statistics() or ignore_statistics() if it's not. Then you should save the data to disk calling the save() method.

update

  $ibam->update();

Updates ibams data. You should check if it's valid and then update or ignore the statistics.

SEE ALSO

ibam(1)

AUTHOR

Florian Ragwitz <flora@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2004 by Florian Ragwitz

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.