summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Nagy <robert@cvs.openbsd.org>2022-02-06 09:07:43 +0000
committerRobert Nagy <robert@cvs.openbsd.org>2022-02-06 09:07:43 +0000
commitcd721369793cb6587e12b1ccb14d07dee3e9ebbe (patch)
treee1b29e8464f1f0d369e82b5ef64102b4cb0ffb44
parentfcb81b3839f2090192a7d9e99cb264f2781f92cc (diff)
now that APM_BATT_CHARGING is also set in acpi and on some m1 devices
enable support for displaying an estimate recharge time in apm(d) e.g: Battery state: charging, 95% remaining, 11 minutes recharge time estimate Battery state: charging, 97% remaining, 8 minutes recharge time estimate Battery state: charging, 98% remaining, 6 minutes recharge time estimate Battery state: charging, 99% remaining, 3 minutes recharge time estimate Battery state: charging, 99% remaining, 1 minutes recharge time estimate Battery state: charging, 99% remaining, 0 minutes recharge time estimate ok jca@
-rw-r--r--usr.sbin/apm/apm.c6
-rw-r--r--usr.sbin/apmd/apmd.c21
2 files changed, 7 insertions, 20 deletions
diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c
index 918a164944e..eb66acdc246 100644
--- a/usr.sbin/apm/apm.c
+++ b/usr.sbin/apm/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.39 2022/01/12 13:09:29 robert Exp $ */
+/* $OpenBSD: apm.c,v 1.40 2022/02/06 09:07:42 robert Exp $ */
/*
* Copyright (c) 1996 John T. Kohl
@@ -354,7 +354,6 @@ balony:
printf("\n");
if (domin && !dobstate && !dopct) {
-#ifdef __powerpc__
if (reply.batterystate.battery_state ==
APM_BATT_CHARGING)
printf("Remaining battery recharge "
@@ -365,7 +364,6 @@ balony:
printf("Battery life estimate: "
"not available\n");
else
-#endif
{
printf("Battery life estimate: ");
if (reply.batterystate.minutes_left ==
@@ -376,7 +374,6 @@ balony:
reply.batterystate.minutes_left);
}
} else if (domin) {
-#ifdef __powerpc__
if (reply.batterystate.battery_state ==
APM_BATT_CHARGING)
printf(", %d minutes recharge time estimate\n",
@@ -385,7 +382,6 @@ balony:
reply.batterystate.battery_life > 10)
printf(", unknown life estimate\n");
else
-#endif
{
if (reply.batterystate.minutes_left ==
(u_int)-1)
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c
index aaaf6b941b1..4735c6d52cb 100644
--- a/usr.sbin/apmd/apmd.c
+++ b/usr.sbin/apmd/apmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apmd.c,v 1.106 2021/07/12 15:09:20 beck Exp $ */
+/* $OpenBSD: apmd.c,v 1.107 2022/02/06 09:07:42 robert Exp $ */
/*
* Copyright (c) 1995, 1996 John T. Kohl
@@ -165,26 +165,17 @@ power_status(int fd, int force, struct apm_power_info *pinfo)
bstate.battery_state != last.battery_state ||
(bstate.minutes_left && bstate.minutes_left < 15) ||
abs(bstate.battery_life - last.battery_life) >= 10) {
-#ifdef __powerpc__
- /*
- * When the battery is charging, the estimated life
- * time is in fact the estimated remaining charge time
- * on Apple machines, so lie in the stats.
- * We still want an useful message if the battery or
- * ac status changes, however.
- */
- if (bstate.minutes_left != 0 &&
- bstate.battery_state != APM_BATT_CHARGING)
-#else
if ((int)bstate.minutes_left > 0)
-#endif
logmsg(priority, "battery status: %s. "
"external power status: %s. "
- "estimated battery life %d%% (%u minutes)",
+ "estimated battery life %d%% "
+ "(%u minutes %s time estimate)",
battstate(bstate.battery_state),
ac_state(bstate.ac_state),
bstate.battery_life,
- bstate.minutes_left);
+ bstate.minutes_left,
+ (bstate.battery_state == APM_BATT_CHARGING)
+ ? "recharge" : "life");
else
logmsg(priority, "battery status: %s. "
"external power status: %s. "