Add the '-s' flag to apm which returns the status of the APM support
(enable/disabled) now that the APM_GETINFO ioctl returns the necessary information. Also, print out the status along with the other information as the default behavior.
This commit is contained in:
parent
886c4a60dd
commit
16f7ca5510
@ -20,6 +20,7 @@
|
||||
.Op Fl b
|
||||
.Op Fl a
|
||||
.Op Fl l
|
||||
.Op Fl s
|
||||
.Pp
|
||||
.Nm zzz
|
||||
.Sh DESCRIPTION
|
||||
@ -58,13 +59,21 @@ status respectively.
|
||||
Display the current AC-line status as an integer value. The values
|
||||
0 and 1 correspond to the
|
||||
.Dq off-line
|
||||
state and
|
||||
state or
|
||||
.Dq on-line
|
||||
state, respectively.
|
||||
.Pp
|
||||
.It Fl l
|
||||
Display the remaining battery percentage. If your laptop does not
|
||||
support this function, 255 is displayed.
|
||||
.Pp
|
||||
.It Fl s
|
||||
Display the status of the APM support as an integer value. The values
|
||||
0 and 1 correspond to the
|
||||
.Dq enabled
|
||||
state or
|
||||
.Dq disabled
|
||||
state respecitively
|
||||
.Sh BUGS
|
||||
Some APM implementations do not support parameters needed by
|
||||
.Nm apm.
|
||||
|
@ -43,6 +43,7 @@ void apm_getinfo(int fd, apm_info_t aip)
|
||||
void print_all_info(apm_info_t aip)
|
||||
{
|
||||
printf("APM version: %d.%d\n", aip->ai_major, aip->ai_minor);
|
||||
printf("APM Managment: %s\n", (aip->ai_status ? "Enabled": "Disabled"));
|
||||
printf("AC Line status: ");
|
||||
if (aip->ai_acline == 255) {
|
||||
printf("unknown");
|
||||
@ -83,7 +84,7 @@ void print_all_info(apm_info_t aip)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i, j, fd;
|
||||
int sleep = 0, all_info = 1, batt_status = 0, batt_life = 0, ac_status = 0;
|
||||
int sleep = 0, all_info = 1, apm_status = 0, batt_status = 0, batt_life = 0, ac_status = 0;
|
||||
char *cmdname;
|
||||
|
||||
main_argc = argc;
|
||||
@ -123,6 +124,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
batt_life = 1;
|
||||
all_info = 0;
|
||||
case 's':
|
||||
apm_status = 1;
|
||||
all_info = 0;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s Unknown option '%s'.\n", argv[0], argv[i]);
|
||||
@ -138,8 +142,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (sleep) {
|
||||
apm_suspend(fd);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
struct apm_info info;
|
||||
|
||||
apm_getinfo(fd, &info);
|
||||
@ -155,6 +158,9 @@ int main(int argc, char *argv[])
|
||||
if (ac_status) {
|
||||
printf("%d\n", info.ai_acline);
|
||||
}
|
||||
if (apm_status) {
|
||||
printf("%d\n", info.ai_status);
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user