mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
607 B

  1. #!/bin/bash -e
  2. #
  3. # Scans /proc/bus/input/devices for the given device.
  4. #
  5. # (c) 2004 Darren Salt <linux@youmustbejoking.demon.co.uk>
  6. # GPL v2 or later applies.
  7. [ "$1" ] || exit 0
  8. # input device name, less leading "input/"
  9. DEVICE=${1#input/}
  10. # "|"-separated list.
  11. # The first found in the given device's "N:" line will be output.
  12. DEFAULT_KEYWORDS='dvb|saa7134'
  13. KEYWORDS=${2:-$DEFAULT_KEYWORDS}
  14. exec sed -nre '
  15. /^I:/ {
  16. : gather
  17. N
  18. /\nH:/! b gather
  19. /'"$DEVICE"'/ {
  20. s/^.*\nN:[^\n]*("|\b)('"$KEYWORDS"')("|\b)[^\n]*\n.*$/inputdev/
  21. T
  22. p
  23. }
  24. }
  25. ' < /proc/bus/input/devices