A focus-enforcement utility that uses webcam gaze detection to play a meme video when you look away from your screen. Stay focused or face the consequences.
- Real-time eye gaze tracking via webcam
- Configurable delay threshold before alarm triggers
- Automatic video playback with audio when you look away
- Immediate stop when you look back at the screen
- Live visual feedback with face and eye tracking overlays
- Python 3.7+
- macOS (uses QuickTime Player for video playback)
- Webcam
pip install -r requirements.txt# Basic usage
python main.py --video path/to/meme.mp4
# Custom threshold (wait 2 seconds before alarm)
python main.py --video meme.mp4 --threshold 2.0
# Stricter gaze detection
python main.py --video meme.mp4 --gaze-tolerance 0.10
# Set volume
python main.py --video meme.mp4 --volume 80- Press q to quit
| Argument | Default | Description |
|---|---|---|
--video |
required | Path to video file to play as alarm |
--threshold |
0.5 | Seconds of looking away before alarm triggers |
--gaze-tolerance |
0.15 | Gaze tolerance from center (0.0-1.0, smaller = stricter) |
--volume |
100 | Video volume level (0-100) |
- Captures frames from webcam using OpenCV
- Detects facial landmarks using MediaPipe Face Mesh
- Calculates iris position to determine if you're looking at the screen
- Starts a timer when you look away
- Plays the alarm video when the timer exceeds the threshold
- Stops the video immediately when you look back
├── main.py # Entry point and main loop
├── gaze_detector.py # Eye tracking using MediaPipe
├── alarm_controller.py # Video playback control
├── config.py # Configuration constants
├── requirements.txt # Python dependencies
└── face_landmarker.task # MediaPipe pre-trained model