Pi66

pind
Simple Rust hotkey daemon.
git clone https://git.pi66.xyz/pind

← back to log

fix: keyboard checker fn removes a real keyboards

author: pi66
date: 2025-08-16 23:26
hash: ff24aa2d4288112b9f6196d3a59d69065da7deac

Diffstat:

M

Cargo.lock
2 ++--

M

src/main.rs
14 ++++++------------------------
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
diff --git a/Cargo.lock b/Cargo.lock
index cf0c8d3..00c69cf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -68,7 +68,7 @@ dependencies = [

 [[package]]
 name = "pind"
-version = "0.1.2"
+version = "0.1.3"
 dependencies = [
  "evdev",
 ]
diff --git a/src/main.rs b/src/main.rs
index 7ecdf48..2c210cb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -129,10 +129,8 @@ fn is_keyboard(path: &PathBuf) -> bool
 {
     let dev = Device::open(path).unwrap();
     if let Some(keys) = dev.supported_keys() {
-        if dev.name().unwrap().to_lowercase().contains("keyboard"){
-            if keys.contains(KeyCode::KEY_A) && keys.contains(KeyCode::KEY_ENTER) {
-                return true;
-            }
+        if keys.contains(KeyCode::KEY_A) && keys.contains(KeyCode::KEY_ENTER) {
+            return true;
         }
     }
     false
@@ -141,16 +139,10 @@ fn is_keyboard(path: &PathBuf) -> bool
 fn keyboards() -> Vec<PathBuf> 
 {
     let mut devices: Vec<PathBuf> = vec![];
-    let mut sn = Vec::new();

     for (path, _) in enumerate() {
         if is_keyboard(&path) {
-            let dev = Device::open(&path).unwrap();
-            let name = dev.name().unwrap_or("unknown").to_string();
-            if !sn.contains(&name) {
-                devices.push(path.clone());
-                sn.push(name);
-            }
+            devices.push(path);
         }
     }
     devices