chiark / gitweb /
Merge keymap building in the top-level Makefile.am.
[elogind.git] / extras / keymap / findkeyboards
1 #!/bin/sh -e
2 # Find "real" keyboard devices and print their device path.
3 # Author: Martin Pitt <martin.pitt@ubuntu.com>
4 #
5 # Copyright (C) 2009, Canonical Ltd.
6 #
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.
11 #
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.
16
17
18 # print a list of input devices which are keyboard-like
19 keyboard_devices() {
20     input_devs=`udevadm trigger --dry-run --verbose --subsystem-match=input --attr-match=dev`
21
22     # standard AT keyboard
23     for dev in $input_devs; do
24         walk=`udevadm info --attribute-walk --path=$dev`
25         env=`udevadm info --query=env --path=$dev`
26         
27         if echo "$walk" | grep -q 'DRIVERS=="atkbd"'; then
28             echo -n 'AT keyboard: '
29             udevadm info --query=name --path=$dev
30         fi
31         if echo "$env"| grep -q '^ID_CLASS=kbd' && echo "$env" | grep -q '^ID_USB_DRIVER=usbhid'; then
32             echo -n 'USB keyboard: '
33             udevadm info --query=name --path=$dev
34         fi
35     done
36
37     # modules
38     module=`udevadm trigger --verbose --dry-run --subsystem-match=input --attr-match=name='*Extra Buttons'`
39     module="$module
40 `udevadm trigger --verbose --dry-run --subsystem-match=input --attr-match=name='Sony Vaio Keys'`"
41     for m in $module; do
42         evdev=`ls -d $m/event* 2>/dev/null`
43         if [ -e "$evdev/dev" ]; then
44             echo -n 'module: '
45             udevadm info --query=name --path=$evdev
46         fi
47     done
48 }
49
50 keyboard_devices