- Notifications
You must be signed in to change notification settings - Fork57
beltex/SMCKit
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An Apple System Management Controller (SMC) library & command line tool in Swiftfor Intel based Macs. The library works by talking to the AppleSMC.kext (kernelextension), the private driver for the SMC. Read temperature sensors, get andset fan speed (RPM), and more.
- For an example usage of this library, seedshb, a macOS system monitor in Swift
- For other system related statistics in Swift for macOS, seeSystemKit
"The System Management Controller (SMC) is an internal subsystem introduced byApple Inc. with the introduction of their new Intel processor based machinesin 2006. It takes over the functions of the SMU. The SMC manages thermal andpower conditions to optimize the power and airflow while keeping audible noiseto a minimum. Power consumption and temperature are monitored by the operatingsystem, which communicates the necessary adjustments back to the SMC. The SMCmakes the changes, slowing down or speeding up fans as necessary."-via Wikipedia
For more see:
- Xcode 9.0 (Swift 4.0)
- macOS 10.12 Sierra and abovefor development (due to Xcode)
- OS X 10.9 Mavericks and abovefor use (due to Swift)
Make sure to use the recursive option on clone to initialize all submodules.
git clone --recursive https://github.com/beltex/SMCKit
Incase you have already cloned the repository, run the following inside theproject directory.
git submodule update --init
A macOS command line tool for interfacing with the SMC using SMCKit. TheCommandLine library is used forthe CLI andronn for generating themanual page.
This will build SMCKitTool (smckit(1)
) from source and place the binary andmanual page in your path.
make install
$ smckit-- Temperature --AMBIENT_AIR_0 34.0°CCPU_0_DIE 48.0°CCPU_0_PROXIMITY 39.0°CENCLOSURE_BASE_0 29.0°CENCLOSURE_BASE_1 29.0°CENCLOSURE_BASE_2 28.0°CHEATSINK_1 34.0°CMEM_SLOTS_PROXIMITY 36.0°CPALM_REST 27.0°C-- Fan --[id 0] Right Side Min: 1299 RPM Max: 6199 RPM Current: 1292 RPM-- Power --AC Present:trueBattery Powered:falseCharging:falseBattery Ok:trueBattery Count: 1-- Misc --Discin ODD:false
- The use of this library will almost certainly not be allowed in theMac App Store as it is essentially using a private API
- If you are creating a macOS command line tool, you cannot use SMCKit as alibrary as Swift does not currently support static libraries. In such acase, the
SMC.swift
file must simply be included in your project as anothersource file. SeeSwiftInFlux/Runtime Dynamic Librariesfor more information and both SMCKitTool &dshb as examples of such a case.
There are many projects that interface with the SMC for one purpose or another.Credit is most certainly due to them for the reference. Such projects as:
Handy I/O Kit references:
This project is under theMIT License.
While the SMC driver is closed source, the call strucutre and definition ofcertain structs needed to interact with it (seeSMCParamStruct
) happened toappear in the open source ApplePowerManagement project at around version211, and soon after disappeared. They can be seen in thePrivateLib.cfile underpmconfigd
. In the very same source file, the following snippet can befound:
// And simply AppleSMC with kCFBooleanTrue to let them know time is changed.// We don't pass any information down.IORegistryEntrySetCFProperty(_smc,CFSTR("TheTimesAreAChangin"),kCFBooleanTrue);
Almost certainly a reference to Bob Dylan'sThe Times They Are a-Changin' :)