A macOS utility that alerts you via WhatsApp when your battery reaches a defined threshold using Twilio.
Project description
⚡ PowerNudge
PowerNudge is a lightweight macOS utility that monitors your MacBook's battery percentage and sends you a WhatsApp alert via Twilio when it reaches a predefined charging level — so you can unplug and prolong battery health.
Built with automation in mind, it’s perfect for users who want a hands-free way to monitor charging without keeping an eye on the battery all the time.
🚀 Features
- 🔋 Monitors battery percentage using macOS's
pmsetcommand - 📤 Sends WhatsApp messages via Twilio when battery thresholds are crossed
- 📶 Automatically enables Wi-Fi if disabled, and checks for internet connectivity
- 🧪 Integrated logging with Loguru for easier debugging and monitoring
- ⚙️ Configurable thresholds and message templates via
src/config.py
🛠 Requirements
- Python 3.12+
- macOS (uses
pmsetfor battery info) - Twilio Account with WhatsApp sandbox enabled
- Internet connection to send WhatsApp messages
📦 Installation
Install dependencies:
pip install power_nudge
Make sure you have the appropriate values set in src/config.py or through environment variables if abstracted.
🧠 How It Works
- Reads your battery percentage using the
pmsetcommand. - Checks if battery is above or below thresholds:
- Sends "Please unplug!" if battery is too high.
- Sends "Please plug in!" if battery is too low.
- Automatically enables Wi-Fi if off, and waits for connectivity.
- Uses Twilio to send a WhatsApp alert.
- All activity is logged using a central
logobject via Loguru.
🧪 Usage
python src/power_nudge/main.py
Or schedule it with a cron job or launchd to run periodically in the background.
📝 Logging
PowerNudge uses the Loguru library for structured, colorful, and level-based
logging (debug, info, warning, error).
You can configure your logging output in the logger.py file.
📬 Example WhatsApp Alerts
🔋 Battery is 90%. Please unplug the charger! 🔌 Battery is 15%. Please plug in your charger!
🧰 Developer Info
You’ll find helper functions in:
src/power_nudge/utils/helper.py— for battery, Wi-Fi, and internet utilitiestwilio_helper/main.py— for sending WhatsApp messages via Twilio APIsrc/power_nudge/utils/logger.py— for centralized logging setup
📄 License
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file power_nudge-0.2.0.tar.gz.
File metadata
- Download URL: power_nudge-0.2.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.9.22 Linux/6.11.0-1012-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f612594dd782fbad029c4c284bd9f2e8933c40a87a0d67bb90491d93667929b
|
|
| MD5 |
df8f4651b1325fe2409dd70131ba66df
|
|
| BLAKE2b-256 |
02f7d7928d510c13643d689962895650d7763eacd546f3df2a7ef755d0b072c0
|
File details
Details for the file power_nudge-0.2.0-py3-none-any.whl.
File metadata
- Download URL: power_nudge-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.9.22 Linux/6.11.0-1012-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2186b3c2bdb0dfcb6204783ea116dc1fcd65013e06b484a78ff344d97366aea3
|
|
| MD5 |
30cceeeef236150e72c128d6660e80c8
|
|
| BLAKE2b-256 |
f199a3d4da323c1ea2acb8cae86616017d23fd7f5274b954c70ecb4c6c2516aa
|