From 739ac42b5ee9204936b5e9affe30326582d120e3 Mon Sep 17 00:00:00 2001 From: chuck Date: Thu, 25 Jan 2001 00:48:59 +0000 Subject: [PATCH] be more picky about running /etc/apm/{battery,line} in response to APM_POWER_CHANGE event. some BIOS post this event periodically while the battery is charging/discharging (no change in a/c state). on these systems this prevents /etc/apm/{battery,line} from being run multiple times. --- usr.sbin/apmd/apmd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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: