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.2.tar.gz (5.5 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.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file power_nudge-0.2.2.tar.gz.

File metadata

  • Download URL: power_nudge-0.2.2.tar.gz
  • Upload date:
  • Size: 5.5 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.2.tar.gz
Algorithm Hash digest
SHA256 702ae94a632699ead79bbda295f9afe30416a95ac9b4377db76ac96297cb5455
MD5 a580c9141b5eb64dd3a16a46c417c6c7
BLAKE2b-256 2f8736f9622c3973511f819c4ab259077999851c3ecb568c138c5d7682938b29

See more details on using hashes here.

File details

Details for the file power_nudge-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: power_nudge-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6fb8e83ccdeb49bf394acc620c5065b1c4b1f6de76c77d79d9ff2bd1cd170e9a
MD5 bd99f18c23982ff1ed9e7dfc8120aa46
BLAKE2b-256 8ce15bdbc2b9610cfd39b27b6eb508c4f89961f92f2bce6659305ca7a0979c14

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