Skip to content

Instantly share code, notes, and snippets.

@harendra21
Created November 27, 2021 11:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harendra21/cd9c6abffe19c01a47f9dada5a632c95 to your computer and use it in GitHub Desktop.
Save harendra21/cd9c6abffe19c01a47f9dada5a632c95 to your computer and use it in GitHub Desktop.
# 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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment