A menu bar application for macOS that allows you to set a sleep timer to automatically put your Mac to sleep. Features both manual timer mode and intelligent camera-based sleep detection.
- Menu Bar Countdown: View the remaining time directly in your menu bar next to the icon.
- Flexible Duration: Set timers anywhere from 15 minutes to 12 hours.
- Quick Presets: One-click access to common durations (15m, 30m, 1h, 1.5h, 2h, 3h, 4h, 6h).
- Easy Extension: Add +5, +15, +30, or +60 minutes to an active timer instantly.
- Visual Feedback: Circular progress ring and dynamic menu bar icons (moon/filled moon).
- Auto-Sleep: Automatically starts a 30-minute timer when it detects your eyes are closed for ~15 seconds.
- Activity Check: After 2 hours in camera mode, prompts you to confirm if you're still awake. If no response within 30 seconds, automatically puts the Mac to sleep.
- Privacy First: All processing is done on-device using Apple's Vision Framework. No video data is stored or transmitted.
- Smart Wake: Automatically cancels the pending timer if you open your eyes.
- Energy Efficient: Optimized "Eye Aspect Ratio" (EAR) algorithm for minimal battery impact.
- Auto Mode Switch: Automatically returns to manual mode before putting the computer to sleep.
- Adaptive App Icon: The application icon automatically changes between Light and Dark versions to match your macOS theme.
- Native Architecture: Uses
pmsetcommand for reliable and safe system sleep. - Modern UI: "Liquid Glass" design language that fits perfectly into macOS Sonoma, Sequoia, and the upcoming Tahoe.
- Launch at Login: Option to start the app automatically in the background.
- macOS 13.0 (Ventura) or later (Ready for macOS 26 Tahoe)
- Apple Silicon (M1/M2/M3/M4) or Intel Mac (runs via Rosetta 2 on older macOS)
- Xcode 15.0 or later (for building from source)
- Go to Actions tab
- Click on the latest successful build
- Download
Sleep-Timer-macOSartifact - Unzip the downloaded file
- Important: Remove the quarantine attribute:
xattr -cr "Sleep Timer.app" - Move
Sleep Timer.appto Applications folder
Note: The app is not notarized by Apple, so you need to remove the quarantine attribute or right-click and select "Open" the first time.
Security: If you have concerns about running a pre-built app, you can always review the source code and build it yourself (see Option 2 below).
- Clone the repository:
git clone https://github.com/wiltodelta/sleep-timer-app.git
cd sleep-timer-app- Create app bundle:
./create-app.sh- Open the app:
open "Sleep Timer.app"Or move to Applications:
mv "Sleep Timer.app" /Applications/- Launch the application - a moon icon will appear in your menu bar
- Click the moon icon to open the timer interface
- Select "Timer" mode at the top
- Set your desired sleep time:
- Use the slider for custom times
- Click a preset button for quick selection
- Click "Start Timer" to begin
- The menu bar icon changes to indicate an active timer (filled moon)
- Click the menu bar icon again to:
- View remaining time and progress
- Add more time if needed
- Cancel the timer
- Click the moon icon in your menu bar
- Select "Camera" mode at the top
- Grant camera permission when prompted
- The app will start tracking your eyes
- When your eyes are closed for ~15 seconds, a 30-minute timer starts automatically
- Open your eyes for a few seconds to cancel the timer
- Every 2 hours, you'll be asked if you're still awake
- Respond within 30 seconds to continue
- No response will put the Mac to sleep automatically
The app requires the following permissions:
Required:
- System Events permission - to put your Mac to sleep
Optional (for Camera Mode):
- Camera access - to detect when your eyes are closed
- All camera processing happens on-device; no data is sent anywhere
- Built with Swift and SwiftUI
- Uses
pmset sleepnowcommand for reliable system sleep - Runs as menu bar only application (no dock icon)
- Launch at Login support via
SMAppService - Camera mode uses Vision Framework for face and eye detection
- Eye Aspect Ratio (EAR) algorithm for sleep detection
- Optimized performance with cached frame counting (O(1) complexity)
- Minimal resource usage and energy efficient
- Automatic mode switching before sleep to ensure clean state
The app version is automatically derived from git tags. To release a new version:
- Commit and push your changes:
git add .
git commit -m "Add new features"
git push origin main- Create and push a git tag:
git tag -a v1.3.0 -m "Release v1.3.0: Activity check in camera mode"
git push origin v1.3.0- GitHub Actions will automatically:
- Extract version from the tag (e.g.,
v1.2.0→1.2.0) - Build the app with the correct version
- Create a GitHub Release
- Attach the app as a downloadable ZIP file
- Extract version from the tag (e.g.,
Version format: Use semantic versioning MAJOR.MINOR.PATCH
- MAJOR: Breaking changes (e.g.,
1.x.x→2.0.0) - MINOR: New features (e.g.,
1.1.x→1.2.0) - PATCH: Bug fixes (e.g.,
1.1.2→1.1.3)
Note: Local builds use version dev and are not intended for distribution
Contributions are welcome! Please feel free to submit a Pull Request.
The project includes comprehensive unit tests for core functionality:
# Run all tests
swift test
# Run tests with verbose output
swift test --verboseTest coverage includes:
- TimerManager: Timer lifecycle, add time, notifications
- SleepDetectionManager: Camera mode, state management, initialization
# Quick run for development
./run.sh
# Build release version
swift build -c release
# Create app bundle
./create-app.shMIT License - feel free to use this project for personal or commercial purposes.
"Sleep Timer is damaged and can't be opened" error:
- This is macOS Gatekeeper blocking unsigned apps downloaded from the internet
- To fix this, first navigate to Applications folder in Terminal:
cd /Applications - Then run this command to remove the quarantine attribute:
xattr -cr "Sleep Timer.app" - Alternatively, right-click the app in Finder, select "Open", and confirm in the dialog
- Why this happens: The app is not notarized by Apple, so macOS marks it as potentially unsafe
Timer doesn't put Mac to sleep:
- Check System Settings > Privacy & Security > Automation
- Ensure the app has permission to control System Events
Camera mode not working:
- Check System Settings > Privacy & Security > Camera
- Ensure Sleep Timer has camera access enabled
- Make sure your face is visible and well-lit
- The camera green indicator should be visible when camera mode is active
"Looking for your face..." message:
- Ensure your face is centered and clearly visible to the camera
- Check lighting conditions - avoid backlighting
- Clean your camera lens if needed
- Make sure no other app is using the camera
App doesn't appear in menu bar:
- Check that you're running macOS 13.0 or later
- Try quitting and restarting the application
Created with ❤️ for Mac users who want better control over their sleep schedules.


