From 561ead0c5af171ccf5fe5901e7c034a5fa6f9631 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Mon, 15 Aug 2022 00:20:27 +0200 Subject: [PATCH] Use system constant for internal battery power source name on macOS --- macOS/Power.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/macOS/Power.swift b/macOS/Power.swift index e0866469..931f168b 100644 --- a/macOS/Power.swift +++ b/macOS/Power.swift @@ -7,10 +7,10 @@ struct Power { for ps in psList { if let psDesc = IOPSGetPowerSourceDescription(psInfo, ps).takeUnretainedValue() as? [String: Any] { - if let type = psDesc[kIOPSTypeKey] as? String { - if type == "InternalBattery" { - return true - } + if let type = psDesc[kIOPSTypeKey] as? String, + type == kIOPSInternalBatteryType + { + return true } } } @@ -25,7 +25,7 @@ struct Power { for ps in psList { if let psDesc = IOPSGetPowerSourceDescription(psInfo, ps).takeUnretainedValue() as? [String: Any] { if let type = psDesc[kIOPSTypeKey] as? String, - type == "InternalBattery", + type == kIOPSInternalBatteryType, let powerSourceState = (psDesc[kIOPSPowerSourceStateKey] as? String) { return powerSourceState == kIOPSACPowerValue