1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-31 07:51:08 +03:00
systemd-stable/extras/inputdev.sh

31 lines
605 B
Bash

#!/bin/sh -e
#
# Scans /proc/bus/input/devices for the given device.
#
# (c) 2004 Darren Salt <linux@youmustbejoking.demon.co.uk>
# GPL v2 or later applies.
[ "$1" ] || exit 0
# input device name, less leading "input/"
DEVICE=${1#input/}
# "|"-separated list.
# The first found in the given device's "N:" line will be output.
DEFAULT_KEYWORDS='dvb|saa7134'
KEYWORDS=${2:-$DEFAULT_KEYWORDS}
exec sed -nre '
/^I:/ {
: gather
N
/\nH:/! b gather
/'"$DEVICE"'/ {
s/^.*\nN:[^\n]*("|\b)('"$KEYWORDS"')("|\b)[^\n]*\n.*$/inputdev/
T
p
}
}
' < /proc/bus/input/devices