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