Skip to content

xpcrack/Nap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nap 💤

Nap is a macOS menu bar app that automatically manages your AI PC's power state. It keeps your GPU workstation sleeping when idle and wakes it on-demand when AI requests come in.

Features

  • 🤖 Auto Wake-on-Demand: When an AI request hits the gateway, Nap wakes your PC automatically
  • 💤 Smart Sleep: Sleeps PC after 1 minute of idle (GPU < 10%)
  • 📊 GPU Monitoring: Real-time GPU load in menu bar
  • 🔌 SSH Protection: Won't sleep if you have active SSH sessions
  • 👨 Manual Override: Keep PC awake when needed

Requirements

  • macOS (with Python 3)
  • A Windows/Linux PC with:
    • NVIDIA GPU (for monitoring)
    • Wake-on-LAN enabled in BIOS
    • SSH server running
    • Passwordless SSH key authentication set up

Installation

  1. Clone this repo:

    git clone https://github.com/YOUR_USERNAME/nap.git
    cd nap
  2. Copy and edit the config:

    cp config.example.yaml config.yaml
    # Edit config.yaml with your PC details
  3. Run the installer:

    ./install.sh

Configuration

Edit config.yaml:

pc:
  ip: "192.168.1.100"        # Your PC's IP
  mac: "AA-BB-CC-DD-EE-FF"   # Your PC's MAC address
  user: "yourname"           # SSH username
  gpu_threshold: 10          # Sleep if GPU < this %
  wait_time_minutes: 5       # Idle threshold
  ai_ports: [11434]          # Ollama port

proxy:
  listen_port: 11435         # Local gateway port
  wake_timeout: 30           # Max wake wait (seconds)

Usage

Menu Bar

  • 🤖 = PC Online
  • 💤 = PC Sleeping
  • 👨 = Manual Override (won't auto-sleep)

CLI Commands

nap start      # Start daemon
nap stop       # Stop daemon
nap restart    # Restart daemon
nap status     # Show PC status
nap wake       # Wake PC manually
nap sleep      # Sleep PC manually
nap logs       # View logs

AI Gateway

Point your AI tools to http://localhost:11435 instead of your PC's IP.

Example with Ollama:

export OLLAMA_HOST=http://localhost:11435
ollama run llama2

How It Works

  1. Gateway: Nap runs a local proxy on port 11435
  2. Request arrives: If PC is sleeping, Nap sends a Wake-on-LAN packet
  3. Wait for boot: Waits for the AI service port to become available
  4. Forward request: Streams the response back to the client
  5. Auto sleep: After 1 minute of idle, PC goes back to sleep

License

MIT

About

把高性能PC封装成API,请求唤醒,闲置超1min自动睡眠;

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors