1
0

tools.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. .. _tools:
  2. ==============================================================================
  3. Helper tools
  4. ==============================================================================
  5. libinput provides a ``libinput`` tool to query state and events. This tool
  6. takes a subcommand as argument, similar to the **git** command. A full
  7. explanation of the various commands available in the libinput tool is
  8. available in the **libinput(1)** man page.
  9. The most common tools used are:
  10. - ``libinput list-devices``: to list locally available devices as seen by libinput,
  11. see :ref:`here <libinput-list-devices>`
  12. - ``libinput list-kernel-devices``: to list locally available devices as seen by the kernel,
  13. see :ref:`here <libinput-list-kernel-devices>`
  14. - ``libinput debug-events``: to monitor and debug events,
  15. see :ref:`here <libinput-debug-events>`
  16. - ``libinput debug-gui``: to visualize events,
  17. see :ref:`here <libinput-debug-gui>`
  18. - ``libinput record``: to record an event sequence for replaying,
  19. see :ref:`here <libinput-record>`
  20. - ``libinput measure``: measure properties on a kernel device,
  21. see :ref:`here <libinput-measure>`
  22. - ``libinput analyze``: analyse event recordings from a kernel device,
  23. see :ref:`here <libinput-analyze>`
  24. - ``libinput quirks``: show quirks assigned to a device, see
  25. :ref:`here <libinput-quirks>`
  26. Most of the tools must be run as root to have access to the kernel's
  27. ``/dev/input/event*`` device files.
  28. .. _libinput-list-devices:
  29. ------------------------------------------------------------------------------
  30. libinput list-devices
  31. ------------------------------------------------------------------------------
  32. The ``libinput list-devices`` command shows information about devices
  33. recognized by libinput and can help identifying why a device behaves
  34. different than expected. For example, if a device does not show up in the
  35. output, it is not a supported input device.
  36. .. note:: This tool does **not** show your desktop's configuration, just the
  37. libinput built-in defaults.
  38. ::
  39. $ sudo libinput list-devices
  40. [...]
  41. Device: SynPS/2 Synaptics TouchPad
  42. Kernel: /dev/input/event4
  43. Group: 9
  44. Seat: seat0, default
  45. Size: 97.33x66.86mm
  46. Capabilities: pointer
  47. Tap-to-click: disabled
  48. Tap drag lock: disabled
  49. Left-handed: disabled
  50. Nat.scrolling: disabled
  51. Middle emulation: n/a
  52. Calibration: n/a
  53. Scroll methods: *two-finger
  54. Click methods: *button-areas clickfinger
  55. [...]
  56. The above listing shows example output for a touchpad. The
  57. ``libinput list-devices`` command lists general information about the device
  58. (the kernel event node) but also the configuration options. If an option is
  59. ``n/a`` it does not exist on this device. Otherwise, the tool will show the
  60. default configuration for this device, for options that have more than a
  61. binary state all available options are listed, with the default one prefixed
  62. with an asterisk (``*``). In the example above, the default click method is
  63. button-areas but clickfinger is available.
  64. .. note:: This tool is intended for human-consumption and may change its output
  65. at any time.
  66. .. _libinput-list-kernel-devices:
  67. ------------------------------------------------------------------------------
  68. libinput list-kernel-devices
  69. ------------------------------------------------------------------------------
  70. The ``libinput list-kernel-devices`` command shows the devices known by **the
  71. kernel**. This command can help identify issues when a device is not handled by
  72. libinput.
  73. ::
  74. $ libinput list-kernel-devices
  75. /dev/input/event0: Sleep Button
  76. /dev/input/event1: Power Button
  77. /dev/input/event2: Power Button
  78. /dev/input/event3: Microsoft Microsoft® 2.4GHz Transceiver v9.0
  79. /dev/input/event4: Microsoft Microsoft® 2.4GHz Transceiver v9.0 Mouse
  80. [...]
  81. In some cases, knowing about the HID devices behind the kernel's event nodes
  82. can be useful. To list HID devices, supply the ``--hid`` commandline flag:
  83. ::
  84. $ libinput list-kernel-devices --hid
  85. hid:
  86. - name: 'Logitech Gaming Mouse G303'
  87. id: '046d:c080'
  88. driver: 'hid-generic'
  89. hidraw: ['/dev/hidraw6']
  90. evdev: ['/dev/input/event13']
  91. - name: 'Logitech Gaming Mouse G303'
  92. id: '046d:c080'
  93. driver: 'hid-generic'
  94. hidraw: ['/dev/hidraw7']
  95. evdev: ['/dev/input/event14']
  96. - name: 'Microsoft Microsoft® 2.4GHz Transceiver v9.0'
  97. id: '045e:07a5'
  98. driver: 'hid-generic'
  99. hidraw: ['/dev/hidraw0']
  100. evdev: ['/dev/input/event3']
  101. .. note:: This tool is intended for human-consumption and may change its output
  102. at any time.
  103. .. _libinput-debug-events:
  104. ------------------------------------------------------------------------------
  105. libinput debug-events
  106. ------------------------------------------------------------------------------
  107. The ``libinput debug-events`` command prints events from devices and can help
  108. to identify why a device behaves different than expected. ::
  109. $ sudo libinput debug-events --enable-tapping --set-click-method=clickfinger
  110. All configuration options (enable/disable tapping,
  111. etc.) are available as commandline arguments. To reproduce the event
  112. sequence as your desktop session sees it, ensure that all options are turned
  113. on or off as required. See the **libinput-debug-events(1)** man page or the
  114. ``--help`` output for information about the available options.
  115. .. note:: When submitting a bug report, always use the ``--verbose`` flag to get
  116. additional information: ``libinput debug-events --verbose <other options>``
  117. An example output from this tool may look like the snippet below. ::
  118. $ sudo libinput debug-events --enable-tapping --set-click-method=clickfinger
  119. -event2 DEVICE_ADDED Power Button seat0 default group1 cap:k
  120. -event5 DEVICE_ADDED Video Bus seat0 default group2 cap:k
  121. -event0 DEVICE_ADDED Lid Switch seat0 default group3 cap:S
  122. -event1 DEVICE_ADDED Sleep Button seat0 default group4 cap:k
  123. -event4 DEVICE_ADDED HDA Intel HDMI HDMI/DP,pcm=3 seat0 default group5 cap:
  124. -event11 DEVICE_ADDED HDA Intel HDMI HDMI/DP,pcm=7 seat0 default group6 cap:
  125. -event12 DEVICE_ADDED HDA Intel HDMI HDMI/DP,pcm=8 seat0 default group7 cap:
  126. -event13 DEVICE_ADDED HDA Intel HDMI HDMI/DP,pcm=9 seat0 default group8 cap:
  127. -event14 DEVICE_ADDED HDA Intel HDMI HDMI/DP,pcm=10 seat0 default group9 cap:
  128. -event19 DEVICE_ADDED Integrated Camera: Integrated C seat0 default group10 cap:k
  129. -event15 DEVICE_ADDED HDA Intel PCH Dock Mic seat0 default group11 cap:
  130. -event16 DEVICE_ADDED HDA Intel PCH Mic seat0 default group12 cap:
  131. -event17 DEVICE_ADDED HDA Intel PCH Dock Headphone seat0 default group13 cap:
  132. -event18 DEVICE_ADDED HDA Intel PCH Headphone seat0 default group14 cap:
  133. -event6 DEVICE_ADDED ELAN Touchscreen seat0 default group15 cap:t size 305x172mm ntouches 10 calib
  134. -event3 DEVICE_ADDED AT Translated Set 2 keyboard seat0 default group16 cap:k
  135. -event20 DEVICE_ADDED SynPS/2 Synaptics TouchPad seat0 default group17 cap:pg size 100x76mm tap(dl off) left scroll-nat scroll-2fg-edge click-buttonareas-clickfinger dwt-on
  136. -event21 DEVICE_ADDED TPPS/2 IBM TrackPoint seat0 default group18 cap:p left scroll-nat scroll-button
  137. -event7 DEVICE_ADDED ThinkPad Extra Buttons seat0 default group19 cap:k
  138. -event20 POINTER_MOTION +3.62s 2.72/ -0.93
  139. event20 POINTER_MOTION +3.63s 1.80/ -1.42
  140. event20 POINTER_MOTION +3.65s 6.16/ -2.28
  141. event20 POINTER_MOTION +3.66s 6.42/ -1.99
  142. event20 POINTER_MOTION +3.67s 8.99/ -1.42
  143. event20 POINTER_MOTION +3.68s 11.30/ 0.00
  144. event20 POINTER_MOTION +3.69s 21.32/ 1.42
  145. .. _libinput-debug-gui:
  146. ------------------------------------------------------------------------------
  147. libinput debug-gui
  148. ------------------------------------------------------------------------------
  149. A simple GTK-based graphical tool that shows the behavior and location of
  150. touch events, pointer motion, scroll axes and gestures. Since this tool
  151. gathers data directly from libinput, it is thus suitable for
  152. pointer-acceleration testing.
  153. .. note:: This tool does **not** use your desktop's configuration, just the
  154. libinput built-in defaults.
  155. ::
  156. $ sudo libinput debug-gui --enable-tapping
  157. As with :ref:`libinput-debug-events`, all options must be specified on the
  158. commandline to emulate the correct behavior.
  159. See the **libinput-debug-gui(1)** man page or the ``--help`` output for information about
  160. the available options.
  161. .. _libinput-record:
  162. ------------------------------------------------------------------------------
  163. libinput record and libinput replay
  164. ------------------------------------------------------------------------------
  165. .. note:: For libinput versions 1.10 and older, use :ref:`evemu`.
  166. The ``libinput record`` command records the **kernel** events from a specific
  167. device node. The recorded sequence can be replayed with the ``libinput
  168. replay`` command. This pair of tools is crucial to capturing bugs and
  169. reproducing them on a developer's machine.
  170. .. graphviz:: libinput-record.gv
  171. :align: center
  172. The recorded events are **kernel events** and independent of the
  173. libinput context. libinput does not need to be running, it does
  174. not matter whether a user is running X.Org or Wayland or even what
  175. version of libinput is currently running.
  176. The use of the tools is straightforward, just run without arguments, piping
  177. the output into a file: ::
  178. $ sudo libinput record > touchpad.yml
  179. Available devices:
  180. /dev/input/event0: Lid Switch
  181. /dev/input/event1: Sleep Button
  182. /dev/input/event2: Power Button
  183. /dev/input/event3: AT Translated Set 2 keyboard
  184. /dev/input/event4: ThinkPad Extra Buttons
  185. /dev/input/event5: ELAN Touchscreen
  186. /dev/input/event6: Video Bus
  187. /dev/input/event7: HDA Intel HDMI HDMI/DP,pcm=3
  188. /dev/input/event8: HDA Intel HDMI HDMI/DP,pcm=7
  189. /dev/input/event9: HDA Intel HDMI HDMI/DP,pcm=8
  190. /dev/input/event10: HDA Intel HDMI HDMI/DP,pcm=9
  191. /dev/input/event11: HDA Intel HDMI HDMI/DP,pcm=10
  192. /dev/input/event12: HDA Intel PCH Dock Mic
  193. /dev/input/event13: HDA Intel PCH Mic
  194. /dev/input/event14: HDA Intel PCH Dock Headphone
  195. /dev/input/event15: HDA Intel PCH Headphone
  196. /dev/input/event16: Integrated Camera: Integrated C
  197. /dev/input/event17: SynPS/2 Synaptics TouchPad
  198. /dev/input/event18: TPPS/2 IBM TrackPoint
  199. Select the device event number: 17
  200. /dev/input/event17 recording to stdout
  201. Without arguments, ``libinput record`` displays the available devices and lets
  202. the user select one. Supply the number (17 in this case for
  203. ``/dev/input/event17``) and the tool will print the device information and
  204. events to the file it is redirected to. More arguments are available, see
  205. the **libinput-record(1)** man page.
  206. .. note:: When reproducing a bug that crashes libinput, run inside ``screen`` or
  207. ``tmux``.
  208. Reproduce the bug, ctrl+c and attach the output file to a bug report.
  209. For data protection, ``libinput record`` obscures key codes by default, any
  210. alphanumeric key shows up as letter "a".
  211. .. warning:: The longer the recording, the harder it is to identify the event
  212. sequence triggering the bug. Please keep the event sequence as
  213. short as possible.
  214. The recording can be replayed with the ``libinput replay`` command: ::
  215. $ sudo libinput replay touchpad.yml
  216. /dev/input/event19: SynPS/2 Synaptics TouchPad
  217. Hit enter to start replaying
  218. ``libinput replay`` creates a new virtual device based on the description in
  219. the log file. Hitting enter replays the event sequence once and the tool
  220. stops once all events have been replayed. Hitting enter again replays the
  221. sequence again, Ctrl+C stops it and removes the virtual device.
  222. Users are advised to always replay a recorded event sequence to ensure they
  223. have captured the bug.
  224. Sometimes only the device description is needed, e.g. for checking the
  225. device's capabilities, udev properties, or quirks. Use
  226. ``libinput record --no-events`` to print the device description and
  227. exit immediately without waiting for any events::
  228. $ sudo libinput record --no-events /dev/input/event17
  229. More arguments are available, see the **libinput-record(1)** and
  230. **libinput-replay(1)** man pages.
  231. .. _libinput-record-autorestart:
  232. ..............................................................................
  233. libinput record's autorestart feature
  234. ..............................................................................
  235. ``libinput record`` often collects thousands of events per minute. However,
  236. the output of ``libinput record`` usually needs to be visually inspected
  237. or replayed in realtime on a developer machine. It is thus imperative that
  238. the event log is kept as short as possible.
  239. For bugs that are difficult to reproduce use
  240. ``libinput record --autorestart=2 --output-file=recording.yml``.
  241. The tool will wait for device activity before creating an output file.
  242. Once events are received, they are recorded to a file named
  243. ``recording.yml.<current-date-and-time>``. Whenever the device does not
  244. send events for 2 seconds, the current file is closed and a new file is
  245. created once the device sends events again.
  246. To use the ``--autorestart`` option correctly:
  247. - run ``libinput record --autorestart=2 --output-file=<somefilename>.yml``.
  248. You may provide a timeout other than 2 if needed.
  249. - use the device to reproduce the bug, pausing frequently for 2s and longer
  250. to rotate the logs
  251. - when the bug triggers, **immediately stop using the device** and wait
  252. several seconds for the log to rotate
  253. - Ctrl+C the ``libinput record`` process without using the device
  254. again. Attach the **last recording** to the bug report.
  255. If you have to use the recorded device to stop ``libinput record`` (e.g. to
  256. switch windows), remember that this will cause a new recording to be
  257. created. Thus, attach the **second-to-last recording** to the bug report
  258. because this one contains the bug trigger.
  259. .. _libinput-record-multiple:
  260. ..............................................................................
  261. Recording multiple devices at once
  262. ..............................................................................
  263. In some cases, an interaction between multiple devices is the cause for a
  264. specific bug. For example, a touchpad may not work in response to keyboard
  265. events. To accurately reproduce this sequence, the timing between multiple
  266. devices must be correct and we need to record the events in one go.
  267. ``libinput record`` can record multiple devices by specifying them on the
  268. commandline. Recording multiple devices requires the ``--output-file``
  269. argument: ::
  270. $ sudo libinput record --output-file=touchpad-bug.yml /dev/input/event17 /dev/input/event3
  271. recording to 'touchpad-bug.yml'
  272. Replaying events is the same as for a single recording: ::
  273. $ sudo libinput replay touchpad-bug.yml
  274. .. _libinput-measure:
  275. ------------------------------------------------------------------------------
  276. Measuring device properties with libinput measure
  277. ------------------------------------------------------------------------------
  278. The ``libinput measure`` tool is a multiplexer for various sub-tools that can
  279. measure specific properties on the device. These tools generally measure one
  280. thing and one thing only and their usage is highly specific to the tool.
  281. Please see the **libinput-measure(1)** man page for information about what
  282. tools are available and the man page for each respective tool.
  283. .. _libinput-analyze:
  284. ------------------------------------------------------------------------------
  285. Analyzing device events with libinput analyze
  286. ------------------------------------------------------------------------------
  287. The ``libinput analyze`` tool is a multiplexer for various sub-tools that
  288. can analyze input events previously recorded from a device.
  289. Please see the **libinput-analyze(1)** man page for information about what
  290. tools are available and the man page for each respective tool.
  291. .. _libinput-quirks:
  292. ------------------------------------------------------------------------------
  293. Listing quirks assigned to a device
  294. ------------------------------------------------------------------------------
  295. The ``libinput quirks`` tool can show quirks applied for any given device. ::
  296. $ libinput quirks list /dev/input/event0
  297. AttrLidSwitchReliability=unreliable
  298. If the tool's output is empty, no quirk is applied. See :ref:`device-quirks`
  299. for more information.