Created
August 24, 2025 04:33
-
-
Save Kyome22/e212428af0273a072df35a1cbd64ce07 to your computer and use it in GitHub Desktop.
Battery Health
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import IOKit.ps | |
| @main | |
| struct TestCode { | |
| static func main() async throws { | |
| let psInfo = IOPSCopyPowerSourcesInfo().takeRetainedValue() | |
| let psList = IOPSCopyPowerSourcesList(psInfo).takeRetainedValue() as? [CFDictionary] | |
| guard let psList else { | |
| return | |
| } | |
| let powerSource = psList[0] as NSDictionary | |
| print(powerSource) | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Intel Mac
Power: Battery Information: Model Information: Serial Number: D869395H0VVHDTDAG Manufacturer: SMP Device Name: bq20z451 Pack Lot Code: 0 PCB Lot Code: 0 Firmware Version: 901 Hardware Revision: 1 Cell Revision: 3922 Charge Information: The battery’s charge is below the warning level: No Fully Charged: No Charging: Yes Full Charge Capacity (mAh): 3814 State of Charge (%): 16 Health Information: Cycle Count: 70 Condition: Normal System Power Settings: AC Power: System Sleep Timer (Minutes): 60 Disk Sleep Timer (Minutes): 10 Display Sleep Timer (Minutes): 60 Wake on AC Change: No Wake on Clamshell Open: Yes Wake on LAN: Yes AutoPowerOff Delay: 259200 AutoPowerOff Enabled: 1 Current Power Source: Yes Display Sleep Uses Dim: Yes Hibernate Mode: 3 LowPowerMode: 0 PrioritizeNetworkReachabilityOverSleep: 0 Battery Power: System Sleep Timer (Minutes): 4 Disk Sleep Timer (Minutes): 10 Display Sleep Timer (Minutes): 4 Wake on AC Change: No Wake on Clamshell Open: Yes Wake on LAN: No AutoPowerOff Delay: 259200 AutoPowerOff Enabled: 1 Display Sleep Uses Dim: Yes Hibernate Mode: 3 LowPowerMode: 0 PrioritizeNetworkReachabilityOverSleep: 0 Reduce Brightness: Yes Hardware Configuration: UPS Installed: No AC Charger Information: Connected: Yes Wattage (W): 60 Charging: Yes Power Events: Next Scheduled Events: appPID: 381 Type: Wake Scheduled By: com.apple.alarm.user-visible-com.apple.CalendarNotification.EKTravelEngine.periodicRefreshTimer Time: 2025/08/24 22:23 UserVisible: 0