]> git.ipfire.org Git - thirdparty/systemd.git/blame - extras/inputdev.sh
[PATCH] cleanup udevd/udevstart
[thirdparty/systemd.git] / extras / inputdev.sh
CommitLineData
29afcc5f
GKH
1#!/bin/sh -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
8[ "$1" ] || exit 0
9
10# input device name, less leading "input/"
11DEVICE=${1#input/}
12
13# "|"-separated list.
14# The first found in the given device's "N:" line will be output.
15DEFAULT_KEYWORDS='dvb|saa7134'
16KEYWORDS=${2:-$DEFAULT_KEYWORDS}
17
18exec sed -nre '
19 /^I:/ {
20 : gather
21 N
22 /\nH:/! b gather
23 /'"$DEVICE"'/ {
24 s/^.*\nN:[^\n]*("|\b)('"$KEYWORDS"')("|\b)[^\n]*\n.*$/inputdev/
25 T
26 p
27 }
28 }
29' < /proc/bus/input/devices
30