Add the apm -e argument, which will toggle the "enabled" status of APM.
This commit is contained in:
parent
31faeddf80
commit
701eaeb380
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56123
@ -19,7 +19,7 @@
|
||||
.Nd control the APM BIOS and display its information
|
||||
.Sh SYNOPSIS
|
||||
.Nm apm
|
||||
.Op Fl ablstzZ
|
||||
.Op Fl abelstzZ
|
||||
.Op Fl d Ar 1|0
|
||||
.Op Fl r Ar delta
|
||||
.Pp
|
||||
@ -68,6 +68,9 @@ or
|
||||
.Ar 0
|
||||
respectively. This argument seems to not work on many different
|
||||
laptops, including the Libretto 30CT and 50CT.
|
||||
.It Fl e
|
||||
Enable APM if it is currently not enabled, or disable APM if it is currently
|
||||
enabled.
|
||||
.It Fl l
|
||||
Display the remaining battery percentage. If your laptop does not
|
||||
support this function, 255 is displayed.
|
||||
|
@ -106,6 +106,16 @@ apm_getinfo(int fd, apm_info_t aip)
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
apm_enable(int fd)
|
||||
{
|
||||
struct apm_info info;
|
||||
|
||||
apm_getinfo(fd, &info);
|
||||
if (ioctl(fd, info.ai_status ? APMIO_DISABLE : APMIO_ENABLE) == -1)
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
print_all_info(int fd, apm_info_t aip)
|
||||
{
|
||||
@ -293,7 +303,7 @@ main(int argc, char *argv[])
|
||||
int c, fd;
|
||||
int sleep = 0, all_info = 1, apm_status = 0, batt_status = 0;
|
||||
int display = 0, batt_life = 0, ac_status = 0, standby = 0;
|
||||
int batt_time = 0, delta = 0;
|
||||
int batt_time = 0, delta = 0, enable = 0;
|
||||
char *cmdname;
|
||||
size_t cmos_wall_len = sizeof(cmos_wall);
|
||||
|
||||
@ -310,7 +320,7 @@ main(int argc, char *argv[])
|
||||
all_info = 0;
|
||||
goto finish_option;
|
||||
}
|
||||
while ((c = getopt(argc, argv, "ablRr:stzd:Z")) != -1) {
|
||||
while ((c = getopt(argc, argv, "abelRr:stzd:Z")) != -1) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
ac_status = 1;
|
||||
@ -343,6 +353,9 @@ main(int argc, char *argv[])
|
||||
apm_status = 1;
|
||||
all_info = 0;
|
||||
break;
|
||||
case 'e':
|
||||
enable = 1;
|
||||
break;
|
||||
case 't':
|
||||
batt_time = 1;
|
||||
all_info = 0;
|
||||
@ -368,6 +381,8 @@ main(int argc, char *argv[])
|
||||
warn("can't open %s", APMDEV);
|
||||
return 1;
|
||||
}
|
||||
if (enable)
|
||||
apm_enable(fd);
|
||||
if (delta)
|
||||
apm_set_timer(fd, delta);
|
||||
if (sleep)
|
||||
|
Loading…
Reference in New Issue
Block a user