PR/6606: Johnny C. Lam: Add -l flag to apmd so that it suspends automagically
when the is a battery low event.
This commit is contained in:
parent
dafe2a2b81
commit
ac20cbee1c
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: apmd.8,v 1.8 1998/11/19 19:39:14 kenh Exp $
|
||||
.\" $NetBSD: apmd.8,v 1.9 1998/12/19 15:27:58 christos Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
|
@ -45,6 +45,7 @@
|
|||
.Op Fl d
|
||||
.Op Fl s
|
||||
.Op Fl a
|
||||
.Op Fl l
|
||||
.Op Fl q
|
||||
.Op Fl t Ar seconds
|
||||
.Op Fl S Ar sockname
|
||||
|
@ -102,6 +103,11 @@ ignored if the system is connected to line current and not running from
|
|||
batteries (user requests are still honored).
|
||||
.Pp
|
||||
If the
|
||||
.Fl l
|
||||
flag is specified, then a low-battery event causes a suspend request
|
||||
to occur.
|
||||
.Pp
|
||||
If the
|
||||
.Fl d
|
||||
flag is specified,
|
||||
.Nm
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: apmd.c,v 1.9 1998/11/19 19:39:14 kenh Exp $ */
|
||||
/* $NetBSD: apmd.c,v 1.10 1998/12/19 15:27:58 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
|
@ -90,7 +90,7 @@ sigexit(int signo)
|
|||
void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,"usage: %s [-d] [-t timo] [-s] [-a] [-f devfile] [-S sockfile]\n\t[-m sockmode] [-o sockowner]\n", __progname);
|
||||
fprintf(stderr,"usage: %s [-d] [-s] [-a] [-l] [-q] [-t seconds] [-S sockname]\n\t[-m sockmode] [-o sockowner:sockgroup] [-f devname]\n", __progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -303,6 +303,7 @@ main(int argc, char *argv[])
|
|||
struct apm_event_info apmevent;
|
||||
int suspends, standbys, resumes;
|
||||
int noacsleep = 0;
|
||||
int lowbattsleep = 0;
|
||||
mode_t mode = 0660;
|
||||
struct timeval tv = {TIMO, 0}, stv;
|
||||
const char *sockname = sockfile;
|
||||
|
@ -321,6 +322,9 @@ main(int argc, char *argv[])
|
|||
case 'a':
|
||||
noacsleep = 1;
|
||||
break;
|
||||
case 'l':
|
||||
lowbattsleep = 1;
|
||||
break;
|
||||
case 'd':
|
||||
debug = 1;
|
||||
break;
|
||||
|
@ -429,9 +433,12 @@ main(int argc, char *argv[])
|
|||
case APM_SUSPEND_REQ:
|
||||
case APM_USER_SUSPEND_REQ:
|
||||
case APM_CRIT_SUSPEND_REQ:
|
||||
case APM_BATTERY_LOW:
|
||||
suspends++;
|
||||
break;
|
||||
case APM_BATTERY_LOW:
|
||||
if (lowbattsleep)
|
||||
suspends++;
|
||||
break;
|
||||
case APM_USER_STANDBY_REQ:
|
||||
case APM_STANDBY_REQ:
|
||||
standbys++;
|
||||
|
@ -531,7 +538,8 @@ do_etc_file(const char *file)
|
|||
}
|
||||
}
|
||||
|
||||
void do_ac_state(int state)
|
||||
void
|
||||
do_ac_state(int state)
|
||||
{
|
||||
switch (state) {
|
||||
case APM_AC_OFF:
|
||||
|
|
Loading…
Reference in New Issue