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.1.tar.gz (5.3 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.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: power_nudge-0.2.1.tar.gz
  • Upload date:
  • Size: 5.3 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.1.tar.gz
Algorithm Hash digest
SHA256 f1d095192c7ec5ea35cdccfef492e522aff3bcd946c3665878c6ab91cb4b4d29
MD5 2493a708dd5e199843d84881feddb349
BLAKE2b-256 50bdaca2fc701a04aed6019aad5c4e70e74adb87cb7aa4cbaae7e6f1759b6107

See more details on using hashes here.

File details

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

File metadata

  • Download URL: power_nudge-0.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 be872427a0574c9978c067689faf0c396304fb45590695648e1930f6e87306fe
MD5 8f2a1218452cf9771d9f3186d4c1304c
BLAKE2b-256 16b154d0bfb5df30ec1ba21d0084155137e41842417a32856413dd497ad8966c

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