diff --git a/Sources/App/SystemTelemetryStore.swift b/Sources/App/SystemTelemetryStore.swift index 3cf2263..7deb773 100644 --- a/Sources/App/SystemTelemetryStore.swift +++ b/Sources/App/SystemTelemetryStore.swift @@ -705,7 +705,9 @@ public final class SystemTelemetryStore { : 0 ) } - context.batteryLevel = self.power.batteryLevel + context.batteryLevel = self.batteryHealth.maxCapacity > 0 + ? Double(self.batteryHealth.currentCapacity) / Double(self.batteryHealth.maxCapacity) * 100.0 + : self.power.batteryLevel context.hasBattery = self.batteryHealth.hasBattery context.onExternalPower = self.batteryHealth.externalConnected context.isCharging = self.batteryHealth.isCharging || self.power.isCharging diff --git a/Sources/Hardware/AppleSMC/MMAppleSMCClient.m b/Sources/Hardware/AppleSMC/MMAppleSMCClient.m index cd17faa..56525c8 100644 --- a/Sources/Hardware/AppleSMC/MMAppleSMCClient.m +++ b/Sources/Hardware/AppleSMC/MMAppleSMCClient.m @@ -57,13 +57,13 @@ return YES; } - CFMutableDictionaryRef matching = IOServiceMatching("AppleSMCClient"); + CFMutableDictionaryRef matching = IOServiceMatching("AppleSMC"); if (!matching) { os_unfair_lock_unlock(&_lock); if (error) { *error = [NSError errorWithDomain:@"com.i3omb.MacMonitor.SMC" code:-1 - userInfo:@{NSLocalizedDescriptionKey: @"Failed to create AppleSMCClient matching dictionary"}]; + userInfo:@{NSLocalizedDescriptionKey: @"Failed to create AppleSMC matching dictionary"}]; } return NO; } @@ -74,7 +74,7 @@ if (error) { *error = [NSError errorWithDomain:@"com.i3omb.MacMonitor.SMC" code:-2 - userInfo:@{NSLocalizedDescriptionKey: @"AppleSMCClient service not found (running on non-Mac or unsupported VM)"}]; + userInfo:@{NSLocalizedDescriptionKey: @"AppleSMC service not found (running on non-Mac or unsupported VM)"}]; } return NO; } diff --git a/Sources/Hardware/AppleSMC/MMSMCDefines.h b/Sources/Hardware/AppleSMC/MMSMCDefines.h index 39c5123..fc993be 100644 --- a/Sources/Hardware/AppleSMC/MMSMCDefines.h +++ b/Sources/Hardware/AppleSMC/MMSMCDefines.h @@ -15,8 +15,6 @@ #define kSMCGetKeyFromIndex 8 #define kSMCGetKeyInfo 9 -#pragma pack(push, 1) - typedef struct { unsigned char major; unsigned char minor; @@ -58,8 +56,6 @@ typedef struct { UInt8 bytes[32]; } SMCVal_t; -#pragma pack(pop) - static inline UInt32 MMSMCToFourCharCode(const char * _Nonnull str) { UInt32 code = 0; for (int i = 0; i < 4 && str[i] != '\0'; i++) {