Cursor Spotlight
A lightweight X11 overlay that dims the entire screen except a configurable circle around your mouse cursor. Perfect for presentations, screen recordings, and pair programming.
Tech stack: Pure C · libX11 · XFixes · XRender · Cairo · ~350 lines
Build & Run
# Install dependencies
sudo apt install pkg-config libx11-dev libxext-dev libxfixes-dev libxrender-dev libcairo2-dev
# Build
./build_cursor_spotlight.sh
# Run with defaults
./build/bin/cursor_spotlight
# Run with custom settings
./build/bin/cursor_spotlight --radius 180 --dim 0.68 --fps 50
# Optional install
./build_cursor_spotlight.sh --install
~/Programs/bin/cursor_spotlight --radius 180 --dim 0.68 --fps 50
Command-Line Flags
| Flag | Default | Description |
|---|---|---|
--radius | 150 | Spotlight circle radius in pixels |
--dim | 0.6 | Dimming opacity (0.0 = transparent, 1.0 = black) |
--fps | 60 | Refresh rate for the overlay |
AwesomeWM Integration
The rc.lua config registers these hotkeys:
| Key | Action |
|---|---|
| F7 | Toggle spotlight on/off |
| F9 / F10 | Adjust dimming (less / more) |
| Shift+F9 / Shift+F10 | Adjust radius (smaller / larger) |
The Utilities widget in the wibar also has Cursor Spotlight (toggle) and Build Spotlight (recompile) buttons.
How It Works
Architecture
┌─────────────────────────────────────────────────────┐
│ X11 Root Window │
│ │
│ ┌──────────────────────────────────────────────┐ │
│ │ Override-Redirect Window (full-screen) │ │
│ │ ┌────────────────────────────────────────┐ │ │
│ │ │ Cairo Surface │ │ │
│ │ │ • Fill entire surface with dim color │ │ │
│ │ │ • Punch spotlight circle at cursor │ │ │
│ │ │ • XFixes tracks cursor position │ │ │
│ │ └────────────────────────────────────────┘ │ │
│ │ input-passthrough: clicks go to windows below│ │
│ └──────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────┘
Key Implementation Details
- Override-redirect window — bypasses the window manager so there's no title bar or focus stealing.
- XFixes cursor tracking — uses
XFixesSelectCursorInputto get cursor position events without polling. - Input passthrough — the overlay window has its input region set to empty, so all clicks and keypresses pass through to the window below.
- Cairo compositing — draws a full-screen semi-transparent rectangle, then punches a clear circle using
CAIRO_OPERATOR_CLEAR. - vsync via usleep — simple frame-rate limiting to avoid burning CPU.