A lightweight command-line tool for retrieving the battery status of AirPods (or other Bluetooth headphones) on macOS. This script fetches connection status and battery levels for left, right, and case batteries directly from macOS system data.
- ✅ Check AirPods connection status
- ✅ Display battery levels (left earbud, right earbud, and case)
- ✅ Lightweight & fast execution
- ✅ Fully automated, no additional setup required
- ✅ Can be added to macOS menu bar using SwiftBar/BitBar
curl -O https://github.com/pratikbhavarthe/AirpodsBattery/bt_battery.shchmod +x bt_battery.shTo make it accessible system-wide:
sudo mv bt_battery.sh /usr/local/bin/bt_batteryNow you can run it with:
bt_batteryRun the script:
./bt_battery.sh- Finds AirPods MAC Address: Extracts Bluetooth headphone details from
system_profiler. - Checks if AirPods are Connected: Looks for the
Connected: Yesfield. - Retrieves Battery Data: Reads battery percentages from macOS Bluetooth preferences.
- Displays Status: Outputs formatted battery information.
- Download SwiftBar
- Move
bt_battery.shto~/Documents/SwiftBar/ - Rename it to
bt_battery.1m.sh(Runs every 1 minute) - Your AirPods battery status will appear in the macOS menu bar! 🎉
This project is licensed under the MIT License.
Feel free to fork, submit pull requests, or suggest enhancements!
This has been tested and works on OSX 10.12.6 and above.