user-idle3
This is a fork of user-idle2, which is itself a fork of user-idle-rs. The key differences introduced in this fork are native Wayland idle detection via the ext-idle-notify-v1 protocol (wayland feature) and evdev-based input tracking as a broad Wayland fallback (evdev feature).
| OS | Supported |
|---|---|
| Linux | ✔️* |
| Windows | ✔️ |
| MacOS | ✔️ |
* The Linux implementation tries the following providers in order:
- Mutter (DBus) — works on GNOME with Wayland or X11.
- X11 — works on any X11 desktop.
ext-idle-notify-v1(Wayland) — standard Wayland idle protocol; requires thewaylandfeature. Works on Sway, KWin ≥5.27, Hyprland, Mutter 45+, and any compositor that implementsext-idle-notify-v1.- Screensaver (DBus) — supported by many desktop environments; may report 0 when the screensaver is inactive.
- evdev — low-level input event tracking; requires the
evdevfeature. Works on any Linux desktop (X11 or Wayland) but requires the user to be in theinputgroup.
Usage
[]
= "0.7"
use UserIdle;
let idle = get_time.unwrap;
println!;
println!;
println!;
Features
wayland (optional)
Enable native Wayland idle detection using the ext-idle-notify-v1 protocol:
[]
= { = "0.7", = ["wayland"] }
The wayland implementation connects to the Wayland compositor, binds ext_idle_notifier_v1 and wl_seat, and requests idle notifications with a 3-second timeout. A background thread dispatches compositor events. When the compositor signals Idled, the elapsed time is computed as time_since_idle_event + 3s. When the compositor signals Resumed, the idle time resets to zero.
Supported compositors:
- Sway
- KWin (KDE Plasma) ≥ 5.27
- Hyprland
- Mutter (GNOME) ≥ 45
- Any compositor implementing
ext-idle-notify-v1
evdev (optional)
Enable evdev-based idle tracking as a broad fallback:
[]
= { = "0.7", = ["evdev"] }
The evdev implementation runs background threads monitoring all input devices for keyboard and mouse events. Works on any Linux desktop (X11 or Wayland).
Note: The user must be in the input group:
# Log out and back in for the change to take effect
Both features can be enabled together:
[]
= { = "0.7", = ["wayland", "evdev"] }