1 <?xml version='
1.0'
?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
8 Copyright © 2014 Tom Gundersen
11 <refentry id=
"hwdb" conditional=
"ENABLE_HWDB">
14 <productname>systemd
</productname>
17 <contrib>Developer
</contrib>
18 <firstname>Kay
</firstname>
19 <surname>Sievers
</surname>
20 <email>kay@vrfy.org
</email>
23 <contrib>Developer
</contrib>
24 <firstname>Tom
</firstname>
25 <surname>Gundersen
</surname>
26 <email>teg@jklm.no
</email>
32 <refentrytitle>hwdb
</refentrytitle>
33 <manvolnum>7</manvolnum>
37 <refname>hwdb
</refname>
38 <refpurpose>Hardware Database
</refpurpose>
41 <refsect1><title>Description
</title>
42 <para>The hardware database is a key-value store for associating modalias-like keys to
43 udev-property-like values. It is used primarily by udev to add the relevant properties
44 to matching devices, but it can also be queried directly.
</para>
47 <refsect1><title>Hardware Database Files
</title>
48 <para>The hwdb files are read from the files located in the
49 system hwdb directory
<filename>/usr/lib/udev/hwdb.d
</filename> and
50 the local administration directory
<filename>/etc/udev/hwdb.d
</filename>.
51 All hwdb files are collectively sorted and processed in lexical order,
52 regardless of the directories in which they live. However, files with
53 identical filenames replace each other. Files in
<filename>/etc
</filename>
54 have the highest priority and take precedence over files with the same
55 name in
<filename>/usr/lib
</filename>. This can be used to override a
56 system-supplied hwdb file with a local file if needed;
57 a symlink in
<filename>/etc
</filename> with the same name as a hwdb file in
58 <filename>/usr/lib
</filename>, pointing to
<filename>/dev/null
</filename>,
59 disables that hwdb file entirely. hwdb files must have the extension
60 <filename>.hwdb
</filename>; other extensions are ignored.
</para>
62 <para>Each hwdb file contains data records consisting of matches and associated
63 key-value pairs. Every record in the hwdb starts with one or more match strings,
64 specifying a shell glob to compare the lookup string against. Multiple match lines
65 are specified in consecutive lines. Every match line is compared individually, and
66 they are combined by OR. Every match line must start at the first character of the
69 <para>The match lines are followed by one or more key-value pair lines, which are
70 recognized by a leading space character. The key name and value are separated by
71 <literal>=
</literal>. An empty line signifies the end of a record. Lines beginning
72 with
<literal>#
</literal> are ignored.
</para>
74 <para>In case multiple records match a given lookup string, the key-value pairs
75 from all records are combined. If a key is specified multiple times, the value
76 from the record with the highest priority is used (each key can have only a single
77 value). The priority is higher when the record is in a file that sorts later
78 lexicographically, and in case of records in the same file, later records have
79 higher priority.
</para>
81 <para>The content of all hwdb files is read by
82 <citerefentry><refentrytitle>systemd-hwdb
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
83 and compiled to a binary database located at
<filename>/etc/udev/hwdb.bin
</filename>,
84 or alternatively
<filename>/usr/lib/udev/hwdb.bin
</filename> if you want ship the
85 compiled database in an immutable image. During runtime, only the binary database
90 <title>Examples
</title>
93 <title>General syntax of hwdb files
</title>
95 <programlisting># /usr/lib/udev/hwdb.d/example.hwdb
96 # Comments can be placed before any records. This is a good spot
97 # to describe what that file is used for, what kind of properties
98 # it defines, and the ordering convention.
100 # A record with three matches and one property
101 mouse:*:name:*Trackball*:
102 mouse:*:name:*trackball*:
103 mouse:*:name:*TrackBall*:
106 # A record with a single match and five properties
107 mouse:usb:v046dp4041:name:Logitech MX Master:
109 MOUSE_WHEEL_CLICK_ANGLE=
15
110 MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL=
26
111 MOUSE_WHEEL_CLICK_COUNT=
24
112 MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL=
14
117 <title>Overriding of properties
</title>
119 <programlisting># /usr/lib/udev/hwdb.d/
60-keyboard.hwdb
120 evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn*
122 KEYBOARD_KEY_a2=setup
123 KEYBOARD_KEY_a3=battery
125 evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn123*
128 # /etc/udev/hwdb.d/
70-keyboard.hwdb
129 # disable wlan key on all at keyboards
131 KEYBOARD_KEY_a2=reserved
</programlisting>
133 <para>If the hwdb consists of those two files, a keyboard with the lookup string
134 <literal>evdev:atkbd:dmi:bvnAcer:bdXXXXX:bd08/
05/
2010:svnAcer:pn123
</literal>
135 will match all three records, and end up with the following properties:
</para>
137 <programlisting>KEYBOARD_KEY_a1=help
138 KEYBOARD_KEY_a2=reserved
139 KEYBOARD_KEY_a3=battery
</programlisting>
144 <title>See Also
</title>
147 <refentrytitle>systemd-hwdb
</refentrytitle><manvolnum>8</manvolnum>