Added 10ms sleep between querying keymap to prevent accidentally making

the CPU a seat warmer
This commit is contained in:
Jack Yu 2023-05-22 02:50:43 -07:00
parent e8966ab00b
commit a5d7c37618
1 changed files with 4 additions and 0 deletions

View File

@ -4,6 +4,8 @@ extern crate x11;
use std::env; use std::env;
use std::process; use std::process;
use std::ptr; use std::ptr;
use std::thread;
use std::time;
const KEYID_LSUPER: u32 = 130; const KEYID_LSUPER: u32 = 130;
@ -29,6 +31,7 @@ fn x11_close_display(display: *mut x11::xlib::Display) {
} }
fn x11_check_lsuper() -> Option<bool> { fn x11_check_lsuper() -> Option<bool> {
let sleep_time = time::Duration::from_millis(10);
match x11_open_display() { match x11_open_display() {
Some(display) => { Some(display) => {
loop { loop {
@ -50,6 +53,7 @@ fn x11_check_lsuper() -> Option<bool> {
x11_close_display(display); x11_close_display(display);
return Some(false); return Some(false);
} }
thread::sleep(sleep_time);
} }
}, },
None => { None => {