2 # Find "real" keyboard devices and print their device path.
3 # Author: Martin Pitt <martin.pitt@ubuntu.com>
5 # Copyright (C) 2009, Canonical Ltd.
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
19 # returns OK if $1 contains $2
21 [ "${1#*$2*}" != "$1" ]
24 # returns OK if $1 contains $2 at the beginning
26 [ "${1#$2*}" != "$1" ]
30 while read a; do str_starts "$a" "$1" && return 0;done
34 # print a list of input devices which are keyboard-like
36 # standard AT keyboard
37 for dev in `udevadm trigger --dry-run --verbose --property-match=ID_INPUT_KEYBOARD=1`; do
38 walk=`udevadm info --attribute-walk --path=$dev`
39 env=`udevadm info --query=env --path=$dev`
40 # filter out non-event devices, such as the parent input devices which
42 if ! echo "$env" | str_line_starts 'DEVNAME='; then
45 if strstr "$walk" 'DRIVERS=="atkbd"'; then
46 echo -n 'AT keyboard: '
47 elif echo "$env" | str_line_starts 'ID_USB_DRIVER=usbhid'; then
48 echo -n 'USB keyboard: '
50 echo -n 'Unknown type: '
52 udevadm info --query=name --path=$dev
56 module=$(udevadm trigger --verbose --dry-run --subsystem-match=input --attr-match=name='*Extra Buttons')
58 $(udevadm trigger --verbose --dry-run --subsystem-match=input --attr-match=name='*extra buttons')"
60 $(udevadm trigger --verbose --dry-run --subsystem-match=input --attr-match=name='Sony Vaio Keys')"
62 for evdev in $m/event*/dev; do
63 if [ -e "$evdev" ]; then
65 udevadm info --query=name --path=${evdev%%/dev}