-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check all event devices for KEY_ENTER presence.
- Loading branch information
1 parent
ffd8b99
commit 8bbd34c
Showing
7 changed files
with
196 additions
and
44 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
__pycache__ | ||
target | ||
src/Makefile |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "swhkd" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
evdev = "0.11.3" | ||
glob = "0.3.0" | ||
|
||
[[bin]] | ||
name = "swhkd" | ||
path = "src/main.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
all: build | ||
|
||
build: | ||
@cargo build --release --target=x86_64-unknown-linux-musl | ||
|
||
install: | ||
@mkdir -p /usr/local/bin | ||
@cp ./target/x86_64-unknown-linux-musl/release/swhkd /usr/local/bin/swhkd | ||
@chmod +x /usr/local/bin/swhkd | ||
|
||
uninstall: | ||
@rm /usr/local/bin/swhkd | ||
|
||
run: | ||
@cargo run --target=x86_64-unknown-linux-musl | ||
|
||
check: | ||
@cargo fmt | ||
@cargo check --target=x86_64-unknown-linux-musl | ||
|
||
clean: | ||
@cargo clean | ||
|
||
setup: | ||
@rustup install stable | ||
@rustup default stable | ||
@rustup target add x86_64-unknown-linux-musl | ||
|
||
.PHONY: check clean setup all run install build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
# swhkd | ||
**S**imple **W**ayland **H**ot**K**ey **D**aemon | ||
|
||
|
||
This project is still very new and I'm making new decisions everyday as to where I should drive this project. | ||
|
||
I'm using libevdev which technically makes swhkd display protocol indepdent, but we'll need to put that to the test before claiming anything. | ||
|
||
Currently I have only been able to achieve the grabbing of input evdev, I don't know how I will process chains of keybinds, but we'll get to that soon. | ||
|
||
|
||
# Python: | ||
Adressing the elephant in the room, python. Python is good enough for the prototype stage of the project, once I have a clear idea and a working prototype, | ||
I will port the project to go or zig if I get time. | ||
|
||
# Contributors: | ||
<img src="https://contrib.rocks/image?repo=shinyzenith/swhkd" /> | ||
# Compiling: | ||
1) Clone this repos | ||
2) Install rustup | ||
3) `make setup` | ||
4) `make` | ||
5) `sudo make install` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use evdev::Device; | ||
use evdev::Key; | ||
use glob::glob; | ||
|
||
pub fn main() { | ||
for entry in glob("/dev/input/event*").expect("Failed to read /dev/input/event*.") { | ||
match entry { | ||
Ok(path) => { | ||
check_keyboard(path.into_os_string().into_string().unwrap()); | ||
} | ||
Err(_) => continue, | ||
} | ||
} | ||
} | ||
|
||
pub fn check_keyboard(input_path: String) -> bool { | ||
let device = Device::open(&input_path).expect("Failed to open device."); | ||
if device | ||
.supported_keys() | ||
.map_or(false, |keys| keys.contains(Key::KEY_ENTER)) | ||
{ | ||
println!("{} is a keyboard.", input_path); | ||
return true; | ||
} else { | ||
println!("{} is not a keyboard.", input_path); | ||
return false; | ||
} | ||
} |