Tidy up battery status information. Remove a trailing white space.

PR:		193671
This commit is contained in:
jkim 2015-04-06 21:51:55 +00:00
parent 7dd288fb20
commit 9435c121fa

View File

@ -136,16 +136,30 @@ acpi_battinfo(int num)
if (ioctl(acpifd, ACPIIO_BATT_GET_BATTINFO, &battio) == -1)
err(EX_IOERR, "get battery user info (%d) failed", num);
if (battio.battinfo.state != ACPI_BATT_STAT_NOT_PRESENT) {
printf("State:\t\t\t");
if (battio.battinfo.state == 0)
printf("high ");
if (battio.battinfo.state & ACPI_BATT_STAT_CRITICAL)
printf("critical ");
if (battio.battinfo.state & ACPI_BATT_STAT_DISCHARG)
printf("discharging ");
if (battio.battinfo.state & ACPI_BATT_STAT_CHARGING)
printf("charging ");
printf("\n");
const char *state;
switch (battio.battinfo.state & ACPI_BATT_STAT_BST_MASK) {
case 0:
state = "high";
break;
case ACPI_BATT_STAT_DISCHARG:
state = "discharging";
break;
case ACPI_BATT_STAT_CHARGING:
state = "charging";
break;
case ACPI_BATT_STAT_CRITICAL:
state = "critical";
break;
case ACPI_BATT_STAT_DISCHARG | ACPI_BATT_STAT_CRITICAL:
state = "critical discharging";
break;
case ACPI_BATT_STAT_CHARGING | ACPI_BATT_STAT_CRITICAL:
state = "critical charging";
break;
default:
state = "invalid";
}
printf("State:\t\t\t%s\n", state);
if (battio.battinfo.cap == -1)
printf("Remaining capacity:\tunknown\n");
else