Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions AutomationScripts/Battery Notification/Battery_Notification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import psutil
from plyer import notification
import time
# From psutil we import sensors battery class which gives us battery percentage
threshold = int(input('Enter the threshold: '))

battery = psutil.sensors_battery()
percent = battery.percent

while(True):
battery = psutil.sensors_battery()
cur_per = battery.percent
change = cur_per - percent
diff = abs(change)
# We calculate the change in the battery and show notification if battery level increases or decreases
if(diff >= threshold):
notification.notify(
title="Battery Percentage",
message=str(cur_per) + "% Battery Remaining",
timeout=5
)
percent = cur_per
continue
19 changes: 19 additions & 0 deletions AutomationScripts/Battery Notification/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This is a Python Script which shows the battery percentage left

## Requirements

For this script to run you need to have psutil and plyer packages installed

Run the command in terminal to install package

```
$ pip install psutil
```
```
$ pip install plyer
```
Run the program using command

```
$ python Battery_Notification.py
```