Skip to content

Get a notification when your laptop battery level goes below 20% or above 90%

Notifications You must be signed in to change notification settings

franciscopower/battery-limit-notifier

Repository files navigation

Battery limit notifier

Displays a notification when battery level is above 90% while the computer is charging or below 20% while the commputer is discharging, in order to alert the user to unplug or plug the computer extending the computer's battery life.

Windows Installation

Just download the BatteryLimitNotifierSetup.exe file and run it on your computer. This will automatically perform all the steps discribed in the "Windows manual installation" section.

Windows manual installation

  1. Download the Battery Limit Notifier.exe and config.yaml files;
  2. Create a folder in the C:\Program Files directory named BatteryLimitNotifier;
  3. Move the Battery Limit Notifier.exe and config.yaml files to the created folder;
  4. Right-click the Battery Limit Notifier.exe file and select "Create shortcut";
  5. Press the Windows + r keys to open up a "Run" prompt. In the text field type "shell:common startup" and click "OK". This will open the startup applications folder.
  6. Move the shortcut created in step 5 to the folder opend in step 6.

Once the computer restarts, the program will automatically start. To manually start the program, simply double click the program icon.

Settings

Time between notifications, maximum and minimum battery limits can be adjusted, by adjusting the values in the config.yaml file:

Battery_min_limit: 20 # percent
Battery_max_limit: 90 # percent
Notification_interval: 5 # minutes

Build from source

This project can be compiled to an executable using a tool such as pyinstaller or can be run as a script.

Dependencies

(see requirements.txt)

psutil==5.8.0
pypiwin32==223
pywin32==303
PyYAML==6.0
schedule==1.1.0
win10toast==0.9

Option 1: Compile into an executable

  1. Clone repository:
    git clone https://github.com/franciscopower/battery-limit-notifier.git
  2. Create virtual environment:
    cd battery-limit-notifier
    python -m venv venv
    .\venv\Scripts\activate
    (assuming Windows PowerShell is being used)
  3. Install necessary dependencies:
    pip install psutil PyYAML schedule win10toast pyinstaller
  4. Run pyinstaller:
    pyinstaller --noconfirm --onefile --windowed --icon "<BASE_DIRECTORY>/battery-limit-notifier/res/Elegantthemes-Beautiful-Flat-One-Color-Battery-full.ico" --name "Battery Limit Notifier" --add-data "<BASE_DIRECTORY>/battery-limit-notifier/res;res/"  "<BASE_DIRECTORY>/battery-limit-notifier/battery_limit_notifier.py"
    (substitute <BASE_DIRECTORY> for the base directory of the github repository). After running pyinstaller, an output folder will be created with the executable file in it.
  5. Place the created executable file in a folder together with the config.yaml file.
  6. Right click on the Battery Limit Notifier.exe file and create a shortcut.
  7. Press the Windows + r keys on your keyboard and a windows should appear. Write shell:common startup in the text field and click OK. This will open up a folder in your windows explorer.
  8. Move the shortcut created in step 5 to the folder opened in step 5.
  9. Restart your computer and the program should start automatically.

Option 2: Run program as a script

  1. Install Python and all the dependencies listed above on your computer.
  2. Download the archive with all the files from this repository onto your computer and unzip it or clone this repository onto your computer.
  3. Place the batery_monitor folder in a folder named Startup_scripts in your C: drive. The scipts and images should end up int C:\Startup_scripts\battery_monitor.
  4. Right click on the python file and select Open with > Choose another app. When a pop-up windows appears, select "Python" and check the box "Always use this app to open .py files", before clicking OK.
  5. Right click on the battery_limiter_launcher.vbs file and create a shortcut.
  6. Press the Windows + r keys on your keyboard and a windows should appear. Write shell:startup in the text field and click OK. This will open up a folder in your windows explorer.
  7. Move the shortcut created in step 4 to the folder opened in step 5.
  8. Restart your computer and the program should start automatically.

About

Get a notification when your laptop battery level goes below 20% or above 90%

Resources

Stars

Watchers

Forks

Packages

No packages published