Lines 457-462
Link Here
|
457 |
use_acpi = 1; |
457 |
use_acpi = 1; |
458 |
fclose(acpinfo); |
458 |
fclose(acpinfo); |
459 |
} |
459 |
} |
|
|
460 |
// Do we have an pmu file? |
461 |
FILE *pmuinfo = fopen("/proc/pmu/battery_0", "r"); |
462 |
if (pmuinfo == NULL) { |
463 |
use_pmu = 0; |
464 |
} else { |
465 |
use_pmu = 1; |
466 |
fclose(pmuinfo); |
467 |
} |
460 |
|
468 |
|
461 |
probe_group = NULL; |
469 |
probe_group = NULL; |
462 |
data_group = NULL; |
470 |
data_group = NULL; |
Lines 1390-1398
Link Here
|
1390 |
// Now fetch the APM data (if so desired) |
1398 |
// Now fetch the APM data (if so desired) |
1391 |
if (monitor_bat) { |
1399 |
if (monitor_bat) { |
1392 |
#ifdef SYS_LINUX |
1400 |
#ifdef SYS_LINUX |
1393 |
char buf[128]; |
1401 |
char buf[128]; |
1394 |
|
1402 |
|
1395 |
if (use_acpi == 0) { |
1403 |
if (use_acpi == 0) { |
|
|
1404 |
if (use_pmu == 0) { |
1396 |
// Lifted from gkrellm's battery monitor, fetch the APM info |
1405 |
// Lifted from gkrellm's battery monitor, fetch the APM info |
1397 |
FILE *apm; |
1406 |
FILE *apm; |
1398 |
int ac_line_status, battery_status, flag, percentage, apm_time; |
1407 |
int ac_line_status, battery_status, flag, percentage, apm_time; |
Lines 1435-1441
Link Here
|
1435 |
|
1444 |
|
1436 |
if (!strncmp(units, "min", 32)) |
1445 |
if (!strncmp(units, "min", 32)) |
1437 |
bat_time *= 60; |
1446 |
bat_time *= 60; |
1438 |
} |
1447 |
|
|
|
1448 |
} |
1449 |
}else{ //code for pmu |
1450 |
|
1451 |
FILE *infopmu; |
1452 |
FILE *batpmu; |
1453 |
char input[BUFSIZ]; |
1454 |
int i = 0; |
1455 |
int total_remain = 0; |
1456 |
int total_cap = 0; |
1457 |
|
1458 |
|
1459 |
if ((infopmu = fopen("/proc/pmu/info", "r")) == NULL) { |
1460 |
bat_available = 0 ; |
1461 |
}else { |
1462 |
|
1463 |
bat_available = 1 ; |
1464 |
fgets( input, BUFSIZ, infopmu); |
1465 |
fgets( input, BUFSIZ, infopmu); |
1466 |
fgets( input, BUFSIZ, infopmu); |
1467 |
|
1468 |
if (input[25] == '1') |
1469 |
bat_ac = 1; |
1470 |
else |
1471 |
bat_ac = 0; |
1472 |
|
1473 |
fclose(infopmu); |
1474 |
|
1475 |
if ((batpmu = fopen("/proc/pmu/battery_0", "r")) != NULL) { |
1476 |
|
1477 |
fgets( input, BUFSIZ, batpmu); |
1478 |
fgets( input, BUFSIZ, batpmu); |
1479 |
fgets( input, BUFSIZ, batpmu); |
1480 |
i=13; |
1481 |
while (input[i] != '\0') { |
1482 |
input[i-13] = input[i]; |
1483 |
i++; |
1484 |
} |
1485 |
input[i-13] = '\0'; |
1486 |
total_remain=atoi(input); |
1487 |
|
1488 |
fgets( input, BUFSIZ, batpmu); |
1489 |
i=13; |
1490 |
while (input[i] != '\0') { |
1491 |
input[i-13] = input[i]; |
1492 |
i++; |
1493 |
} |
1494 |
total_cap=atoi(input); |
1495 |
|
1496 |
fgets( input, BUFSIZ, batpmu); |
1497 |
fgets( input, BUFSIZ, batpmu); |
1498 |
fgets( input, BUFSIZ, batpmu); |
1499 |
i=13; |
1500 |
while (input[i] != '\0') { |
1501 |
input[i-13] = input[i]; |
1502 |
i++; |
1503 |
} |
1504 |
input[i-13] = '\0'; |
1505 |
bat_time=atoi(input); |
1506 |
|
1507 |
bat_percentage = int((float(total_remain) / total_cap) * 100); |
1508 |
|
1509 |
if ((bat_ac) && (bat_time)) |
1510 |
bat_charging=1; |
1511 |
else |
1512 |
bat_charging=0; |
1513 |
|
1514 |
fclose(batpmu); |
1515 |
} |
1516 |
|
1517 |
} |
1518 |
|
1519 |
|
1520 |
|
1521 |
|
1522 |
} // end pmu code |
1523 |
|
1439 |
} else { |
1524 |
} else { |
1440 |
DIR *batteries, *ac_adapters; |
1525 |
DIR *batteries, *ac_adapters; |
1441 |
struct dirent *this_battery, *this_adapter; |
1526 |
struct dirent *this_battery, *this_adapter; |