/**
  * getBattery 
  * 
  * @access private
  * @return array of battery status
  */
 private function getBattery()
 {
     // Time?
     if (!empty($this->settings['timer'])) {
         $t = new LinfoTimerStart('Batteries');
     }
     // Return values
     $return = array();
     // Here they should be
     $bats = (array) @glob('/sys/class/power_supply/BAT*', GLOB_NOSORT);
     // Get vals for each battery
     foreach ($bats as $b) {
         $go_for_it = true;
         // F**k pointless cuntshit
         foreach (array($b . '/manufacturer', $b . '/status', $b . '/charge_now') as $f) {
             if (!is_file($f)) {
                 $go_for_it = false;
             }
         }
         // Continue out of two nested loops
         if (!$go_for_it) {
             continue;
         }
         // Get these from the simple text files
         $charge_full = get_int_from_file($b . '/charge_full');
         $charge_now = get_int_from_file($b . '/charge_now');
         // Alleged percentage
         $percentage = $charge_now != 0 && $charge_full != 0 ? round($charge_now / $charge_full, 4) * 100 : '?';
         // Save result set
         $return[] = array('charge_full' => $charge_full, 'charge_now' => $charge_now, 'percentage' => (is_numeric($percentage) && $percentage > 100 ? 100 : $percentage) . '%', 'device' => getContents($b . '/manufacturer') . ' ' . getContents($b . '/model_name', 'Unknown'), 'state' => getContents($b . '/status', 'Unknown'));
     }
     // Give it
     return $return;
 }
示例#2
0
 /**
  * getBattery 
  * 
  * @access private
  * @return array of battery status
  */
 private function getBattery()
 {
     // Time?
     if (!empty($this->settings['timer'])) {
         $t = new LinfoTimerStart('Batteries');
     }
     // Return values
     $return = array();
     // Here they should be
     $bats = (array) @glob('/sys/class/power_supply/BAT*', GLOB_NOSORT);
     // Get vals for each battery
     foreach ($bats as $b) {
         // Get these from the simple text files
         $charge_full = get_int_from_file($b . '/charge_full');
         $charge_now = get_int_from_file($b . '/charge_now');
         // Save result set
         $return[] = array('charge_full' => $charge_full, 'charge_now' => $charge_now, 'percentage' => ($charge_now != 0 && $charge_full != 0 ? round($charge_now / $charge_full, 4) * 100 : '?') . '%', 'device' => getContents($b . '/manufacturer') . ' ' . getContents($b . '/model_name', 'Unknown'), 'state' => getContents($b . '/status', 'Unknown'));
     }
     // Give it
     return $return;
 }