The Battery Alert Service is a Python script that monitors the battery level of a Windows laptop and displays alert messages when certain conditions are met. The script is designed to run continuously in the background as a Windows service, providing real-time notifications to the user.
- Monitors the battery level and power status (plugged in or unplugged).
- Displays alert messages when the battery reaches a specific percentage (e.g., 100%).
- Calculates and displays the estimated time remaining until the battery is fully charged or depleted.
- Runs as a Windows service, allowing for seamless background execution without user intervention.
- Built using the psutil library for battery monitoring and ctypes for displaying message dialogs.
- Python 3.x installed on the system.
- PyInstaller library for converting the Python script into an executable.
- NSSM (Non-Sucking Service Manager) for creating and managing Windows services.
-
Clone or download the repository to your local machine.
-
Install the required Python packages using pip:
pip install psutil
- Install PyInstaller for converting the script into an executable:
pip install pyinstaller
- Download and extract NSSM from the official website: NSSM - the Non-Sucking Service Manager.
-
Edit the
battery_alert.py
script to customize the battery percentage threshold and other parameters if needed. -
Convert the Python script into an executable using PyInstaller:
pyinstaller --onefile battery_alert.py
- Use NSSM to create a Windows service for the executable:
nssm install batteryAlert "C:\path\to\battery_alert.exe"
- Start the batteryAlert service:
net start batteryAlert
- If you encounter any issues with the service, check the Event Viewer or system logs for error messages.
- Ensure that the service has the necessary permissions and dependencies to run successfully.
- Verify that the NSSM executable directory is added to the system's PATH variable.
- Update NSSM to the latest version if you encounter compatibility issues.
Contributions to the project are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License.