A lightweight desktop application that automatically shuts down your computer when running on battery power. Perfect for preventing accidental battery drain if your charger gets disconnected.
The application automatically detects your system language and supports:
- π¬π§ English
- π·πΊ Russian (Π ΡΡΡΠΊΠΈΠΉ)
- πΊπ¦ Ukrainian (Π£ΠΊΡΠ°ΡΠ½ΡΡΠΊΠ°)
If your system language isn't supported, the app defaults to English.
- π Automatic Battery Monitoring - Continuously monitors your laptop's power status
- β±οΈ Configurable Delay - Set a delay (1-60 minutes) before shutdown occurs
- π Battery Threshold - Set minimum battery percentage for shutdown trigger
- π Warning Dialog - 30-second countdown with cancel option before shutdown
- π Sound Alerts - Optional audio notifications (can be disabled)
- π Auto-Start - Option to run at Windows startup
- πΎ Persistent Settings - All configurations are automatically saved
- π¨ System Tray Integration - Minimizes to tray, runs in background
- Windows 7/8/10/11
- Python 3.7 or higher (for running from source)
- PyQt5
- psutil
- Download the latest EXE file from Releases
- Run the executable
- Configure your settings
- Enable auto-shutdown
-
Clone the repository:
git clone https://github.com/XXanderWP/WinPowerControl.git cd battery-shutdown -
Create and activate virtual environment:
Windows:
setup_venv.bat venv\Scripts\activate
-
Run the application:
# Default run python main.py # Debug mode (disables battery check at startup) python main.py --debug
To create a standalone executable:
-
Activate virtual environment (if not already activated)
venv\Scripts\activate # Windows
-
Run build script:
Windows:
build.bat
The executable will be created in the dist folder.
- Power Monitoring: The app continuously monitors your computer's power status
- Battery Transition: When disconnected from AC power, a countdown timer starts
- Threshold Check: If battery drops below your set percentage and time expires, shutdown is triggered
- Warning Dialog: A 30-second warning appears before shutdown
- Cancel Option: You can cancel the shutdown at any time
- Settings: 5-minute delay, 50% battery threshold
- Event: Charger disconnects, battery at 75%
- Process:
- Timer starts (5 minutes)
- After 5 minutes, if battery β€ 50%, warning dialog appears
- 30-second countdown begins
- Computer shuts down (unless cancelled)
- Enable Auto-Shutdown: Master on/off switch
- Delay Before Shutdown: 1-60 minutes (time after AC disconnect)
- Minimum Battery Charge: 1-100% (shutdown threshold)
- Sound Notifications: Enable/disable audio alerts
- Auto-Start: Launch at Windows startup
Settings are stored in: %USERPROFILE%\.win_power_control\config.json
Example configuration:
{
"enabled": true,
"delay_minutes": 5,
"battery_percent": 50,
"sound_enabled": true,
"language": null
}- Accidental Disconnect Protection: Prevent battery drain if charger unplugs
- Power Outage Safety: Auto-shutdown during extended power outages
- Battery Longevity: Avoid deep discharge cycles
- Remote Systems: Automatically manage power on unattended machines
- Cancellable Shutdown: Always get 30 seconds to cancel
- Auto-Disable on Cancel: If you cancel once, feature turns off
- Persistent Status: System tray icon shows current state
- Multiple Conditions: Both time AND battery level must be met
battery-shutdown/
βββ main.py # Application entry point
βββ src/
β βββ core/
β β βββ config.py # Configuration management
β β βββ monitor.py # Battery monitoring thread
β βββ gui/
β β βββ main_window.py # Main application window
β β βββ settings_dialog.py # Settings dialog
β β βββ help_dialog.py # Help/FAQ dialog
β β βββ shutdown_dialog.py # Shutdown warning dialog
β βββ i18n/
β β βββ translations.py # Translation system
β β βββ help_content.py # Multi-language help text
β βββ utils/
β βββ system.py # System utilities (shutdown, autostart)
βββ requirements.txt # Python dependencies
βββ setup_venv.bat # Virtual environment setup (Windows)
βββ build.bat # Build script (Windows)
βββ README.md # This file
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a 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
To add support for a new language:
- Edit
src/i18n/translations.py - Add your language code and translations to
TRANSLATIONSdictionary - Edit
src/i18n/help_content.py - Add help content in your language to
HELP_CONTENTdictionary
- Ensure Python 3.7+ is installed
- Check that all dependencies are installed:
pip install -r requirements.txt - Try running with admin privileges
- This app requires a laptop with a battery
- Desktop computers are not supported
- Check if Windows detects your battery in Device Manager
- Ensure you have necessary permissions
- Check Windows Registry:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run - Try running the app as administrator
- Check Windows Event Viewer for shutdown errors
- Ensure you have permission to shutdown the system
- Test manual shutdown command:
shutdown /s /t 0
This project is licensed under the MIT License - see the LICENSE file for details.
Created with β€οΈ for better battery management
- PyQt5 - Cross-platform GUI framework
- psutil - System and process utilities
- Python community - For amazing tools and libraries
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: xanderwp@protonmail.com
β If you find this project useful, please consider giving it a star!
- macOS support
- Linux support
- Hibernate option (instead of shutdown)
- Sleep mode trigger
- Battery statistics
- Custom shutdown scripts