From a5d7c37618f25abf38c2fd1499a46cad547fab6f Mon Sep 17 00:00:00 2001 From: Yiyao Yu Date: Mon, 22 May 2023 02:50:43 -0700 Subject: [PATCH] Added 10ms sleep between querying keymap to prevent accidentally making the CPU a seat warmer --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.rs b/src/main.rs index 69991b5..4613f6a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,8 @@ extern crate x11; use std::env; use std::process; use std::ptr; +use std::thread; +use std::time; const KEYID_LSUPER: u32 = 130; @@ -29,6 +31,7 @@ fn x11_close_display(display: *mut x11::xlib::Display) { } fn x11_check_lsuper() -> Option { + let sleep_time = time::Duration::from_millis(10); match x11_open_display() { Some(display) => { loop { @@ -50,6 +53,7 @@ fn x11_check_lsuper() -> Option { x11_close_display(display); return Some(false); } + thread::sleep(sleep_time); } }, None => {