Created
November 6, 2023 09:30
-
-
Save adamency/4830e35da4e54c3d71e388dc03c5a22c to your computer and use it in GitHub Desktop.
CheckKeys: Pretty-Print Key Presses & Releases
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
#!/bin/bash | |
### DEPENDENCIES | |
# `rg`: https://github.com/BurntSushi/ripgrep/ | |
# `awk` | |
# `xev` | |
# `--line-buffered` because ripgrep uses a block buffer in piped | |
# and so doesn't provide instant output by default when redirected | |
# after to stdout (related: https://unix.stackexchange.com/questions/200235/how-to-use-sed-to-manipulate-continuously-streaming-output) | |
echo | |
xev |\ | |
rg --line-buffered -o '(KeyPress|KeyRelease|\(keysym.*\))' |\ | |
rg --line-buffered --passthru -e '\(keysym.*, ' -e '\)' -r '' |\ | |
awk 'ORS=NR%2-1?"\n":": "' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment