Skip to content

About

A lightweight macOS menu bar temperature monitor for Apple Silicon

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

49 Commits

Folders and files

Repository files navigation

SwiftTempBar logo

SwiftTempBar

macOS 15.0+ Apple Silicon Swift 6 No dependencies

Built with Vibe Coding (DeepSeek V4.1 Flash / OpenCode).

中文文档

A lightweight macOS menu bar temperature monitor for Apple Silicon (M-series chips).

Preview

Features

  • Real-time CPU / GPU temperature display in the menu bar
  • Switchable CPU and GPU mode
  • Celsius / Fahrenheit unit switch
  • Color-coded temperature display (optional):
    • Blue: < 35°C (Low)
    • Green: 35–45°C (Normal)
    • Orange: 46–55°C (High)
    • Red: ≥ 56°C (Overheating)
  • Icon prefix mode (optional) — colored dot ● before temperature for better visibility
  • Dot-only mode (optional) — show only the colored dot ●, hiding the number
  • Trend indicator (optional) — reuse the dot: steady ●, rising ▲, falling ▼ (equal-width glyphs, no layout shift)
  • Fan speed display with RPM range (read on menu open)
  • Session peak — highest / lowest temperature since the last wake / unlock (per mode), shown at the top of the menu
  • One-click open Activity Monitor
  • One-click open GitHub repository
  • Restart or quit directly from the menu
  • Version label in menu
  • Configurable refresh interval with presets (1s / 2s / 3s / 5s / 10s / 15s / 30s / 45s / 60s) and fine-tuning (±1s)
  • Settings persistence across restarts
  • Launch at login option
  • English / Chinese menu language switch (defaults to English)
  • No Dock icon — lives entirely in the menu bar

Requirements

  • macOS 15.0 (Sequoia) or later
  • Apple Silicon Mac (M-series) only — Intel Macs are not supported

How It Works

SwiftTempBar reads hardware temperature sensors through macOS private IOKit/HID APIs, and fan speed through the Apple SMC (System Management Controller):

Temperature

  1. IOHIDEventSystemClientCreate — creates a HID system client
  2. IOHIDEventSystemClientSetMatching — filters devices by UsagePage=0xFF00, Usage=5 (temperature sensors)
  3. IOHIDEventSystemClientCopyServices — enumerates all matching sensor services
  4. IOHIDServiceClientCopyProperty — reads each sensor's name ("Product")
  5. IOHIDServiceClientCopyEvent — for sensors matching the selected mode only, retrieves a temperature event (kIOHIDEventTypeTemperature = 15)
  6. IOHIDEventGetFloatValue — extracts the temperature value

Sensors are classified by name prefix:

  • CPU: PMU tdie, PMU tdev, pACC MTR Temp, eACC MTR Temp, etc.
  • GPU: GPU MTR Temp Sensor, PMU2 tdie, PMU2 tdev, etc.

Reading the name is essentially free while copying the event is comparatively expensive, so names are matched first and only the relevant sensors are queried. The HID client is rebuilt on every read rather than cached, which keeps sensor enumeration robust at negligible cost.

The private APIs are loaded at runtime via dlopen/dlsym — no bridging headers or ObjC needed.

Fan Speed

  1. IOServiceMatching("AppleSMC") — opens a connection to the SMC service
  2. IOConnectCallStructMethod — sends SMC commands (read key info / read bytes)
  3. FNum — reads fan count (ui8 type)
  4. F%dAc / F%dMn / F%dMx — reads current / minimum / maximum RPM per fan (flt or fpe2 type)

Project Structure

Sources/
├── StatusBarController.swift   # App entry (@main), menu bar UI, settings
├── TemperatureReader.swift     # HID sensor reading (pure Swift)
├── FanReader.swift             # SMC fan speed reading (pure Swift)
├── Assets.xcassets/            # App icon
└── Info.plist

Only 3 Swift source files. No Storyboards, no ObjC, no dependencies.

Building

Requires an Xcode toolchain with Swift 6. The project targets macOS 15.0 and produces an arm64-only binary.

xcodebuild -project SwiftTempBar.xcodeproj -scheme SwiftTempBar -configuration Release build

Open SwiftTempBar.xcodeproj in Xcode to run it from the IDE.

Notes

  • SwiftTempBar uses private IOKit/HID and SMC interfaces, so it is intended for local, personal use and is not suitable for distribution on the Mac App Store.
  • Temperatures are read directly from hardware sensors and are indicative rather than calibrated.

Acknowledgements

This project was inspired by and derived from:

License

See LICENSE.

About

A lightweight macOS menu bar temperature monitor for Apple Silicon

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages