Expand description
“Pause during fullscreen video” detection.
Each platform’s check() combines two signals:
- Display-wake assertion —
pmset/powercfg/systemd-inhibittell us whether anything on the system is asking the display to stay awake. Most video players (browser HTML5, VLC, video calls) set this, but so do tiny background-tab videos. On its own it’s a false-positive magnet. - Fullscreen window present — at least one on-screen, normal application window has bounds matching one of the connected monitors. This narrows (1) to the “I’m actually committed to watching this” case, which is what the user-facing setting “Pause during fullscreen video” actually promises.
Combined: active = assertion && fullscreen_window_present. The
assertion check is the fast path — we skip the window enumeration
when nothing is keeping the display awake.
Wayland is a known degraded case: there is no portable way to
enumerate windows from outside the compositor, so we treat the
fullscreen check as always-true and fall back to assertion-only
behaviour. A one-time log::info! at startup records the
degradation.
Modules§
- linux 🔒
Structs§
- Rect 🔒
- Plain rectangle used by the bounds-comparison helpers below. Decoupled from any platform type so the matching logic is pure and testable.
Enums§
- Window
Knowledge 🔒 - Whether the platform can answer “is a fullscreen window present?”.
Linux Wayland uses
Unknowable; everywhere else passes a concreteFullscreen(bool). Exists so the combining logic inpause_decisionis one pure function with one truth-table test, instead of three near-identical chains duplicated per platform.
Constants§
- FULLSCREEN_
TOLERANCE_ 🔒PX - Pixel tolerance when comparing window bounds to monitor bounds. Native fullscreen on macOS/Windows is exact, but X11 reparenting window managers (i3, openbox) sometimes leave a 1–2px border. Keep this small — a 5px tolerance would catch maximised-but-not-fullscreen windows on some setups.
- POLL_
INTERVAL 🔒
Functions§
- any_
window_ 🔒is_ fullscreen - True if any window in
windowsmatches any monitor inmonitors. This is the platform-independent core of the fullscreen check. - parse_
active_ 🔒window_ id - Linux
xprop -root _NET_ACTIVE_WINDOW: extract the0x…window id, rejecting the0x0“no active window” sentinel so we don’t chain a useless follow-up xprop call. - parse_
display_ 🔒request - Windows
powercfg /requests: true if theDISPLAY:section lists any request other thanNone.(something is requesting the display stay on). - parse_
display_ 🔒sleep_ blocked - macOS
pmset -g assertions: true ifPreventUserIdleDisplaySleephas a non-zero count (something is keeping the display awake). - parse_
idle_ 🔒inhibitor - Linux
systemd-inhibit --list: true if any inhibitor’s WHAT column (colon-separated types) includesidle. System-managed inhibitors likehandle-lid-switch/sleepdon’t carry theidlecomponent. - parse_
net_ 🔒wm_ state_ fullscreen - Linux
xprop -id <id> _NET_WM_STATE: true iff_NET_WM_STATE_FULLSCREENis present. Crucially_NET_WM_STATE_MAXIMIZED_*must NOT match — a maximised window with the taskbar visible is the case we exclude. - pause_
decision 🔒 - Should breaks pause right now, given the two signals?
- rect_
matches 🔒 - True if
windowcoversmonitorwithinFULLSCREEN_TOLERANCE_PXon every edge. - spawn_
monitor