sindresorhus/is-camera-on
> Check if a Mac camera is on
Requirements
macOS 10.15+
Install
Add the following to Package.swift:
.package(url: "https://github.com/sindresorhus/is-camera-on", from: "3.0.0")Usage
Checking camera status
import IsCameraOn
// Check built-in camera only (default)
print(isCameraOn())
//=> true
// Check both built-in and external physical cameras
print(isCameraOn(includeExternal: true))
//=> trueMonitoring camera status changes
import IsCameraOn
// Monitor camera status changes with async/await
Task {
for await isOn in cameraStatusChanges() {
print("Camera status: \(isOn ? "ON" : "OFF")")
}
}Notes:
- Emits the current status immediately, then only on changes
- Automatically handles device hot-plugging (cameras being connected/disconnected)
- Uses property listeners for real-time updates (not polling)
Testing
To run the manual test:
swift run TestCameraswift run TestAsyncCameraPackage Metadata
Repository: sindresorhus/is-camera-on
Default branch: main
README: readme.md