Skip to content

Repository files navigation

Eject Different

Think Different. Eject Different.

Knock three times on an Apple-silicon MacBook and Eject Different safely ejects every removable physical disk — external drives and SD cards. No clicking. No menu hunting. No touching the volume control.

What it does

  • Reads the MacBook's hidden Apple SPU IMU (accelerometer and gyroscope) through IOKit HID.
  • Ignores single knocks, double knocks, and mechanical bounce.
  • On a triple knock, automatically detects and stops any active Time Machine backups before proceeding with disk ejection.
  • Wired Time Machine exception: a backup in progress to a wired destination never blocks the knock — if backupd still holds the disk after being interrupted, Eject Different force-unmounts that wired backup disk anyway. Other busy disks (an rsync, an app transfer) are still politely refused.
  • Uses diskutil eject on every removable physical disk — external USB/Thunderbolt drives and SD cards in the built-in reader. The internal boot disk is never touched. It never force-unmounts a busy volume.
  • Plays an original C-major add-9 success chord. On refusal/failure, it plays macOS's built-in Sosumi sound.
  • Temporarily unmutes and sets output to 100% for feedback, then restores the exact prior mute and volume settings.
  • Runs as a root LaunchDaemon (required for SPU HID access) and stays awake with the lid open or closed only while plugged into AC. On battery the Mac sleeps normally, and the display is allowed to sleep in both cases.

Requirements

  • Apple Silicon MacBook with AppleSPUHIDDevice (M2/M3/M4/M5; select M1 Pro hardware may work)
  • Not Mac Studio or Mac mini — those boards ship no SPU IMU (verified against an M1 Max and M2 Max Studio: no 0xFF00 accel/gyro HID nodes).
  • macOS 15+
  • Xcode command-line tools / Swift 6 to build

Install

git clone https://github.com/nsd97/eject-different.git
cd eject-different
sudo Scripts/install.sh

Verify:

sudo /usr/local/libexec/eject-different/eject-different --probe
sudo launchctl print system/com.nsd97.eject-different

Uninstall and restore normal sleep:

sudo Scripts/uninstall.sh

Power note: closed-lid listening requires the machine not to sleep. The installer applies pmset -c sleep 0 disablesleep 1 (AC only), so the Mac stays awake with the lid closed only while plugged in; on battery it sleeps normally (pmset -b sleep 1 disablesleep 0). The display is always allowed to sleep (displaysleep 10). Uninstall restores the stock sleep policy.

Design

The sensor is a Bosch BMI286-class IMU behind Apple's Sensor Processing Unit. Accelerometer reports use vendor usage page 0xFF00, usage 3, and gyroscope reports use usage 9; each 22-byte report carries Q16 xyz values. A low-pass/high-pass acceleration filter is fused with rotational gyroscope impulses. A 400 ms grouping window recognizes exactly three knocks.

The sound recording in this repository is original and generated by Scripts/generate-success-chord.py; no Apple startup audio is redistributed.

Credits

Eject Different stands on excellent MIT-licensed reverse engineering:

  • shaircast/nocnoc — Swift SPU HID access and knock-pattern filtering, adapted in SPUAccelerometerService.swift and KnockDetector.swift.
  • olvvier/apple-silicon-accelerometer — SPU/BMI286 report layout, usages, Q16 scaling, and driver wake properties.
  • taigrr/spank — prior art proving a root LaunchDaemon can continuously monitor this sensor and produce audio feedback.

Thank you to those authors for opening the door.

License

MIT. See LICENSE.

About

Triple-knock your MacBook to safely eject external disks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages