diff options
author | jdp <jdp@FreeBSD.org> | 1997-11-12 04:16:23 +0000 |
---|---|---|
committer | jdp <jdp@FreeBSD.org> | 1997-11-12 04:16:23 +0000 |
commit | dd8043bfaa6a9f3f0d452c2675ef66eb632ab69d (patch) | |
tree | f6470bb46a2e9b4d3420bfb1a972bbd1b404d79b /usr.sbin/apm | |
parent | 53247589eb018f3b6e61ad83192fe9f7bbf23ab8 (diff) | |
download | FreeBSD-src-dd8043bfaa6a9f3f0d452c2675ef66eb632ab69d.zip FreeBSD-src-dd8043bfaa6a9f3f0d452c2675ef66eb632ab69d.tar.gz |
Output the estimated battery lifetime as "hh:mm:ss" along with
everything else. Add a "-t" option for outputting it in raw form.
Define and document the order in which raw values are printed when
more than one is requested on the command line.
Diffstat (limited to 'usr.sbin/apm')
-rw-r--r-- | usr.sbin/apm/apm.8 | 7 | ||||
-rw-r--r-- | usr.sbin/apm/apm.c | 32 |
2 files changed, 33 insertions, 6 deletions
diff --git a/usr.sbin/apm/apm.8 b/usr.sbin/apm/apm.8 index 9652a18..4b299ff 100644 --- a/usr.sbin/apm/apm.8 +++ b/usr.sbin/apm/apm.8 @@ -16,7 +16,7 @@ .Nd control the APM BIOS and display its information .Sh SYNOPSIS .Nm apm -.Op Fl ablsz +.Op Fl ablstz .Op Fl d Ar 1|0 .Pp .Nm zzz @@ -35,6 +35,8 @@ The following options are available for If no options are specified, .Nm apm displays information and current status of APM in verbose mode. +If multiple display options are given, the values are displayed one +per line in the order given here. .Bl -tag -width indent .It Fl a Display the current AC-line status as an integer value. The values @@ -71,6 +73,9 @@ Display the status of the APM support as an integer value. The values state or .Dq enabled state respectively. +.It Fl t +Display the estimated remaining battery lifetime in seconds. If +it is unknown, -1 is displayed. .It Fl z Suspend the system. It is equivalent to .Nm zzz. diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c index 98e9852..b764b2a 100644 --- a/usr.sbin/apm/apm.c +++ b/usr.sbin/apm/apm.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] = - "$Id: apm.c,v 1.10 1997/09/02 06:36:39 charnier Exp $"; + "$Id: apm.c,v 1.11 1997/11/06 23:55:38 imp Exp $"; #endif /* not lint */ #include <err.h> @@ -33,7 +33,7 @@ void usage() { fprintf(stderr, "%s\n%s\n", - "usage: apm [-ablsz] [-d 1|0]", + "usage: apm [-ablstz] [-d 1|0]", " zzz"); exit(1); } @@ -85,6 +85,21 @@ print_all_info(apm_info_t aip) else printf("invalid value (0x%x)", aip->ai_batt_life); printf("\n"); + printf("Remaining battery time: "); + if (aip->ai_batt_time == -1) + printf("unknown"); + else { + int t, h, m, s; + + t = aip->ai_batt_time; + s = t % 60; + t /= 60; + m = t % 60; + t /= 60; + h = t; + printf("%2d:%02d:%02d", h, m, s); + } + printf("\n"); } @@ -106,6 +121,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; + int batt_time = 0; char *cmdname; @@ -119,7 +135,7 @@ main(int argc, char *argv[]) all_info = 0; goto finish_option; } - while ((c = getopt(argc, argv, "ablszd:")) != -1) { + while ((c = getopt(argc, argv, "ablstzd:")) != -1) { switch (c) { case 'a': ac_status = 1; @@ -146,6 +162,10 @@ main(int argc, char *argv[]) apm_status = 1; all_info = 0; break; + case 't': + batt_time = 1; + all_info = 0; + break; case 'z': sleep = 1; all_info = 0; @@ -171,14 +191,16 @@ finish_option: apm_getinfo(fd, &info); if (all_info) print_all_info(&info); + if (ac_status) + printf("%d\n", info.ai_acline); if (batt_status) printf("%d\n", info.ai_batt_stat); if (batt_life) printf("%d\n", info.ai_batt_life); - if (ac_status) - printf("%d\n", info.ai_acline); if (apm_status) printf("%d\n", info.ai_status); + if (batt_time) + printf("%d\n", info.ai_batt_time); if (display) apm_display(fd, display - 1); } |