1pub type Error = anyhow::Error;
12pub type Result<T> = anyhow::Result<T>;
13
14#[cfg(all(target_os = "linux", feature = "x11"))]
15#[path = "x11_impl.rs"]
16mod idle;
17
18#[cfg(all(target_os = "linux", not(feature = "x11")))]
19#[path = "dbus_impl.rs"]
20mod idle;
21
22#[cfg(target_os = "windows")]
23#[path = "windows_impl.rs"]
24mod idle;
25
26pub use idle::get_idle_time;
31
32#[expect(clippy::unwrap_used, reason = "unit tests")]
33#[cfg(test)]
34mod test {
35 use std::{thread::sleep, time::Duration};
36
37 use super::get_idle_time;
38
39 const DURATION: Duration = Duration::from_secs(10);
40
41 #[test]
42 fn main() {
44 let idle_before = get_idle_time().unwrap();
45 sleep(DURATION);
46 let idle_after = get_idle_time().unwrap();
47 assert!(idle_after >= idle_before + DURATION,);
48 }
49}