From 90068ab474f5abbb2b5155655cdf54f201f83811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 8 Jan 2025 13:46:08 +0800 Subject: [PATCH] Battery (NetBSD): fix battery percentage detection --- src/detection/battery/battery_nbsd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/detection/battery/battery_nbsd.c b/src/detection/battery/battery_nbsd.c index 682bfbfd2..093853336 100644 --- a/src/detection/battery/battery_nbsd.c +++ b/src/detection/battery/battery_nbsd.c @@ -46,7 +46,7 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r { if (prop_object_type(dict) != PROP_TYPE_DICTIONARY) continue; - + const char* desc = NULL; if (!prop_dictionary_get_string(dict, "description", &desc)) continue; @@ -88,7 +88,7 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r ffStrbufInit(&battery->manufactureDate); battery->timeRemaining = -1; - battery->capacity = (double) curr / max; + battery->capacity = (double) curr / (double) max * 100.; if (charging) ffStrbufAppendS(&battery->status, "Charging, "); else if (dischargeRate) @@ -102,6 +102,6 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r } } prop_object_iterator_release(itKey); - + return NULL; }