Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-opus-4-20250514-thinking-16k· AnthropicHugging Face LMArena Human Preference 140K

use ntfy server running on Debian to notify my iPhone when my MacBook battery is fully…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Mistralmagistral-medium-2506’s answer.
  1. User

    use ntfy server running on Debian to notify my iPhone when my MacBook battery is fully charged

  2. Claude Assistant

    Here's how to set up ntfy on Debian to notify your iPhone when your MacBook battery is fully charged:

    1. Set up ntfy server on Debian

    First, install and configure ntfy on your Debian server:

    # Install ntfy
    curl -sSL https://github.com/binwiederhier/ntfy/releases/latest/download/ntfy_amd64.deb -o ntfy.deb
    sudo dpkg -i ntfy.deb
    
    # Start and enable the service
    sudo systemctl enable ntfy
    sudo systemctl start ntfy
    

    Configure ntfy by editing /etc/ntfy/server.yml:

    base-url: "http://your-server-ip"  # or https://your-domain.com if using HTTPS
    behind-proxy: false
    

    2. Set up iPhone to receive notifications

    Install the ntfy app from the App Store on your iPhone. In the app:

    • Add your server: http://your-server-ip (or use HTTPS if configured)
    • Subscribe to a topic, for example: macbook-battery

    3. Create battery monitoring script on MacBook

    Create a script on your MacBook that monitors battery status:

    #!/bin/bash
    # Save as ~/battery-monitor.sh
    
    NTFY_SERVER="http://your-server-ip"
    TOPIC="macbook-battery"
    CHECK_INTERVAL=300  # Check every 5 minutes
    
    while true; do
        # Get battery percentage and charging status
        BATTERY_INFO=$(pmset -g batt)
        PERCENTAGE=$(echo "$BATTERY_INFO" | grep -Eo '[0-9]+%' | sed 's/%//')
        CHARGING=$(echo "$BATTERY_INFO" | grep -q "AC Power" && echo "true" || echo "false")
        
        # Check if battery is fully charged (100% and connected to AC)
        if [ "$PERCENTAGE" -eq 100 ] && [ "$CHARGING" = "true" ]; then
            # Send notification
            curl -d "MacBook battery is fully charged! 🔋" \
                 -H "Title: Battery Full" \
                 -H "Priority: default" \
                 -H "Tags: battery,macbook" \
                 "$NTFY_SERVER/$TOPIC"
            
            # Wait longer before checking again to avoid spam
            sleep 3600  # Wait 1 hour
        else
            sleep $CHECK_INTERVAL
        fi
    done
    

    Make the script executable:

    chmod +x ~/battery-monitor.sh
    

    4. Run the script automatically

    Create a LaunchAgent to run the script at startup:

    <!-- Save as ~/Library/LaunchAgents/com.user.battery-monitor.plist -->
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.user.battery-monitor</string>
        <key>ProgramArguments</key>
        <array>
            <string>/bin/bash</string>
            <string>/Users/YOUR_USERNAME/battery-monitor.sh</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <true/>
    </dict>
    </plist>
    

    Load the LaunchAgent:

    launchctl load ~/Library/LaunchAgents/com.user.battery-monitor.plist
    

    Optional: Enhanced script with additional features

    Here's a more sophisticated version that only notifies once per charge cycle:

    #!/bin/bash
    # Enhanced battery monitor with state tracking
    
    NTFY_SERVER="http://your-server-ip"
    TOPIC="macbook-battery"
    STATE_FILE="$HOME/.battery-monitor-state"
    CHECK_INTERVAL=300
    
    # Initialize state
    NOTIFIED=false
    [ -f "$STATE_FILE" ] && NOTIFIED=$(cat "$STATE_FILE")
    
    while true; do
        BATTERY_INFO=$(pmset -g batt)
        PERCENTAGE=$(echo "$BATTERY_INFO" | grep -Eo '[0-9]+%' | sed 's/%//')
        CHARGING=$(echo "$BATTERY_INFO" | grep -q "AC Power" && echo "true" || echo "false")
        
        if [ "$PERCENTAGE" -eq 100 ] && [ "$CHARGING" = "true" ] && [ "$NOTIFIED" = "false" ]; then
            # Send notification
            curl -d "MacBook battery is fully charged! Time to unplug 🔌" \
                 -H "Title: Battery Full (100%)" \
                 -H "Priority: default" \
                 -H "Tags: battery,full,macbook" \
                 "$NTFY_SERVER/$TOPIC"
            
            # Mark as notified
            echo "true" > "$STATE_FILE"
            NOTIFIED=true
            
        elif [ "$PERCENTAGE" -lt 100 ] || [ "$CHARGING" = "false" ]; then
            # Reset notification state when unplugged or not full
            echo "false" > "$STATE_FILE"
            NOTIFIED=false
        fi
        
        sleep $CHECK_INTERVAL
    done
    

    This setup will monitor your MacBook's battery status and send a push notification to your iPhone through your ntfy server when the battery reaches 100% while charging.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.