2014-03-25 09:22:21 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-10-07 16:33:45 +02:00
|
|
|
compat=""
|
2016-06-23 23:18:36 +02:00
|
|
|
if awk --version | grep -q GNU; then
|
2015-10-07 16:33:45 +02:00
|
|
|
# This is for hex-to-decimal conversion.
|
|
|
|
compat="--non-decimal"
|
|
|
|
fi
|
|
|
|
xev "$@" | awk $compat '/KeyPress|KeyRelease/ {
|
2014-11-12 16:15:39 +01:00
|
|
|
if ($1 == "KeyPress")
|
|
|
|
event="pressed";
|
|
|
|
else
|
|
|
|
event="released";
|
2014-03-25 09:22:21 +01:00
|
|
|
|
2014-11-12 16:15:39 +01:00
|
|
|
getline; getline;
|
|
|
|
state = substr($2,1,length($2)-2);
|
|
|
|
keycode = $4;
|
|
|
|
keysym = substr($7, 1, length($7)-2);
|
2014-03-25 09:22:21 +01:00
|
|
|
|
2015-10-07 16:33:45 +02:00
|
|
|
printf "%-16s code=%-3s state=%s event=%-8s", keysym, keycode, state, event
|
2014-03-25 09:22:21 +01:00
|
|
|
|
2015-10-07 16:33:45 +02:00
|
|
|
getline;
|
|
|
|
gsub(/\(|\)/, "", $5)
|
|
|
|
code=int(sprintf("%d", "0x" $5))
|
|
|
|
if (code > 32 && code != 127) {
|
|
|
|
/* Ignore non-printable characters" */
|
|
|
|
gsub(/"/, "", $NF)
|
|
|
|
printf " string=%s", $NF
|
|
|
|
}
|
|
|
|
print ""
|
2014-03-25 09:22:21 +01:00
|
|
|
}'
|