Skip to content

Commit

Permalink
Merge pull request #39 from acidnik/watch_for_devices
Browse files Browse the repository at this point in the history
Watch for devices in /dev/input/
  • Loading branch information
ItayGarin authored Mar 11, 2023
2 parents ea4f8eb + da227fa commit 5af7288
Show file tree
Hide file tree
Showing 7 changed files with 410 additions and 62 deletions.
183 changes: 172 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ nix = "0.17.0"
zmq = {version = "0.9.2", optional = true}
rodio = {version = "0.11.0", optional = true}
enum-iterator = {version = "0.6.0", optional = true}
regex = "1.7.1"
inotify = "0.10.0"
retry = "2.0.0"

[features]
sound = ["rodio", "enum-iterator"]
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,14 @@ sudo chmod -R 0770 /opt/ktrl

#### Locating your Keyboard's input device

For ktrl to work, you have to supply it with a path to your keyboard's input device.
#### The easy and obvious way
If you want ktrl to process events from all input devices, just run it without arguments.
If you also want ktrl to watch for new devices in `/dev/input`, you can pass `--watch` as an argument.
This could be useful if you use bluetooth devices that connect and reconnect all the time.

#### Specifying devices manually

If you want to process events only from selected devices, you have to supply it with a path to your keyboard's input device.
Input devices reside in the `/dev/input` directory.

Linux provides two convenient symlinks-filled directories to make the search process easier.
Expand All @@ -167,6 +174,8 @@ These directories are `/dev/input/by-id` and `/dev/input/by-path`.
Within these two directories keyboard devices usually have a `-kbd` suffix.
For example, in my laptop, the path is `/dev/input/by-path/platform-i8042-serio-0-event-kbd`.

If you provide both `--watch` and `--device` arguments, then ktrl will watch for file events only on those devices.

##### Bluetooth keyboard location

If you are using a bluetooth keyboard, you will need to locate the associated `/dev/input/event<#>` as `/dev/input/by-*` only lists usb connected inputs. The best way to do this is to run `cat /proc/bus/input/devices` and search for the associated bluetooth keyboard (the `Phys` output will have the MAC address). Here is an example:
Expand Down
Loading

0 comments on commit 5af7288

Please sign in to comment.