Documentation
¶
Overview ¶
Package smc reads sensor values (temperatures, fan speeds) from the macOS AppleSMC kernel extension. It works on both Intel and Apple Silicon Macs; the difference is the set of keys and their data type:
- Intel: temperatures live under TC0P / TC0E / TC0F (sp78), fans under F0Ac…F17Ac (fpe2).
- Apple Silicon: temperatures live under Tp01…Tp16 (flt — IEEE 754 single precision), fans under F0Ac…F17Ac (also flt).
AppleSMC fan keys do not exist at all on fanless Macs (e.g. M1/M2 MacBook Air); ReadFanSpeeds returns an empty slice on those.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenSMC ¶
func OpenSMC()
OpenSMC keeps the SMC connection open for the lifetime of the process. Otherwise each Read* call opens and closes it.
func ReadFanSpeeds ¶
func ReadFanSpeeds() []int
ReadFanSpeeds returns the current speed of each active fan in RPM, in fan-index order. Returns an empty slice on fanless Macs (M1/M2 MacBook Air, etc.) where the SMC has no F*Ac keys.
Reads keys F0Ac through F17Ac and stops at the first one that does not respond. AppleSMC reports these as sp78/fpe2 on Intel and as IEEE-754 float on Apple Silicon; both formats are handled.
func ReadTemperature ¶
func ReadTemperature() float64
ReadTemperature returns a representative CPU temperature in degrees Celsius, or 0.0 if no temperature sensor could be read.
- On Intel, this is the TC0P (CPU proximity) sensor.
- On Apple Silicon, this is the maximum across all populated per-cluster CPU sensors (Tp01…Tp16) — i.e. the hottest core cluster, which is generally the most useful single value for thermal monitoring.
func ReadTemperatures ¶
ReadTemperatures returns every CPU-cluster temperature sensor the kernel acknowledges, keyed by SMC key (e.g. "Tp01"). On Intel this will typically be a single entry under "TC0P"; on Apple Silicon it will be several Tp* entries. Empty if no sensors respond.
Types ¶
This section is empty.