Skip to main content

A macOS utility that alerts you via WhatsApp when your battery reaches a defined threshold using Twilio.

Project description

⚡ PowerNudge

Package version Downloads

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 pmset command
  • 📤 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 pmset for 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

  1. Reads your battery percentage using the pmset command.
  2. 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.
  3. Automatically enables Wi-Fi if off, and waits for connectivity.
  4. Uses Twilio to send a WhatsApp alert.
  5. All activity is logged using a central log object 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 utilities
  • twilio_helper/main.py — for sending WhatsApp messages via Twilio API
  • src/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

power_nudge-0.2.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

power_nudge-0.2.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

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

Hashes for power_nudge-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5f612594dd782fbad029c4c284bd9f2e8933c40a87a0d67bb90491d93667929b
MD5 df8f4651b1325fe2409dd70131ba66df
BLAKE2b-256 02f7d7928d510c13643d689962895650d7763eacd546f3df2a7ef755d0b072c0

See more details on using hashes here.

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

Hashes for power_nudge-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2186b3c2bdb0dfcb6204783ea116dc1fcd65013e06b484a78ff344d97366aea3
MD5 30cceeeef236150e72c128d6660e80c8
BLAKE2b-256 f199a3d4da323c1ea2acb8cae86616017d23fd7f5274b954c70ecb4c6c2516aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page