A desktop application that sends random duck messages from Python โ Tauri โ Browser Extension, displaying them on any webpage.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Python Backend (Port 5000) โ
โ - Random message generator โ
โ - Sends messages every 5-10 seconds โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP POST
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Tauri Desktop App (Rust + React) โ
โ - HTTP Server (Port 3030) - receives from Python โ
โ - WebSocket Server (Port 3030/ws) - sends to extension โ
โ - React Dashboard - displays activity โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ WebSocket
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Browser Extension (Chrome/Edge) โ
โ - Background service worker โ
โ - Content script injection โ
โ - Displays duck messages on all web pages โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Rust (latest stable) - Install
- Node.js 18+ - Install
- Python 3.8+ - Install
- Chrome/Edge Browser
- ffmpeg - Install (for video generation)
- Muse EEG Headset - muse-lsl for streaming
- API Keys:
- Anthropic Claude API key
- Fish Audio API key
cd calhackproj
# Install dependencies
npm install
# Run in development mode
npm run tauri devThis will:
- Start the React frontend on
http://localhost:1420 - Start the Rust backend with HTTP server on
http://localhost:3030 - Start WebSocket server on
ws://localhost:3030/ws
cd python-backend
# Create virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create .env file with API keys
echo "ANTHROPIC_API_KEY=your_key_here" > .env
echo "FISH_AUDIO_API_KEY=your_key_here" >> .env
# Run the backend
python main.pyThe Python backend will:
- Start Flask server on port 5000
- Connect to Muse EEG headset for focus detection
- Take screenshots every 30 seconds
- Generate questions with Claude AI
- Create TTS audio with Fish Audio (Donald Duck voice)
- Generate lip-sync videos with animated duck
- Send video when user regains focus
- Open Chrome/Edge
- Navigate to
chrome://extensions/(oredge://extensions/) - Enable Developer mode (toggle in top-right)
- Click Load unpacked
- Select the
browser-extensionfolder - The extension icon should appear in your toolbar
Terminal 1: Start Tauri App
cd calhackproj
npm run tauri devTerminal 2: Start Python Backend
cd python-backend
python main.pyBrowser: Enable Extension
- Extension auto-connects to Tauri WebSocket
- Visit any website (e.g., google.com, youtube.com)
- Duck messages will appear as floating notifications!
- Connects to Muse EEG headset for real-time brain monitoring
- Takes screenshots every 30 seconds
- Uses Claude AI to generate questions about screen content
- Generates TTS audio with Fish Audio (Donald Duck voice)
- Creates lip-sync videos with animated duck mouth movements
- Detects focus state changes and sends videos when focus is restored
- Endpoints:
GET /health- Health checkGET /api/metrics- Current EEG metricsGET /video/<filename>- Serve generated videosGET /screenshot/status- Screenshot generator statusGET /screenshot/latest- Latest generated video path
- HTTP Server (Port 3030)
POST /api/message- Receives messages from PythonPOST /api/video- Receives video URLs from PythonGET /health- Health check
- WebSocket Server (Port 3030/ws)
- Broadcasts messages to all connected browser extensions
- Forwards video URLs to browser for display
- Tauri Commands
get_service_status- Returns status of all services
- Beautiful dashboard showing:
- Service status (HTTP, WebSocket, Extension)
- Message count
- Real-time activity log
- Setup instructions
- Background Worker (
background.js)- Connects to Tauri WebSocket
- Auto-reconnects on disconnect
- Forwards messages to content scripts
- Content Script (
content.ts)- Spawns animated walking duck GIFs on distractions
- Displays lip-sync videos bottom-right with fade in/out
- Tracks attention metrics over 2-minute timeline
- Saves scroll positions when focus drops
- Popup (
popup.html)- Shows EEG connection status
- Displays attention timeline chart
- Manual quack button for testing
- Settings for duck visibility
Edit python-backend/main.py:
TAURI_HTTP_URL = "http://localhost:3030/api/message"
MESSAGE_INTERVAL_MIN = 5 # seconds
MESSAGE_INTERVAL_MAX = 10 # secondsEdit browser-extension/background.js:
const WEBSOCKET_URL = 'ws://127.0.0.1:3030/ws';
const RECONNECT_INTERVAL = 3000; // 3 seconds
const MAX_RECONNECT_ATTEMPTS = 10;- Check Tauri app is running:
http://localhost:3030/health - Check WebSocket server in terminal logs
- Open extension popup โ Click "Reconnect"
- Check browser console (F12) for errors
- Ensure Tauri app is running first
- Check Tauri logs for HTTP server status
- Try manual send:
curl -X POST http://localhost:3030/api/message -H "Content-Type: application/json" -d '{"message":"Test","timestamp":"2024-01-01T00:00:00Z","type":"test"}'
- Check Python backend logs - should show "Sent to Tauri"
- Check Tauri logs - should show "Received from Python"
- Check extension background worker console:
- Right-click extension icon โ "Inspect service worker"
- Check webpage console (F12) - should show "Received duck message"
If port 3030 or 5000 is taken:
- Change ports in code (see Configuration section)
- Kill existing processes:
lsof -ti:3030 | xargs kill -9
Tauri App:
cd calhackproj
npm run tauri buildPython Backend (Executable):
cd python-backend
pip install pyinstaller
pyinstaller --onefile main.pyBrowser Extension:
- Zip the
browser-extensionfolder - Upload to Chrome Web Store
Edit python-backend/main.py:
DUCK_MESSAGES = [
"๐ฆ Your custom message!",
"๐ฆ Another message!",
# Add more...
]Edit browser-extension/content.js - modify the createMessageBox() function CSS.
Edit python-backend/main.py:
MESSAGE_INTERVAL_MIN = 2 # Faster
MESSAGE_INTERVAL_MAX = 5annoying-duck-extension/
โโโ calhackproj/ # Tauri Desktop App
โ โโโ src/ # React Frontend
โ โ โโโ App.tsx # Main dashboard
โ โ โโโ App.css # Styling
โ โโโ src-tauri/ # Rust Backend
โ โ โโโ src/
โ โ โ โโโ lib.rs # HTTP + WebSocket server
โ โ โโโ Cargo.toml # Rust dependencies
โ โโโ package.json
โโโ python-backend/ # Python Backend
โ โโโ main.py # Flask server + message generator
โ โโโ requirements.txt # Python dependencies
โโโ browser-extension/ # Chrome Extension
โ โโโ manifest.json # Extension config
โ โโโ background.js # Service worker
โ โโโ content.js # Page injection
โ โโโ popup.html # Popup UI
โ โโโ popup.js # Popup logic
โโโ README.md # This file
- Start Tauri: Should see "HTTP Server started" in terminal
- Start Python: Should see "Random message loop started!"
- Load Extension: Check popup shows "Connected"
- Open any website: Within 5-10 seconds, a duck message appears!
- Check Tauri Dashboard: Messages logged in real-time
- Add Python as Tauri sidecar (auto-start with app)
- Add native messaging for direct extension โ Tauri communication
- Persistent storage for message history
- Settings panel (message frequency, colors, sounds)
- Multiple duck themes/GIFs
- Desktop notifications
- System tray integration
MIT License - Feel free to modify and use!
Questions? Issues? Create a GitHub issue or check the troubleshooting section above.
Happy Ducking! ๐ฆ