diff options
author | Nikolay Sturm <sturm@cvs.openbsd.org> | 2006-01-28 17:08:15 +0000 |
---|---|---|
committer | Nikolay Sturm <sturm@cvs.openbsd.org> | 2006-01-28 17:08:15 +0000 |
commit | b161f02f354fff9d120985204f4f141d34924284 (patch) | |
tree | 7cfe0621109a89a22d22fce2114bf6a25e8f66ef | |
parent | e7d9a24d40c97438578f43fb0a478fc6da3a1b6d (diff) |
be less verbose:
- status does not provide any information, remove it
- print battery status in one line
ok beck, drahn, i386 tested by bernd
-rw-r--r-- | usr.sbin/apm/apm.8 | 6 | ||||
-rw-r--r-- | usr.sbin/apm/apm.c | 63 | ||||
-rw-r--r-- | usr.sbin/apmd/apmsubr.c | 4 |
3 files changed, 46 insertions, 27 deletions
diff --git a/usr.sbin/apm/apm.8 b/usr.sbin/apm/apm.8 index ec81a2156b6..23e3fc6ddb1 100644 --- a/usr.sbin/apm/apm.8 +++ b/usr.sbin/apm/apm.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: apm.8,v 1.26 2006/01/19 19:17:10 sturm Exp $ +.\" $OpenBSD: apm.8,v 1.27 2006/01/28 17:08:13 sturm Exp $ .\" .\" Copyright (c) 1996 John T. Kohl .\" All rights reserved. @@ -38,7 +38,7 @@ .Op Fl f Ar sockname .Br .Nm apm -.Op Fl AabCHLlmPSsvz +.Op Fl AabCHLlmPSvz .Op Fl f Ar sockname .Sh DESCRIPTION .Nm @@ -95,8 +95,6 @@ Display the performance adjustment mode. mode, 3 means automatic mode, and 4 means cool running mode. .It Fl S Put the system into stand-by (light sleep) mode. -.It Fl s -Display if power management is enabled. .It Fl v Request more verbose description of the displayed states. .It Fl z diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c index 11b1d97bacc..39fbe1319a7 100644 --- a/usr.sbin/apm/apm.c +++ b/usr.sbin/apm/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.16 2006/01/19 19:17:10 sturm Exp $ */ +/* $OpenBSD: apm.c,v 1.17 2006/01/28 17:08:13 sturm Exp $ */ /* * Copyright (c) 1996 John T. Kohl @@ -58,7 +58,7 @@ int send_command(int fd, struct apm_command *cmd, struct apm_reply *reply); void usage(void) { - fprintf(stderr,"usage: %s [-AabCHLlmPSsvz] [-f sockname]\n", + fprintf(stderr,"usage: %s [-AabCHLlmPSvz] [-f sockname]\n", __progname); exit(1); } @@ -137,7 +137,6 @@ int main(int argc, char *argv[]) { const char *sockname = _PATH_APM_SOCKET; - int dostatus = FALSE; int doac = FALSE; int dopct = FALSE; int dobstate = FALSE; @@ -149,7 +148,7 @@ main(int argc, char *argv[]) struct apm_command command; struct apm_reply reply; - while ((ch = getopt(argc, argv, "ACHLlmbvaPsSzf:")) != -1) { + while ((ch = getopt(argc, argv, "ACHLlmbvaPSzf:")) != -1) { switch (ch) { case 'v': verbose = TRUE; @@ -187,12 +186,6 @@ main(int argc, char *argv[]) usage(); action = SETPERF_LOW; break; - case 's': - if (action != NONE && action != GETSTATUS) - usage(); - dostatus = TRUE; - action = GETSTATUS; - break; case 'b': if (action != NONE && action != GETSTATUS) usage(); @@ -236,8 +229,7 @@ main(int argc, char *argv[]) switch (action) { case NONE: action = GETSTATUS; - verbose = doac = dopct = dobstate = dostatus = domin = TRUE; - doperf = TRUE; + verbose = doac = dopct = dobstate = domin = doperf = TRUE; /* FALLTHROUGH */ case GETSTATUS: if (fd == -1) { @@ -284,19 +276,28 @@ main(int argc, char *argv[]) if (doac) printf("%d\n", reply.batterystate.ac_state); - if (dostatus) - printf("1\n"); if (doperf) printf("%d\n", reply.perfstate); break; } - if (dobstate) - printf("Battery state: %s\n", + + if (dobstate) { + printf("Battery state: %s", battstate(reply.batterystate.battery_state)); - if (dopct) - printf("Battery remaining: %d percent\n", + if (!dopct && !domin) + printf("\n"); + } + + if (dopct && !dobstate) + printf("Battery remaining: %d percent", reply.batterystate.battery_life); - if (domin) { + else if (dopct) + printf(", %d %% remaining", + reply.batterystate.battery_life); + if (dopct && !domin) + printf("\n"); + + if (domin && !dobstate && !dopct) { #ifdef __powerpc__ if (reply.batterystate.battery_state == APM_BATT_CHARGING) @@ -318,15 +319,35 @@ main(int argc, char *argv[]) printf("%d minutes\n", reply.batterystate.minutes_left); } + } else if (domin) { +#ifdef __powerpc__ + if (reply.batterystate.battery_state == + APM_BATT_CHARGING) + printf(", %d minutes recharge time estimate\n", + reply.batterystate.minutes_left); + else if (reply.batterystate.minutes_left == 0 && + reply.batterystate.battery_life > 10) + printf(", unknown life estimate\n"); + else +#endif + { + if (reply.batterystate.minutes_left == + (u_int)-1) + printf(", unknown"); + else + printf(", %d minutes", + reply.batterystate.minutes_left); + printf(" life estimate\n"); + } } + if (doac) printf("A/C adapter state: %s\n", ac_state(reply.batterystate.ac_state)); + if (doperf) printf("Performance state: %s (%d MHz)\n", perf_state(reply.perfstate), reply.cpuspeed); - if (dostatus) - printf("Power management enabled\n"); break; default: break; diff --git a/usr.sbin/apmd/apmsubr.c b/usr.sbin/apmd/apmsubr.c index 836a333bf11..fc0d3eb557f 100644 --- a/usr.sbin/apmd/apmsubr.c +++ b/usr.sbin/apmd/apmsubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmsubr.c,v 1.6 2006/01/19 19:17:10 sturm Exp $ */ +/* $OpenBSD: apmsubr.c,v 1.7 2006/01/28 17:08:14 sturm Exp $ */ /* * Copyright (c) 1995,1996 John T. Kohl @@ -48,7 +48,7 @@ battstate(int state) case APM_BATTERY_ABSENT: return "absent"; case APM_BATT_UNKNOWN: - return "unknown (absent?)"; + return "unknown"; default: return "invalid battery state"; } |