Files

37 lines
970 B
Bash
Raw Permalink Normal View History

#!/bin/sh
# Identify the touchscreen and print the stable by-id path for config.env.
set -eu
echo "=== input devices reporting a touch-ish name ==="
found=
for ev in /dev/input/event*; do
name=$(cat "/sys/class/input/$(basename "$ev")/device/name" 2>/dev/null || true)
case "$name" in
*[Tt]ouch* | *TOUCH*)
found=yes
echo
echo " device: $ev"
echo " name: $name"
for l in /dev/input/by-id/* /dev/input/by-path/*; do
[ -e "$l" ] || continue
if [ "$(readlink -f "$l")" = "$(readlink -f "$ev")" ]; then
echo " stable: $l"
fi
done
;;
esac
done
if [ -z "$found" ]; then
echo " (none matched by name)"
echo
echo "Fall back to listing everything:"
for ev in /dev/input/event*; do
printf ' %-22s %s\n' "$ev" "$(cat "/sys/class/input/$(basename "$ev")/device/name" 2>/dev/null)"
done
fi
echo
echo "Put the 'stable:' path (prefer /dev/input/by-id/) into TOUCH_DEV."
echo "Event numbers change across reboots; by-id symlinks do not."