NAME
Acpi::Class - Gets ACPI information fom /sys/class directory.
SYNOPSIS
my $class = Acpi::Class->new( class => 'power_supply');
my $devices = $class->g_devices;
print "Power devices: ";
foreach (@$devices) {print "$_ "} print "\n";
$class->device('AC');
my $ac_online = $class->g_values->{'online'};
$class->device('BAT0');
my $values = $class->g_values;
my $battery_present = $values->{'present'};
my $battery_energy_now = $values->{'energy_now'};
my $battery_capacity = $values->{'capacity'};
if ( $ac_online == 1 and $battery_present == 1 )
{
say "Ac on and battery in use ";
say "Energy now = ". $battery_energy_now ;
say "Capacity " . $battery_capacity ." %";
}
elsif ($battery_present)
{
say "Battery in use";
say "Energy now = ". $battery_energy_now ;
say "Capacity " . $battery_capacity ." %";
}
else
{
say "Battery not present";
}
# get all values of device BAT1
say "-" x 50;
$class->p_device_values;
say "-" x 50;
# get all values of class power_supply
$class->p_class_values;
DESCRIPTION
Acpi::Class provides ACPI information from the directory /sys/class. It's specific for GNU/Linux.
ATTRIBUTES
Acpi::Class implements the following attributes:
class
$class = Acpi::Class->new( class => 'thermal');
$class->class('thermal');
Sets the class (directory under /sys/class).
device
$class = Acpi::Class->new( class => 'thermal', device=> 'BAT0' ));
$class->device('BAT0');
Sets the device (directory under /sys/class/$class).
METHODS
Acpi::Class implements the following methods:
new
my $class = Acpi::Class->new( class => 'thermal', device => 'BAT1 );
Object constructor.
g_classes
my $classes = $class->g_classes;
Gets an ArrayRef of the available classes (directories under /sys/class).
g_devices
Gets an ArrayRef of available devices (directories under /sys/class/$class).
g_values
Gets a Hashef of the attributes and values of a device (content of the files in /sys/class/$class/$device).
p_device_values
$class->class('power_supply');
$class->device('BAT1');
$class->p_device_values;
Prints all the attributes and values of the device BAT1.
p_class_values
$class->class('power_supply');
$class->p_device_values;
Print all the attributes and values of the devices in the class 'power_supply'.
COMMUNITY
Get involved:
SEE ALSO
The modules Acpi::Battery, Acpi::Fan and Acpi::Temperature get the information from the directory /proc/acpi. This directory is deprecated in Linux kernel 2.6.24 and deleted in 2.6.39.