A native macOS menu bar app that displays a full-screen warning overlay when your MacBook battery drops below a customizable threshold. Never let your MacBook die unexpectedly again.
- Full-Screen Warning Overlay - Impossible to miss red overlay when battery is low
- Customizable Threshold - Set your warning level between 5% and 99%
- Two Warning Modes:
- Warning Mode (6-99%) - Dismissable with ESC or button, reminds again at next % drop
- Critical Mode (≤5%) - Requires holding ESC for 3 seconds to dismiss
- Auto-Dismiss - Overlay disappears automatically when power is connected
- Sleep-Friendly - Doesn't prevent your Mac from sleeping
- Multi-Monitor Support - Overlay appears on all connected displays
- Menu Bar App - Lives quietly in your menu bar with dynamic battery icon
- Native macOS - Built with SwiftUI, no Electron, minimal resource usage
Requirements:
- macOS 14.0 or later
- Xcode 15+ or Swift 5.9+
# Clone the repository
git clone https://github.com/rn54n/batterywarn.git
cd batterywarn
# Build the app
swift build -c release
# Run the app
./.build/release/BatteryWarnDownload the latest .dmg from the Releases page.
- Launch the app - BatteryWarn appears in your menu bar
- Configure threshold - Click the menu bar icon → Settings
- Test the overlay - Use the "Test Warning Overlay" button
- Work normally - The app monitors your battery in the background
| Shortcut | Warning Mode | Critical Mode (≤5%) |
|---|---|---|
ESC |
Dismiss immediately | Hold for 3 seconds |
⌘, |
Open Settings | - |
⌘Q |
Quit app | - |
- Battery drops below threshold → Warning overlay appears
- Dismiss the warning → Overlay closes, will remind at next % drop
- Connect power → Overlay disappears automatically
- Battery ≤5% → Critical mode, must hold ESC for 3 seconds
# Debug build
swift build
# Release build
swift build -c release
# Run tests (if available)
swift testbatterywarn/
├── Package.swift # Swift Package Manager config
├── README.md
├── LICENSE
└── BatteryWarn/
├── BatteryWarnApp.swift # App entry point & AppDelegate
├── BatteryMonitor.swift # IOKit battery monitoring
├── OverlayView.swift # SwiftUI overlay UI
├── OverlayWindowController.swift # Window management
├── SettingsView.swift # Settings UI
└── Info.plist # App configuration
- Battery Monitoring: Uses
IOKit.psfor real-time battery status - Power Source Notifications: Subscribes to system power events for instant updates
- Window Management: Uses
NSWindowwith appropriate window levels - No External Dependencies: Pure Swift/SwiftUI implementation
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Requires macOS 14.0 (Sonoma) or later
- Not available on the Mac App Store (sandbox restrictions)
- Overlay may not appear over some full-screen apps
This project is licensed under the MIT License - see the LICENSE file for details.
Created by @nowness0x
- Built with SwiftUI and IOKit
- Inspired by the need to never have a MacBook die during important work
If you find this useful, consider giving it a ⭐ on GitHub!
