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.
17 # returns OK if $1 contains $2
19 [ "${1#*$2*}" != "$1" ]
22 # returns OK if $1 contains $2 at the beginning
24 [ "${1#$2*}" != "$1" ]
28 while read a; do str_starts "$a" "$1" && return 0;done
32 # print a list of input devices which are keyboard-like
34 # standard AT keyboard
35 for dev in `udevadm trigger --dry-run --verbose --property-match=ID_INPUT_KEYBOARD=1`; do
36 walk=`udevadm info --attribute-walk --path=$dev`
37 env=`udevadm info --query=env --path=$dev`
38 # filter out non-event devices, such as the parent input devices which have no devnode
39 if ! echo "$env" | str_line_starts 'DEVNAME='; then
42 if strstr "$walk" 'DRIVERS=="atkbd"'; then
43 echo -n 'AT keyboard: '
44 elif echo "$env" | str_line_starts 'ID_USB_DRIVER=usbhid'; then
45 echo -n 'USB keyboard: '
47 echo -n 'Unknown type: '
49 udevadm info --query=name --path=$dev
53 module=$(udevadm trigger --verbose --dry-run --subsystem-match=input --attr-match=name='*Extra Buttons')
55 $(udevadm trigger --verbose --dry-run --subsystem-match=input --attr-match=name='*extra buttons')"
57 $(udevadm trigger --verbose --dry-run --subsystem-match=input --attr-match=name='Sony Vaio Keys')"
59 for evdev in $m/event*/dev; do
60 if [ -e "$evdev" ]; then
62 udevadm info --query=name --path=${evdev%%/dev}