apple-silicon-accelerometer

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2026 License: MIT

README

apple-silicon-accelerometer

Go port of olvvier/apple-silicon-accelerometer — read accelerometer, gyroscope, ambient light sensor, and lid angle from Apple Silicon MacBooks via IOKit HID.

What it does

Reads the Bosch BMI286 IMU and other sensors exposed through Apple's AppleSPUHIDDevice IOKit interface on Apple Silicon MacBooks. Two binaries:

  • sensord — Daemon that reads raw sensor data via IOKit HID callbacks and writes to POSIX shared memory ring buffers. Requires sudo.
  • sensordash — Terminal dashboard that reads from shared memory and displays live vibration detection, orientation (Mahony AHRS), heartbeat estimation (BCG), lid angle, and ambient light.

Requirements

  • macOS on Apple Silicon (tested on M-series MacBooks)
  • Go 1.26+
  • Root privileges for sensord (IOKit HID access)

Install

go install github.com/taigrr/apple-silicon-accelerometer/cmd/sensord@latest
go install github.com/taigrr/apple-silicon-accelerometer/cmd/sensordash@latest

Usage

# Terminal 1: Start the sensor daemon (requires sudo)
sudo sensord

# Terminal 2: Launch the dashboard
sensordash

Architecture

cmd/sensord/      → Sensor daemon (IOKit HID → shared memory)
cmd/sensordash/   → Terminal dashboard (shared memory → TUI)
sensor/           → IOKit/CoreFoundation bindings via purego (no CGO)
shm/              → POSIX shared memory ring buffers and snapshots
detector/         → Vibration detection, AHRS orientation, heartbeat BCG
Shared Memory Layout

The shared memory format is compatible with the original Python implementation, allowing mixed Go/Python usage:

  • Ring buffers (accel, gyro): 16-byte header + 8000 entries × 12 bytes (3× int32)
  • Snapshots (ALS, lid): 8-byte header + raw payload
No CGO

All macOS framework calls (IOKit, CoreFoundation) use purego for zero-CGO dynamic linking.

Credits

Original Python implementation by olvvier.

License

MIT — see LICENSE.

Directories

Path Synopsis
cmd
kbpulse command
kbpulse controls Apple Silicon MacBook keyboard backlight brightness.
kbpulse controls Apple Silicon MacBook keyboard backlight brightness.
sensord command
sensord is a daemon that reads Apple Silicon IMU sensors and writes data to POSIX shared memory ring buffers for consumption by sensordash or other readers.
sensord is a daemon that reads Apple Silicon IMU sensors and writes data to POSIX shared memory ring buffers for consumption by sensordash or other readers.
sensordash command
sensordash is a terminal dashboard that reads sensor data from shared memory (written by sensord) and displays live vibration detection, orientation, heartbeat estimation, and environmental sensors.
sensordash is a terminal dashboard that reads sensor data from shared memory (written by sensord) and displays live vibration detection, orientation, heartbeat estimation, and environmental sensors.
Package detector implements vibration detection, orientation tracking (Mahony AHRS), and experimental heartbeat (BCG) detection from IMU data.
Package detector implements vibration detection, orientation tracking (Mahony AHRS), and experimental heartbeat (BCG) detection from IMU data.
Package keyboard controls Apple Silicon MacBook keyboard backlight brightness via the private CoreBrightness.framework (KeyboardBrightnessClient).
Package keyboard controls Apple Silicon MacBook keyboard backlight brightness via the private CoreBrightness.framework (KeyboardBrightnessClient).
Package sensor reads accelerometer, gyroscope, ambient light, and lid angle from Apple Silicon MacBooks via IOKit HID (AppleSPUHIDDevice, Bosch BMI286 IMU).
Package sensor reads accelerometer, gyroscope, ambient light, and lid angle from Apple Silicon MacBooks via IOKit HID (AppleSPUHIDDevice, Bosch BMI286 IMU).
Package shm provides POSIX shared memory ring buffers and snapshot regions compatible with the Python spu_sensor.py layout.
Package shm provides POSIX shared memory ring buffers and snapshot regions compatible with the Python spu_sensor.py layout.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL