user-idle3-0.7.0 has been yanked.
user-idle2
This is a fork of user-idle-rs, which had been idle for a while and did not support Wayland.
| OS | Supported |
|---|---|
| Linux | ✔️* |
| Windows | ✔️ |
| MacOS | ✔️ |
* The Linux implementation will do the following:
- Try to get the idle time from Mutter via DBus. This should work on GNOME desktops with Wayland or X11.
- Try to get the idle time from X11. This will not work on Wayland.
- Try to get the screensaver's idle time via DBus. Note that the screensaver may report a value of 0ns when it's not active.
- With the
evdevfeature enabled: Fall back to using evdev for input event tracking. This works on Wayland compositors like Hyprland, Sway, and others.
Features
evdev (optional)
Enable the evdev feature to support Wayland compositors that don't expose idle time via DBus (like Hyprland):
[]
= { = "0.6", = ["evdev"] }
The evdev implementation works by running background threads that monitor all input devices for keyboard and mouse events, tracking the last input time. This approach works on any Linux desktop environment, including:
- Hyprland
- Sway
- wlroots-based compositors
- Any X11 or Wayland environment
Note: On Linux, the user must be in the input group to read input events:
# Log out and back in for the change to take effect
Example
use UserIdle;
let idle = get_time.unwrap;
let idle_seconds = idle.as_seconds;
let idle_minutes = idle.as_minutes;
Check the documentation for more methods.