public function getBattery()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Batteries');
        }

        // Store them here
        $batts = [];

        // Get result of program
        try {
            $res = $this->exec->exec('apm', '-abl');
        } catch (Exception $e) {
            Errors::add('Linfo Core', 'Error using `apm` battery info');

            return $batts;
        }

        // Values from program
        list(, $bat_status, $percentage) = explode("\n", $res);

        // Interpret status code
        switch ($bat_status) {
            case 0:
                $status = 'High';
            break;
            case 1:
                $status = 'Low';
            break;
            case 2:
                $status = 'Critical';
            break;
            case 3:
                $status = 'Charging';
            break;
            default:
                $status = 'Unknown';
            break;
        }

        // Save battery
        $batts[] = array(
            'percentage' => $percentage.'%',
            'state' => $status,
            'device' => 'battery',
        );

        // Return
        return $batts;
    }
public function getBattery()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Batteries');
        }

        // Store them here
        $batts = [];

        // Get result of program
        try {
            $res = $this->exec->exec('apm', '-abl');
        } catch (Exception $e) {
            Errors::add('Linfo Core', 'Error using `apm` battery info');

            return $batts;
        }

        // Values from program
        list(, $bat_status, $percentage) = explode("\n", $res);

        // Interpret status code
        switch ($bat_status) {
            case 0:
                $status = 'High';
            break;
            case 1:
                $status = 'Low';
            break;
            case 2:
                $status = 'Critical';
            break;
            case 3:
                $status = 'Charging';
            break;
            default:
                $status = 'Unknown';
            break;
        }

        // Save battery
        $batts[] = array(
            'percentage' => $percentage.'%',
            'state' => $status,
            'device' => 'battery',
        );

        // Return
        return $batts;
    }
public function getBattery ( ) { // Time? if ( ! empty ( $ this -> settings [ 'timer' ] ) ) { $ t = new Timer ( 'Batteries' ) ; } // Store them here $ batts = [ ] ; // Get result of program try { $ res = $ this -> exec -> exec ( 'apm' , '-abl' ) ; } catch ( Exception $ e ) { Errors :: add ( 'Linfo Core' , 'Error using `apm` battery info' ) ; return $ batts ; } // Values from program list ( , $ bat_status , $ percentage ) = explode ( "\n" , $ res ) ; // Interpret status code switch ( $ bat_status ) { case 0 : $ status = 'High' ; break ; case 1 : $ status = 'Low' ; break ; case 2 : $ status = 'Critical' ; break ; case 3 : $ status = 'Charging' ; break ; default : $ status = 'Unknown' ; break ; } // Save battery $ batts [ ] = array ( 'percentage' => $ percentage . '%' , 'state' => $ status , 'device' => 'battery' , ) ; // Return return $ batts ; }
APM? Seems to only support either one battery of them all collectively
APM? Seems to only support either one battery of them all collectively