summaryrefslogtreecommitdiffstats
path: root/usr.sbin/apmd
diff options
context:
space:
mode:
authorjca <jca@openbsd.org>2020-02-12 11:29:41 +0000
committerjca <jca@openbsd.org>2020-02-12 11:29:41 +0000
commitadd3467c0082d817a7cf1b0a5acc450f082b2979 (patch)
treec6e112bd4a2e9aa3ede6918d17be89f7a2f71ae5 /usr.sbin/apmd
parentZap apmtimeout, the way it's used isn't meaningful any more (diff)
downloadwireguard-openbsd-add3467c0082d817a7cf1b0a5acc450f082b2979.tar.xz
wireguard-openbsd-add3467c0082d817a7cf1b0a5acc450f082b2979.zip
On APM_POWER_CHANGE events check battery life against autoaction level
Makes -z/-Z just work for me using acpibat(4). Other battery drivers that provide APM_POWER_CHANGE events: acpisbs(4), apm(4), ykbec(4/loongson) and stsec(4/loongson). ok tedu@
Diffstat (limited to 'usr.sbin/apmd')
-rw-r--r--usr.sbin/apmd/apmd.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c
index 4f820b4805e..264e339ee83 100644
--- a/usr.sbin/apmd/apmd.c
+++ b/usr.sbin/apmd/apmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apmd.c,v 1.92 2020/02/12 11:23:11 jca Exp $ */
+/* $OpenBSD: apmd.c,v 1.93 2020/02/12 11:29:41 jca Exp $ */
/*
* Copyright (c) 1995, 1996 John T. Kohl
@@ -515,8 +515,8 @@ main(int argc, char *argv[])
if (!powerstatus && autoaction &&
autolimit > (int)pinfo.battery_life) {
logmsg(LOG_NOTICE,
- "estimated battery life %d%%, "
- "autoaction limit set to %d%% .",
+ "estimated battery life %d%%"
+ " below configured limit %d%%",
pinfo.battery_life,
autolimit
);
@@ -570,6 +570,19 @@ main(int argc, char *argv[])
powerstatus = powerbak;
powerchange = 1;
}
+
+ if (!powerstatus && autoaction &&
+ autolimit > (int)pinfo.battery_life) {
+ logmsg(LOG_NOTICE,
+ "estimated battery life %d%%"
+ " below configured limit %d%%",
+ pinfo.battery_life, autolimit);
+
+ if (autoaction == AUTO_SUSPEND)
+ suspends++;
+ else
+ hibernates++;
+ }
break;
default:
;