summaryrefslogtreecommitdiffstats
path: root/usr.sbin/apm
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2000-01-16 20:25:57 +0000
committergreen <green@FreeBSD.org>2000-01-16 20:25:57 +0000
commitdb0585c614f2e1f50612a76cc34482f1712f1214 (patch)
tree8efe3c805e6968c3aa50eb2f29fcaa35fa38b6a1 /usr.sbin/apm
parenta9af0234736b120aa8dcc3f1c0c53bd2ea78fb4c (diff)
downloadFreeBSD-src-db0585c614f2e1f50612a76cc34482f1712f1214.zip
FreeBSD-src-db0585c614f2e1f50612a76cc34482f1712f1214.tar.gz
Add the apm -e argument, which will toggle the "enabled" status of APM.
Diffstat (limited to 'usr.sbin/apm')
-rw-r--r--usr.sbin/apm/apm.85
-rw-r--r--usr.sbin/apm/apm.c19
2 files changed, 21 insertions, 3 deletions
diff --git a/usr.sbin/apm/apm.8 b/usr.sbin/apm/apm.8
index f076bd6..1e3331c 100644
--- a/usr.sbin/apm/apm.8
+++ b/usr.sbin/apm/apm.8
@@ -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.
diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c
index aa63ae2b..ec66323 100644
--- a/usr.sbin/apm/apm.c
+++ b/usr.sbin/apm/apm.c
@@ -107,6 +107,16 @@ apm_getinfo(int fd, apm_info_t aip)
}
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)
{
struct apm_bios_arg args;
@@ -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 @@ finish_option:
warn("can't open %s", APMDEV);
return 1;
}
+ if (enable)
+ apm_enable(fd);
if (delta)
apm_set_timer(fd, delta);
if (sleep)
OpenPOWER on IntegriCloud