Acpi

 view release on metacpan or  search on metacpan

Battery.pm  view on Meta::CPAN

	
	my($charge) = sprintf("%.1f",100*$self->getRemainingTotal/$self->getLastFullTotal);

	return $charge;
}

sub getHoursLeft{
	my($self) = shift;
	
	my($hoursleft) = sprintf("%d",$self->getRemainingTotal/$self->getPresentRateTotal);
	
	return $hoursleft;
}

sub getMinutesLeft{
	my($self) = shift;
	my($remaining) = $self->getRemainingTotal;
	my($presentrate) = $self->getPresentRateTotal;
	my($hoursleft) = sprintf("%d",$self->getHoursLeft);

	my($minutesleft) = sprintf("%d",60 * ($remaining - $presentrate * $hoursleft)/$presentrate);

	return $minutesleft;
}
1;

__END__

=head1 NAME

Acpi::Battery - A class to get informations about your battery.

=head1 SYNOPSIS

use Acpi::Battery;

$battery = Acpi::Battery->new;

if($battery->batteryOnLine == 0){

	print "Battery online\n";
	
	print $battery->getCharge."\n"; 
	
	print "Time remaining ".$batteyr->getHoursLeft.":".$battery->getMinutesLeft."\n";

}

else{

print "Battery offline\n";

}

=head1 DESCRIPTION

Acpi::Battery is used to have information about your battery.It's specific for GNU/Linux

=head1 METHOD DESCRIPTIONS

This sections contains only the methods in Battery.pm itself.

=over

=item *

new();

Contructor for the class

=item *

getBatteryInfo();

Return a hash composed by the name of the battery and the information find in /proc/acpi/battery/BATX/info.

Takes 1 arg :

=over

=item 0

The information that you would find !!

=back

=item *

getBatteryState();

Return a hash composed by the name of the battery and the information find in /proc/acpi/battery/BATX/state.

Takes 1 arg :

=over

=item 0

The information that you would find !!

=back

=item *

batteryOnLine();

Return 0 if the battery is online else -1.

=item *

nbBattery();

Return the number of battery present.

=item *

getCharge();

Return the pourcentage of the battery.

=item *



( run in 2.052 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )