]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/hwdb.xml
Merge pull request #9302 from keszybz/drop-my-copyright-and-some-license-tags
[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 <!--
6 SPDX-License-Identifier: LGPL-2.1+
7
8 Copyright © 2014 Tom Gundersen
9 -->
10
11 <refentry id="hwdb" conditional="ENABLE_HWDB">
12 <refentryinfo>
13 <title>hwdb</title>
14 <productname>systemd</productname>
15 <authorgroup>
16 <author>
17 <contrib>Developer</contrib>
18 <firstname>Kay</firstname>
19 <surname>Sievers</surname>
20 <email>kay@vrfy.org</email>
21 </author>
22 <author>
23 <contrib>Developer</contrib>
24 <firstname>Tom</firstname>
25 <surname>Gundersen</surname>
26 <email>teg@jklm.no</email>
27 </author>
28 </authorgroup>
29 </refentryinfo>
30
31 <refmeta>
32 <refentrytitle>hwdb</refentrytitle>
33 <manvolnum>7</manvolnum>
34 </refmeta>
35
36 <refnamediv>
37 <refname>hwdb</refname>
38 <refpurpose>Hardware Database</refpurpose>
39 </refnamediv>
40
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>
45 </refsect1>
46
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>
61
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
67 line.</para>
68
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>
73
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>
80
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
86 is used.</para>
87 </refsect1>
88
89 <refsect1>
90 <title>Examples</title>
91
92 <example>
93 <title>General syntax of hwdb files</title>
94
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.
99
100 # A record with three matches and one property
101 mouse:*:name:*Trackball*:
102 mouse:*:name:*trackball*:
103 mouse:*:name:*TrackBall*:
104 ID_INPUT_TRACKBALL=1
105
106 # A record with a single match and five properties
107 mouse:usb:v046dp4041:name:Logitech MX Master:
108 MOUSE_DPI=1000@166
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
113 </programlisting>
114 </example>
115
116 <example>
117 <title>Overriding of properties</title>
118
119 <programlisting># /usr/lib/udev/hwdb.d/60-keyboard.hwdb
120 evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn*
121 KEYBOARD_KEY_a1=help
122 KEYBOARD_KEY_a2=setup
123 KEYBOARD_KEY_a3=battery
124
125 evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn123*
126 KEYBOARD_KEY_a2=wlan
127
128 # /etc/udev/hwdb.d/70-keyboard.hwdb
129 # disable wlan key on all at keyboards
130 evdev:atkbd:*
131 KEYBOARD_KEY_a2=reserved</programlisting>
132
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>
136
137 <programlisting>KEYBOARD_KEY_a1=help
138 KEYBOARD_KEY_a2=reserved
139 KEYBOARD_KEY_a3=battery</programlisting>
140 </example>
141 </refsect1>
142
143 <refsect1>
144 <title>See Also</title>
145 <para>
146 <citerefentry>
147 <refentrytitle>systemd-hwdb</refentrytitle><manvolnum>8</manvolnum>
148 </citerefentry>
149 </para>
150 </refsect1>
151 </refentry>