diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2020-02-12 11:29:42 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2020-02-12 11:29:42 +0000 |
commit | bc74102e1b76be174519379f25695b944aa12c7b (patch) | |
tree | f9f4a1d87d8d1feb46d026812b02db1439044cc5 /usr.sbin/apmd/apmd.c | |
parent | d92a73641ae7f072ad6151102f8d7a983a7c7028 (diff) |
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/apmd.c')
-rw-r--r-- | usr.sbin/apmd/apmd.c | 19 |
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: ; |