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

FlagDefaultDescription
--radius150Spotlight circle radius in pixels
--dim0.6Dimming opacity (0.0 = transparent, 1.0 = black)
--fps60Refresh rate for the overlay

AwesomeWM Integration

The rc.lua config registers these hotkeys:

KeyAction
F7Toggle spotlight on/off
F9 / F10Adjust dimming (less / more)
Shift+F9 / Shift+F10Adjust 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 XFixesSelectCursorInput to 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.