device-configuration-via-udev.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. .. _udev_config:
  2. ==============================================================================
  3. Static device configuration via udev
  4. ==============================================================================
  5. libinput supports some static configuration through udev properties.
  6. These properties are read when the device is initially added
  7. to libinput's device list, i.e. before the
  8. **LIBINPUT_EVENT_DEVICE_ADDED** event is generated.
  9. The following udev properties are supported:
  10. LIBINPUT_CALIBRATION_MATRIX
  11. Sets the calibration matrix, see
  12. **libinput_device_config_calibration_get_default_matrix()**. If unset,
  13. defaults to the identity matrix.
  14. The udev property is parsed as 6 floating point numbers separated by a
  15. single space each (scanf(3) format ``"%f %f %f %f %f %f"``).
  16. The 6 values represent the first two rows of the calibration matrix as
  17. described in **libinput_device_config_calibration_set_matrix()**.
  18. Example values are: ::
  19. ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 1 0" # default
  20. ENV{LIBINPUT_CALIBRATION_MATRIX}="0 -1 1 1 0 0" # 90 degree clockwise
  21. ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 0 -1 1" # 180 degree clockwise
  22. ENV{LIBINPUT_CALIBRATION_MATRIX}="0 1 0 -1 0 1" # 270 degree clockwise
  23. ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 0 1 0" # reflect along y axis
  24. LIBINPUT_DEVICE_GROUP
  25. A string identifying the **libinput_device_group** for this device. Two
  26. devices with the same property value are grouped into the same device group,
  27. the value itself is irrelevant otherwise.
  28. LIBINPUT_IGNORE_DEVICE
  29. If set to anything other than "0", the device is ignored by libinput.
  30. See :ref:`ignoring_devices` for more details.
  31. ID_SEAT
  32. Assigns the physical :ref:`seat <seats>` for this device. See
  33. **libinput_seat_get_physical_name()**. Defaults to "seat0".
  34. ID_INPUT
  35. If this property is set, the device is considered an input device. Any
  36. device with this property missing will be ignored, see :ref:`udev_device_type`.
  37. ID_INPUT_KEYBOARD, ID_INPUT_KEY, ID_INPUT_MOUSE, ID_INPUT_TOUCHPAD, ID_INPUT_TOUCHSCREEN, ID_INPUT_TABLET, ID_INPUT_JOYSTICK, ID_INPUT_ACCELEROMETER
  38. If any of the above is set, libinput initializes the device as the given
  39. type, see :ref:`udev_device_type`. Note that for historical reasons more than
  40. one of these may be set at any time, libinput will select only one of these
  41. to determine the device type. To ensure libinput selects the correct device
  42. type, only set one of them.
  43. WL_SEAT
  44. Assigns the logical :ref:`seat <seats>` for this device. See
  45. **libinput_seat_get_logical_name()** context. Defaults to "default".
  46. MOUSE_DPI
  47. HW resolution and sampling frequency of a relative pointer device.
  48. See :ref:`motion_normalization` for details.
  49. MOUSE_WHEEL_CLICK_ANGLE
  50. The angle in degrees for each click on a mouse wheel. See
  51. **libinput_event_pointer_get_axis_source()** for details.
  52. Below is an example udev rule to assign "seat1" to a device from vendor
  53. ``0x012a`` with the model ID of ``0x034b``. ::
  54. $ cat /etc/udev/rules.d/99-my-device-is-on-seat1.rules
  55. ACTION!="remove", KERNEL=="event[0-9]*", \
  56. ENV{ID_VENDOR_ID}=="012a", \
  57. ENV{ID_MODEL_ID}=="034b", \
  58. ENV{ID_SEAT}="seat1"
  59. .. _udev_device_type:
  60. ------------------------------------------------------------------------------
  61. Device type assignment via udev
  62. ------------------------------------------------------------------------------
  63. libinput requires the **ID_INPUT** property to be set on a device,
  64. otherwise the device will be ignored. In addition, one of
  65. **ID_INPUT_KEYBOARD, ID_INPUT_KEY, ID_INPUT_MOUSE, ID_INPUT_TOUCHPAD,
  66. ID_INPUT_TOUCHSCREEN, ID_INPUT_TABLET, ID_INPUT_JOYSTICK,
  67. ID_INPUT_ACCELEROMETER** must be set on the device to determine the
  68. device type. The usual error handling applies within libinput and a device
  69. type label does not guarantee that the device is initialized by libinput.
  70. If a device fails to meet the requirements for a device type (e.g. a keyboard
  71. labelled as touchpad) the device will not be available through libinput.
  72. Only one device type should be set per device at a time, though libinput can
  73. handle some combinations for historical reasons.
  74. Below is an example udev rule to remove an **ID_INPUT_TOUCHPAD** setting
  75. and change it into an **ID_INPUT_TABLET** setting. This rule would apply
  76. for a device with the vendor/model ID of ``012a``/``034b``. ::
  77. $ cat /etc/udev/rules.d/99-my-device-is-a-tablet.rules
  78. ACTION!="remove", KERNEL=="event[0-9]*", \
  79. ENV{ID_VENDOR_ID}=="012a", \
  80. ENV{ID_MODEL_ID}=="034b", \
  81. ENV{ID_INPUT_TOUCHPAD}="", ENV{ID_INPUT_TABLET}="1"
  82. .. _model_specific_configuration:
  83. ------------------------------------------------------------------------------
  84. Model-specific configuration
  85. ------------------------------------------------------------------------------
  86. As of libinput 1.12, model-specific configuration is stored in the
  87. :ref:`device-quirks` and not in the hwdb anymore. Please see
  88. :ref:`device-quirks` for
  89. details.
  90. .. _model_specific_configuration_x220fw81:
  91. ..............................................................................
  92. Lenovo x220 with touchpad firmware v8.1
  93. ..............................................................................
  94. The property **LIBINPUT_MODEL_LENOVO_X220_TOUCHPAD_FW81** may be set by a
  95. user in a local hwdb file. This property designates the touchpad on a Lenovo
  96. x220 with a touchpad firmware version 8.1. When this firmware version is
  97. installed, the touchpad is imprecise. The touchpad device does not send
  98. continuous x/y axis position updates, a behavior also observed on its
  99. successor model, the Lenovo x230 which has the same firmware version. If the
  100. above property is set, libinput adjusts its behavior to better suit this
  101. particular model.
  102. The touchpad firmware version cannot be detected automatically by libinput,
  103. local configuration is required to set this property. Refer to the libinput
  104. model quirks hwdb for instructions.
  105. This property must not be used for any other purpose, no specific behavior
  106. is guaranteed.
  107. .. _hwdb:
  108. ------------------------------------------------------------------------------
  109. Configuring the hwdb
  110. ------------------------------------------------------------------------------
  111. This section outlines how to query the
  112. `udev hwdb <https://www.freedesktop.org/software/systemd/man/hwdb.html>`_
  113. and reload properties so they are available to libinput.
  114. The hwdb contains a set of match rules that assign udev properties that are
  115. available to libinput when the device is connected and/or libinput is
  116. initialized. This section only describes the hwdb in relation to libinput,
  117. it is not a full documentation on how the hwdb works.
  118. libinput's use of the hwdb is limited to properties systemd and custom
  119. rules files (where available) provide. Hardware-specific quirks as used by
  120. libinput are in the :ref:`device-quirks` system.
  121. .. _hwdb_querying:
  122. ..............................................................................
  123. Querying the hwdb
  124. ..............................................................................
  125. libinput only uses device nodes in the form of ``/dev/input/eventX`` where X
  126. is the number of the specific device. Running ``libinput debug-events`` lists
  127. all devices currently available to libinput and their event node name: ::
  128. $> sudo libinput debug-events
  129. -event2 DEVICE_ADDED Power Button seat0 default group1 cap:k
  130. -event5 DEVICE_ADDED Video Bus seat0 default group2 cap:k
  131. -event0 DEVICE_ADDED Lid Switch seat0 default group3 cap:S
  132. ...
  133. Note the event node name for your device and translate it into a syspath in
  134. the form of ``/sys/class/input/eventX``. This path can be supplied to ``udevadm
  135. info`` ::
  136. $> udevadm info
  137. P: /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0D:00/input/input0/event0
  138. N: input/event0
  139. E: DEVNAME=/dev/input/event0
  140. E: DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0D:00/input/input0/event0
  141. E: ID_INPUT=1
  142. E: ID_INPUT_SWITCH=1
  143. E: MAJOR=13
  144. E: MINOR=64
  145. E: SUBSYSTEM=input
  146. E: TAGS=:power-switch:
  147. E: USEC_INITIALIZED=7167898
  148. Lines starting with ``E:`` are udev properties available to libinput. For
  149. example, the above device's ``ID_INPUT_SWITCH`` property will cause libinput
  150. to treat this device as switch device.
  151. .. _hwdb_reloading:
  152. ..............................................................................
  153. Reloading the hwdb
  154. ..............................................................................
  155. The actual hwdb is stored in binary file on-disk and must be updated
  156. manually whenever a ``.hwdb`` file changes. This is required both when a user
  157. manually edits the ``.hwdb`` file but also when the git tree is updated (and
  158. that update causes a hwdb change).
  159. To update the binary file on-disk, run: ::
  160. sudo systemd-hwdb update
  161. Then, to trigger a reload of all properties on your device, run: ::
  162. sudo udevadm trigger /sys/class/input/eventX
  163. Then check with ``udevadm info`` whether the properties were updated, see
  164. :ref:`hwdb_querying`. If a new property does not appear on the device, use ``udevadm
  165. test`` to check for error messages by udev and the hwdb (e.g. syntax errors
  166. in the udev rules files). ::
  167. sudo udevadm test /sys/class/input/eventX
  168. .. warning:: ``udevadm test`` does not run commands specified in ``RUN``
  169. directives. This affects the udev properties relying on e.g.
  170. the udev keyboard builtin such as the :ref:`touchpad_jitter`
  171. workarounds.
  172. .. _hwdb_modifying:
  173. ..............................................................................
  174. Modifying the hwdb
  175. ..............................................................................
  176. .. warning:: This section has been removed as it no longer applies in libinput 1.12
  177. and later. libinput users should not need to modify the hwdb, any
  178. device-specific quirks must go in to the :ref:`device-quirks` system.
  179. For information about older libinput versions, please see the documentation
  180. for your version available in: https://wayland.freedesktop.org/libinput/doc/