Automated battery charge management system that protects your MacBook's battery health by maintaining optimal charge levels.
- Automatically enables charging when battery drops below 20%
- Disables charging when battery reaches 80%
- Runs continuously via launch agent (every 3 minutes)
- Includes installer package for easy deployment
- Self-contained installation with automatic shortcut configuration
- Build the installer package:
chmod +x build.sh
./build.sh
- Install the package:
open BatteryManagerInstaller.pkg
The installer will:
- Copy launch agent to
~/Library/LaunchAgents
- Load the background service
- Place shortcut on your Desktop for verification
- Automatically open the shortcut for initial configuration
- Runs every 180 seconds (3 minutes)
- Executes the BatteryManager shortcut
- Automatic loading on system start
- Logs output to
/tmp/batterymanager.{out,err}
- Installs launch agent to user's LaunchAgents directory
- Copies shortcut to Desktop
- Sets proper file permissions
- Loads the launch agent
- Clears file quarantine attributes
- Signs all script files with developer ID
- Creates installation package using pkgbuild
- Sets proper permissions on package components
To modify battery thresholds:
- Open
BatteryManager.shortcut
- Edit the "If" conditions:
- Change 20% (low threshold)
- Change 80% (high threshold)
- Rebuild and reinstall the package
Check service status:
launchctl list | grep com.luracast.batterymanager
View logs:
tail -f /tmp/batterymanager.out /tmp/batterymanager.err
Uninstall:
launchctl remove com.luracast.batterymanager
rm ~/Library/LaunchAgents/com.luracast.batterymanager.plist
rm ~/Desktop/BatteryManager.shortcut
MIT License - See LICENSE file for details