mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-30 15:31:10 +00:00
Merge pull request #268 from Danuragtiwari/new
battery notification added
This commit is contained in:
commit
800f1f8cb3
13
scripts/battery_notification/README.md
Normal file
13
scripts/battery_notification/README.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
This python File used to give notification about your battery percentage of the device.
|
||||||
|
|
||||||
|
|
||||||
|
Pre-requisites:-you need to install python on your desktop along with some awesome packages as follows:-
|
||||||
|
|
||||||
|
1.)psutil :-pip install psutil
|
||||||
|
|
||||||
|
2.)pynotifier :- pip install py-notifier
|
||||||
|
|
||||||
|
3.)win10toast :- pip install win10toast
|
||||||
|
|
||||||
|
|
||||||
|
thanks for reading!!
|
19
scripts/battery_notification/battery_notification.py
Normal file
19
scripts/battery_notification/battery_notification.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# pip install psutil
|
||||||
|
import psutil
|
||||||
|
|
||||||
|
battery = psutil.sensors_battery()
|
||||||
|
plugged = battery.power_plugged
|
||||||
|
percent = battery.percent
|
||||||
|
|
||||||
|
if percent <= 30 and plugged!=True:
|
||||||
|
|
||||||
|
# pip install py-notifier
|
||||||
|
# pip install win10toast
|
||||||
|
from pynotifier import Notification
|
||||||
|
|
||||||
|
Notification(
|
||||||
|
title="Battery Low",
|
||||||
|
description=str(percent) + "% Battery remain!!",
|
||||||
|
duration=5, # Duration in seconds
|
||||||
|
|
||||||
|
).send()
|
3
scripts/battery_notification/requirement.txt
Normal file
3
scripts/battery_notification/requirement.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
psutil==5.7.2
|
||||||
|
py-notifier==0.1
|
||||||
|
win10toast==0.9
|
Loading…
Reference in New Issue
Block a user