Expand description
“Seconds since the last input” probing.
user_idle wraps the windowing system’s native idle counter —
XScreenSaver on X11, IOKit HIDIdleTime on macOS, the Win32 last-input
timer on Windows. On GNOME/Wayland none of those exist: Wayland
deliberately doesn’t expose a global idle counter, so
UserIdle::get_time() returns Status not OK and every idle-driven
feature (idle-reset, typing-defer, screen-time accounting) silently
treats the user as permanently active (#190).
GNOME’s compositor publishes the same counter on the session bus as
org.gnome.Mutter.IdleMonitor.GetIdletime (milliseconds since last
input). When the primary user_idle probe fails we fall back to it.
Like super::session_lock, we shell out (gdbus) rather than link a
D-Bus crate — one integer read isn’t worth 30+ transitive dependencies
— and reuse the shared 2 s probe timeout so a wedged session bus can’t
stall the scheduler tick.
Modules§
- mutter 🔒
Functions§
- combine_
idle 🔒 - Resolve the primary reading against the platform fallback: the primary
value wins; on primary failure the injected
fallbackis consulted and, if it too has nothing, the primary error is surfaced. The fallback is a closure so this decision is pure and unit-testable on every OS without touching a windowing system — only the two FFI sources it’s wired to inidle_secsstay platform-bound. - fallback_
idle_ 🔒secs - The platform fallback when
user_idlecan’t read the counter. Only GNOME/Wayland has one (Mutter); everywhere else there’s nothing more to try, so the primary error stands. - idle_
secs - Seconds since the last keyboard/mouse input, or a display-error string if no idle source is available this call.
- parse_
mutter_ 🔒idletime_ ms - Parse the
gdbus call … GetIdletimereply —(uint64 12345,)— into idle milliseconds. Pure so the Wayland fallback’s parsing is testable without a live session bus; thegdbusspawn stays inmutter.