diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c index ec49056382f0..5fee47dc4bd5 100644 --- a/usr.sbin/apmd/apmd.c +++ b/usr.sbin/apmd/apmd.c @@ -1,4 +1,4 @@ -/* $NetBSD: apmd.c,v 1.16 2001/01/11 01:35:53 lukem Exp $ */ +/* $NetBSD: apmd.c,v 1.17 2001/01/25 00:48:59 chuck Exp $ */ /*- * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc. @@ -314,6 +314,7 @@ main(int argc, char *argv[]) fd_set selcopy; struct apm_event_info apmevent; int suspends, standbys, resumes; + int ac_is_off; int noacsleep = 0; int lowbattsleep = 0; mode_t mode = 0660; @@ -414,6 +415,7 @@ main(int argc, char *argv[]) struct apm_power_info pinfo; power_status(ctl_fd, 1, &pinfo); do_ac_state(pinfo.ac_state); + ac_is_off = (pinfo.ac_state == APM_AC_OFF); } (void) signal(SIGTERM, sigexit); @@ -484,7 +486,11 @@ main(int argc, char *argv[]) { struct apm_power_info pinfo; power_status(ctl_fd, 0, &pinfo); - do_ac_state(pinfo.ac_state); + /* power status can change without ac status changing */ + if (ac_is_off != (pinfo.ac_state == APM_AC_OFF)) { + do_ac_state(pinfo.ac_state); + ac_is_off = (pinfo.ac_state == APM_AC_OFF); + } break; } default: