@@ -43,11 +43,6 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
4343 ffCfDictGetString (properties , CFSTR (kIOPMDeviceNameKey ), & battery -> modelName );
4444 ffCfDictGetString (properties , CFSTR (kIOPMPSSerialKey ), & battery -> serial );
4545 ffCfDictGetString (properties , CFSTR (kIOPMPSManufacturerKey ), & battery -> manufacturer );
46- ffCfDictGetInt (properties , CFSTR (kIOPMPSTimeRemainingKey ), & battery -> timeRemaining ); // in minutes
47- if (battery -> timeRemaining == 0xFFFF )
48- battery -> timeRemaining = -1 ;
49- else
50- battery -> timeRemaining *= 60 ;
5146
5247 if (!ffCfDictGetBool (properties , CFSTR ("built-in" ), & boolValue ) && boolValue )
5348 {
@@ -65,7 +60,14 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
6560 if (!ffCfDictGetBool (properties , CFSTR (kIOPMPSExternalConnectedKey ), & boolValue ) && boolValue )
6661 ffStrbufAppendS (& battery -> status , "AC connected, " );
6762 else
63+ {
6864 ffStrbufAppendS (& battery -> status , "Discharging, " );
65+ ffCfDictGetInt (properties , CFSTR (kIOPMPSTimeRemainingKey ), & battery -> timeRemaining ); // in minutes
66+ if (battery -> timeRemaining == 0xFFFF )
67+ battery -> timeRemaining = -1 ;
68+ else
69+ battery -> timeRemaining *= 60 ;
70+ }
6971 if (!ffCfDictGetBool (properties , CFSTR (kIOPMPSIsChargingKey ), & boolValue ) && boolValue )
7072 ffStrbufAppendS (& battery -> status , "Charging, " );
7173 if (!ffCfDictGetBool (properties , CFSTR (kIOPMPSAtCriticalLevelKey ), & boolValue ) && boolValue )
0 commit comments