Skip to content

Autonomous macOS daemon for backpack operation with offline LLM resilience. Ultra-low power management, thermal monitoring, network fallback, and intelligent notifications.

Notifications You must be signed in to change notification settings

birddigital/backpack-mode

Repository files navigation

Backpack Mode

Ultra-low power macOS daemon for clamshell operation in backpack

What is Backpack Mode?

Backpack Mode is a macOS daemon that optimizes your Mac for safe, efficient operation while closed in a backpack. It manages power consumption, thermal output, network connectivity, and keeps you informed via AirDrop notifications to your phone.

Use Case

┌─────────────────────────────────────────────────────────────┐
│                    BACKPACK MODE SCENARIO                   │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  [Mac in Backpack]          [Your Phone]                    │
│  ┌─────────────┐             ┌──────────┐                  │
│  │  Lid Closed │ ──AirDrop──→│ Status   │                  │
│  │  Ultra-Low  │    Status   │ Updates  │                  │
│  │  Power Mode │             │ Alerts   │                  │
│  │  Connected  │◄─Hotspot───┤          │                  │
│  └─────────────┘   WiFi/BT   └──────────┘                  │
│                                                             │
│  ✓ Runs cool (~40°C max)                                   │
│  ✓ Minimal battery drain                                   │
│  ✓ Always connected (WiFi→Hotspot→BT)                      │
│  ✓ You know what's happening (AirDrop alerts)              │
│                                                             │
└─────────────────────────────────────────────────────────────┘

Features

1. Ultra-Low Power & Thermal Management

  • CPU throttling: Minimum viable frequency (800MHz base)
  • Process optimization: Suspend non-essential daemons
  • Active thermal monitoring: Keep CPU temp < 65°C (safe for enclosed space)
  • Adaptive performance: Further throttle if temp exceeds threshold
  • Battery-aware: Different profiles when on battery vs AC

2. Network Resilience Chain

WiFi (Known Networks)
    ↓ (disconnect)
Phone Hotspot (WiFi)
    ↓ (unavailable)
Bluetooth PAN (Personal Area Network)
    ↓ (last resort)
Bluetooth Beacon (status updates only)

3. Status Communication to Phone

  • AirDrop notifications for:

    • ✅ Backpack Mode activated
    • ⚠️ Thermal warning (>60°C)
    • 🔴 Critical temperature (>70°C)
    • 📶 Network status changes
    • 🔋 Low battery (<20%)
    • ✅ Returning to normal mode
  • Periodic health updates (configurable, default: every 30 min)

4. Automatic Activation

  • Activates when lid closes (via pmset -g lid state)
  • Deactivates when lid opens
  • Manual control via CLI: backpack-mode [enable|disable|status]

Installation

# Build and install
cd ~/sources/standalone-projects/backpack-mode
make install

# Enable daemon
sudo launchctl load ~/Library/LaunchAgents/com.backpackmode.daemon.plist

# Start manually for testing
./bin/backpack-mode

Usage

# Check status
backpack-mode status

# Enable manually (useful for testing)
backpack-mode enable

# Disable manually
backpack-mode disable

# View logs
tail -f ~/.backpack-mode/backpack.log

# Configure settings
nano ~/.backpack-mode/config.json

Configuration

Default configuration (~/.backpack-mode/config.json):

{
  "thermal": {
    "max_temp_c": 65,
    "critical_temp_c": 70,
    "check_interval_seconds": 10
  },
  "power": {
    "cpu_speed_limit": 800,
    "low_power_mode": true,
    "disable_non_essential": true
  },
  "network": {
    "fallback_chain": ["wifi", "hotspot", "bluetooth"],
    "hotspot_ssid": "YourPhoneHotspot",
    "check_interval_seconds": 30
  },
  "notifications": {
    "method": "airdrop",
    "phone_name": "YouriPhone",
    "health_update_interval_minutes": 30,
    "alert_on": ["thermal_warning", "network_change", "low_battery"]
  }
}

Architecture

backpack-mode/
├── cmd/
│   └── main.go                 # Daemon entry point
├── internal/
│   ├── config/                 # Configuration management
│   ├── daemon/                 # Main daemon orchestrator
│   ├── monitor/                # System monitoring (CPU, thermal, power)
│   ├── network/                # Network fallback chain
│   ├── notify/                 # AirDrop notification system
│   └── power/                  # Power management (CPU throttling, pmset)
├── scripts/
│   └── install.sh              # Installation script
└── com.backpackmode.daemon.plist  # Launchd configuration

How It Works

State Machine

                      ┌─────────────┐
                      │   NORMAL    │
                      │   (Lid Open)│
                      └──────┬──────┘
                             │ Lid Close
                             ▼
                      ┌─────────────┐
              ┌───────│ BACKPACK    │─────────┐
              │       │   MODE      │         │
              │       └──────┬──────┘         │
              │              │               │
              │              │ Temp > 65°C   │ Network Loss
              │              ▼               ▼
              │       ┌─────────────┐  ┌──────────┐
              │       │  THROTTLE   │  │ FALLBACK │
              │       │  MODE       │  │   CHAIN  │
              │       └──────┬──────┘  └────┬─────┘
              │              │              │
              │              │ Temp < 55°C  │
              │              └──────────────┘
              │
              └──────────────→ Lid Open → NORMAL MODE

Power Management

  • Uses pmset to configure power settings
  • Uses powermetrics for thermal monitoring
  • Uses sysctl to manage CPU frequency

Network Management

  • Uses networksetup for WiFi management
  • Uses blueutil for Bluetooth management
  • Implements exponential backoff for reconnection

Notifications

  • Uses osascript (AppleScript) for AirDrop
  • Falls back to terminal-notifier if AirDrop unavailable
  • Stores notification history in ~/.backpack-mode/notifications.json

Safety Features

  • Auto-hibernate: If temp > 75°C for > 5 minutes, force hibernate
  • Battery preservation: Hibernates if battery < 10%
  • Network timeout: Don't waste battery on failed reconnections
  • Watchdog: If daemon crashes, launchd auto-restarts (max 10 crashes/hour)

Logging

All activity logged to ~/.backpack-mode/backpack.log with timestamps:

2026-02-07 12:00:00 [INFO] Backpack Mode activated (lid closed)
2026-02-07 12:00:01 [INFO] Thermal: CPU 42°C, Battery 85%, WiFi: Connected
2026-02-07 12:30:00 [INFO] Health update sent via AirDrop
2026-02-07 12:45:23 [WARN] Thermal warning: CPU 62°C, throttling further

Requirements

  • macOS 12+ (Monterey or later)
  • Intel or Apple Silicon
  • Phone with AirDrop support (iPhone recommended)
  • WiFi and Bluetooth enabled

Development

# Run in development mode (verbose logging)
go run cmd/main.go --verbose

# Run tests
go test ./...

# Build release
make build

Troubleshooting

Daemon not starting:

# Check launchd logs
log stream --predicate 'process == "backpack-mode"' --level debug

Network not connecting:

# Test manually
backpack-mode network-test

Not receiving AirDrop notifications:

  • Ensure AirDrop is enabled on both devices
  • Check phone name in config: backpack-mode config get notifications.phone_name
  • Verify Bluetooth is enabled

License

MIT

Author

Created for ultra-mobile computing workflows.


Status: 🚧 Active Development | Version: 0.1.0-alpha

About

Autonomous macOS daemon for backpack operation with offline LLM resilience. Ultra-low power management, thermal monitoring, network fallback, and intelligent notifications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published