]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/hwdb.xml
man: describe overriding of entries in hwdb files
[thirdparty/systemd.git] / man / hwdb.xml
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">
4
5 <refentry id="hwdb" conditional="ENABLE_HWDB">
6 <refentryinfo>
7 <title>hwdb</title>
8 <productname>systemd</productname>
9 <authorgroup>
10 <author>
11 <contrib>Developer</contrib>
12 <firstname>Kay</firstname>
13 <surname>Sievers</surname>
14 <email>kay@vrfy.org</email>
15 </author>
16 <author>
17 <contrib>Developer</contrib>
18 <firstname>Tom</firstname>
19 <surname>Gundersen</surname>
20 <email>teg@jklm.no</email>
21 </author>
22 </authorgroup>
23 </refentryinfo>
24
25 <refmeta>
26 <refentrytitle>hwdb</refentrytitle>
27 <manvolnum>7</manvolnum>
28 </refmeta>
29
30 <refnamediv>
31 <refname>hwdb</refname>
32 <refpurpose>Hardware Database</refpurpose>
33 </refnamediv>
34
35 <refsect1><title>Description</title>
36 <para>The hardware database is a key-value store for associating modalias-like keys to
37 udev-property-like values. It is used primarily by udev to add the relevant properties
38 to matching devices, but it can also be queried directly.</para>
39 </refsect1>
40
41 <refsect1><title>Hardware Database Files</title>
42 <para>The hwdb files are read from the files located in the
43 system hwdb directory <filename>/usr/lib/udev/hwdb.d</filename> and
44 the local administration directory <filename>/etc/udev/hwdb.d</filename>.
45 All hwdb files are collectively sorted and processed in lexical order,
46 regardless of the directories in which they live. However, files with
47 identical filenames replace each other. Files in <filename>/etc</filename>
48 have the highest priority and take precedence over files with the same
49 name in <filename>/usr/lib</filename>. This can be used to override a
50 system-supplied hwdb file with a local file if needed;
51 a symlink in <filename>/etc</filename> with the same name as a hwdb file in
52 <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
53 disables that hwdb file entirely. hwdb files must have the extension
54 <filename>.hwdb</filename>; other extensions are ignored.</para>
55
56 <para>Each hwdb file contains data records consisting of matches and associated
57 key-value pairs. Every record in the hwdb starts with one or more match strings,
58 specifying a shell glob to compare the lookup string against. Multiple match lines
59 are specified in consecutive lines. Every match line is compared individually, and
60 they are combined by OR. Every match line must start at the first character of the
61 line.</para>
62
63 <para>The match lines are followed by one or more key-value pair lines, which are
64 recognized by a leading space character. The key name and value are separated by
65 <literal>=</literal>. An empty line signifies the end of a record. Lines beginning
66 with <literal>#</literal> are ignored.</para>
67
68 <para>In case multiple records match a given lookup string, the key-value pairs
69 from all records are combined. If a key is specified multiple times, the value
70 from the record with the highest priority is used (each key can have only a single
71 value). The priority is higher when the record is in a file that sorts later
72 lexicographically, and in case of records in the same file, later records have
73 higher priority.</para>
74
75 <para>The content of all hwdb files is read by
76 <citerefentry><refentrytitle>systemd-hwdb</refentrytitle><manvolnum>8</manvolnum></citerefentry>
77 and compiled to a binary database located at <filename>/etc/udev/hwdb.bin</filename>,
78 or alternatively <filename>/usr/lib/udev/hwdb.bin</filename> if you want ship the
79 compiled database in an immutable image. During runtime, only the binary database
80 is used.</para>
81 </refsect1>
82
83 <refsect1>
84 <title>Examples</title>
85
86 <example>
87 <title>General syntax of hwdb files</title>
88
89 <programlisting># /usr/lib/udev/hwdb.d/example.hwdb
90 # Comments can be placed before any records. This is a good spot
91 # to describe what that file is used for, what kind of properties
92 # it defines, and the ordering convention.
93
94 # A record with three matches and one property
95 mouse:*:name:*Trackball*:
96 mouse:*:name:*trackball*:
97 mouse:*:name:*TrackBall*:
98 ID_INPUT_TRACKBALL=1
99
100 # A record with a single match and five properties
101 mouse:usb:v046dp4041:name:Logitech MX Master:
102 MOUSE_DPI=1000@166
103 MOUSE_WHEEL_CLICK_ANGLE=15
104 MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL=26
105 MOUSE_WHEEL_CLICK_COUNT=24
106 MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL=14
107 </programlisting>
108 </example>
109
110 <example>
111 <title>Overriding of properties</title>
112
113 <programlisting># /usr/lib/udev/hwdb.d/60-keyboard.hwdb
114 evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn*
115 KEYBOARD_KEY_a1=help
116 KEYBOARD_KEY_a2=setup
117 KEYBOARD_KEY_a3=battery
118
119 evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn123*
120 KEYBOARD_KEY_a2=wlan
121
122 # /etc/udev/hwdb.d/70-keyboard.hwdb
123 # disable wlan key on all at keyboards
124 evdev:atkbd:*
125 KEYBOARD_KEY_a2=reserved</programlisting>
126
127 <para>If the hwdb consists of those two files, a keyboard with the lookup string
128 <literal>evdev:atkbd:dmi:bvnAcer:bdXXXXX:bd08/05/2010:svnAcer:pn123</literal>
129 will match all three records, and end up with the following properties:</para>
130
131 <programlisting>KEYBOARD_KEY_a1=help
132 KEYBOARD_KEY_a2=reserved
133 KEYBOARD_KEY_a3=battery</programlisting>
134 </example>
135 </refsect1>
136
137 <refsect1>
138 <title>See Also</title>
139 <para>
140 <citerefentry>
141 <refentrytitle>systemd-hwdb</refentrytitle><manvolnum>8</manvolnum>
142 </citerefentry>
143 </para>
144 </refsect1>
145 </refentry>