2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-19 03:25:44 +00:00
cheat.sheets/sheets/xev
terminalforlife bcb2d06328 Add to xev
Thanks to whomever corrected my previous use of `$(xev)`. I've added a
a note about process substitution.
2020-03-15 17:59:30 +00:00

27 lines
592 B
Plaintext

# xev
# Print contents of X events
# Start xev(1) and show only the relevant parts.
xev | awk -F'[ )]+' '
/^KeyPress/ {
a[NR+2]
}
NR in a {
printf "%-3s %s\n", $5, $8
}
'
# Alternative approach to showing keycodes.
#
# Note that the use of `<(xev)` is process substitution, which is unavailable
# in the Bourne Shell and its standard derivatives, nor is it available in Bash
# with its own POSIX mode enabled.
awk '
/^KeyPress/ {
A[NR+2]
}
NR in A {
B=substr($7, 0, length($7) - 2)
printf("%3d %s\n", $4, B)
}
' <(xev)