From 6f76e63887db5a19b9f3d3e2f4e212bfa0a4ee84 Mon Sep 17 00:00:00 2001 From: drkhsh Date: Thu, 27 Oct 2022 23:47:01 +0200 Subject: battery: Refactor remaining on OpenBSD Fixes up overly complicated line, by splitting up logic --- components/battery.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/battery.c b/components/battery.c index 959e2e2..3746095 100644 --- a/components/battery.c +++ b/components/battery.c @@ -182,12 +182,13 @@ battery_remaining(const char *unused) { struct apm_power_info apm_info; + unsigned int h, m; if (load_apm_power_info(&apm_info)) { if (apm_info.ac_state != APM_AC_ON) { - return bprintf("%uh %02um", - apm_info.minutes_left / 60, - apm_info.minutes_left % 60); + h = apm_info.minutes_left / 60; + m = apm_info.minutes_left % 60; + return bprintf("%uh %02um", h, m); } else { return ""; } -- cgit v1.2.3