summaryrefslogtreecommitdiffstats
path: root/usr.sbin/apm
diff options
context:
space:
mode:
authornate <nate@FreeBSD.org>1996-03-13 00:48:06 +0000
committernate <nate@FreeBSD.org>1996-03-13 00:48:06 +0000
commit2be838b1dc40d342a95339a2a106ba2ed313a47d (patch)
tree91ab559ff37679a835e923d1292a59da73ad2e85 /usr.sbin/apm
parent986c9f5c3a8f21824489bd78d88facebe50e9b3c (diff)
downloadFreeBSD-src-2be838b1dc40d342a95339a2a106ba2ed313a47d.zip
FreeBSD-src-2be838b1dc40d342a95339a2a106ba2ed313a47d.tar.gz
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.
Diffstat (limited to 'usr.sbin/apm')
-rw-r--r--usr.sbin/apm/apm.811
-rw-r--r--usr.sbin/apm/apm.c12
2 files changed, 19 insertions, 4 deletions
diff --git a/usr.sbin/apm/apm.8 b/usr.sbin/apm/apm.8
index 6e975ac..0cde379 100644
--- a/usr.sbin/apm/apm.8
+++ b/usr.sbin/apm/apm.8
@@ -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.
diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c
index 2781a61..b0ae12b 100644
--- a/usr.sbin/apm/apm.c
+++ b/usr.sbin/apm/apm.c
@@ -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 @@ finish_option:
}
if (sleep) {
apm_suspend(fd);
- }
- else {
+ } else {
struct apm_info info;
apm_getinfo(fd, &info);
@@ -155,6 +158,9 @@ finish_option:
if (ac_status) {
printf("%d\n", info.ai_acline);
}
+ if (apm_status) {
+ printf("%d\n", info.ai_status);
+ }
}
close(fd);
return 0;
OpenPOWER on IntegriCloud