_libinput 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. #compdef libinput
  2. (( $+functions[_libinput_commands] )) || _libinput_commands()
  3. {
  4. local -a commands
  5. commands=(
  6. "list-devices:List all devices recognized by libinput"
  7. "debug-events:Print all events as seen by libinput"
  8. "debug-gui:Show a GUI to visualize libinput's events"
  9. "debug-tablet:Show tablet axis and button values"
  10. "measure:Measure various properties of devices"
  11. "analyze:Analyze device data"
  12. "record:Record the events from a device"
  13. "replay:Replay the events from a device"
  14. )
  15. _describe -t commands 'command' commands
  16. }
  17. __all_seats()
  18. {
  19. # Obviously only works with logind
  20. local -a seats
  21. seats=${(f)"$(loginctl --no-legend --no-pager list-seats 2>/dev/null)"}
  22. if [[ -z $seats ]]; then
  23. # Can always offer seat0, even if we can't enumerate the seats
  24. compadd "$@" - seat0
  25. else
  26. compadd "$@" - $seats
  27. fi
  28. }
  29. (( $+functions[_libinput_list-devices] )) || _libinput_list-devices()
  30. {
  31. _arguments \
  32. '--help[Show help and exit]' \
  33. '--version[show version information and exit]'
  34. }
  35. (( $+functions[_libinput_debug-events] )) || _libinput_debug-events()
  36. {
  37. _arguments \
  38. '--help[Show debug-events help and exit]' \
  39. '--quiet[Only print libinput messages and nothing from this tool]' \
  40. '--verbose[Use verbose output]' \
  41. '--show-keycodes[Make all keycodes visible]' \
  42. '--grab[Exclusively grab all opened devices]' \
  43. '--compress-motion-events[Compress repeated motion events on a TTY]' \
  44. '--device=[Use the given device with the path backend]:device:_files -W /dev/input/ -P /dev/input/' \
  45. '--udev=[Listen for notifications on the given seat]:seat:__all_seats' \
  46. '--apply-to=[Apply configuration options where the device name matches the pattern]:pattern' \
  47. '--disable-sendevents=[Disable send-events option for the devices matching the pattern]:pattern' \
  48. '--set-area=[Set the desired area as "x1/y1 x2/y2" (within \[0.0, 1.0\]) ]' \
  49. '--set-calibration=[Set the first 6 elements of the 3x3 calibration matrix ("1.0 0.0 0.0 0.0 1.0 0.0")]' \
  50. '--set-click-method=[Set the desired click method]:click-method:(none clickfinger buttonareas)' \
  51. '--set-clickfinger-map=[Set button mapping for clickfinger]:tap-map:(( \
  52. lrm\:2-fingers\ right-click\ /\ 3-fingers\ middle-click \
  53. lmr\:2-fingers\ middle-click\ /\ 3-fingers\ right-click \
  54. ))' \
  55. '--set-eraser-button-button=[Set button mapping for the eraser button]:eraser-button:(BTN_STYLUS BTN_STYLUS2 BTN_STYLUS3)' \
  56. '--set-eraser-button-mode=[Set the eraser button mode]:eraser-mode:(default button)' \
  57. '--set-pressure-range=[Set the tablet tool pressure range (within range \[0.0, 1.0\])]' \
  58. '--set-profile=[Set pointer acceleration profile]:accel-profile:(adaptive flat custom)' \
  59. '--set-rotation-angle=[Set the rotation angle in degrees]' \
  60. '--set-scroll-button=[Set the button to the given button code]' \
  61. '--set-scroll-method=[Set the desired scroll method]:scroll-method:(none twofinger edge button)' \
  62. '--set-speed=[Set pointer acceleration speed (within range \[-1, 1\])]' \
  63. '--set-tap-map=[Set button mapping for tapping]:tap-map:(( \
  64. lrm\:2-fingers\ right-click\ /\ 3-fingers\ middle-click \
  65. lmr\:2-fingers\ middle-click\ /\ 3-fingers\ right-click \
  66. ))' \
  67. + '(custom pointer acceleration)' \
  68. '--set-custom-points=[Set n points defining a custom acceleration function]' \
  69. '--set-custom-step=[Set the distance along the x axis between the custom points]' \
  70. '--set-custom-type=[Set the type of the acceleration function]:custom-type:(fallback motion scroll)' \
  71. + '(drag)' \
  72. '--enable-drag[Enable tap-and-drag]' \
  73. '--disable-drag[Disable tap-and-drag]' \
  74. + '(drag-lock)' \
  75. '--enable-drag-lock[Enable drag-lock]' \
  76. '--disable-drag-lock[Disable drag-lock]' \
  77. + '(dwt)' \
  78. '--enable-dwt[Enable disable-while-typing]' \
  79. '--disable-dwt[Disable disable-while-typing]' \
  80. + '(dwtp)' \
  81. '--enable-dwtp[Enable disable-while-trackpointing]' \
  82. '--disable-dwtp[Disable disable-while-trackpointing]' \
  83. + '(left-handed)' \
  84. '--enable-left-handed[Enable left handed button configuration]' \
  85. '--disable-left-handed[Disable left handed button configuration]' \
  86. + '(middlebutton)' \
  87. '--enable-middlebutton[Enable middle button emulation]' \
  88. '--disable-middlebutton[Disable middle button emulation]' \
  89. + '(natural-scrolling)' \
  90. '--enable-natural-scrolling[Enable natural scrolling]' \
  91. '--disable-natural-scrolling[Disable natural scrolling]' \
  92. + '(plugins)' \
  93. '--enable-plugins[Enable plugins]' \
  94. '--disable-plugins[Disable plugins]' \
  95. + '(tap-to-click)' \
  96. '--enable-tap[Enable tap-to-click]' \
  97. '--disable-tap[Disable tap-to-click]'
  98. }
  99. (( $+functions[_libinput_debug-gui] )) || _libinput_debug-gui()
  100. {
  101. _arguments \
  102. '--help[Show debug-gui help and exit]' \
  103. '--verbose[Use verbose output]' \
  104. '--grab[Exclusively grab all opened devices]' \
  105. '--device=[Use the given device with the path backend]:device:_files -W /dev/input/ -P /dev/input/' \
  106. '--udev=[Listen for notifications on the given seat]:seat:_libinput_all_seats'
  107. }
  108. (( $+functions[_libinput_debug-tablet] )) || _libinput_debug-tablet()
  109. {
  110. _arguments \
  111. '--help[Show debug-tablet help and exit]' \
  112. '--device=[Use the given device with the path backend]:device:_files -W /dev/input/ -P /dev/input/' \
  113. '--udev=[Use the first tablet device on the given seat]:seat:_libinput_all_seats'
  114. }
  115. (( $+functions[_libinput_measure] )) || _libinput_measure()
  116. {
  117. local curcontext=$curcontext state line ret=1
  118. local features
  119. features=(
  120. "fuzz:Measure touch fuzz to avoid pointer jitter"
  121. "touch-size:Measure touch size and orientation"
  122. "touchpad-tap:Measure tap-to-click time"
  123. "touchpad-pressure:Measure touch pressure"
  124. )
  125. _arguments -C \
  126. '--help[Print help and exit]' \
  127. ':feature:->feature' \
  128. '*:: :->option-or-argument'
  129. case $state in
  130. (feature)
  131. _describe -t features 'feature' features
  132. ;;
  133. (option-or-argument)
  134. curcontext=${curcontext%:*:*}:libinput-measure-$words[1]:
  135. if ! _call_function ret _libinput_measure_$words[1]; then
  136. _message "unknown feature: $words[1]"
  137. fi
  138. ;;
  139. esac
  140. return ret
  141. }
  142. (( $+functions[_libinput_measure_fuzz] )) || _libinput_measure_fuzz()
  143. {
  144. _arguments \
  145. '--help[Show help message and exit]' \
  146. ':device:_files -W /dev/input/ -P /dev/input/'
  147. }
  148. (( $+functions[_libinput_measure_touch-size] )) || _libinput_measure_touch-size()
  149. {
  150. _arguments \
  151. '--help[Show help message and exit]' \
  152. '--touch-threshold=[Assume a touch pressure threshold of "down:up"]' \
  153. '--palm-threshold=[Assume a palm threshold of N]' \
  154. ':device:_files -W /dev/input/ -P /dev/input/'
  155. }
  156. (( $+functions[_libinput_measure_touchpad-pressure] )) || _libinput_measure_touchpad-pressure()
  157. {
  158. _arguments \
  159. '--help[Show help message and exit]' \
  160. '--touch-threshold=[Assume a touch pressure threshold of "down:up"]' \
  161. '--palm-threshold=[Assume a palm threshold of N]' \
  162. ':device:_files -W /dev/input/ -P /dev/input/'
  163. }
  164. (( $+functions[_libinput_measure_touchpad-tap] )) || _libinput_measure_touchpad-tap()
  165. {
  166. _arguments \
  167. '--help[Show help message and exit]' \
  168. '--format=dat[Specify the data format to be printed. The default is "summary"]' \
  169. ':device:_files -W /dev/input/ -P /dev/input/'
  170. }
  171. (( $+functions[_libinput_analyze_per-slot-delta] )) || _libinput_analyze_per-slot-delta()
  172. {
  173. _arguments \
  174. '--help[Show help message and exit]' \
  175. ':recording:_files'
  176. }
  177. (( $+functions[_libinput_analyze_touch-down-state] )) || _libinput_analyze_touch-down-state()
  178. {
  179. _arguments \
  180. '--help[Show help message and exit]' \
  181. ':recording:_files'
  182. }
  183. (( $+functions[_libinput_analyze_recording] )) || _libinput_analyze_recording()
  184. {
  185. _arguments \
  186. '--help[Show help message and exit]' \
  187. ':recording:_files'
  188. }
  189. (( $+functions[_libinput_analyze] )) || _libinput_analyze()
  190. {
  191. local curcontext=$curcontext state line ret=1
  192. local features
  193. features=(
  194. "per-slot-delta:analyze relative movement per touch per slot"
  195. "recording:analyze a recording by printing a pretty table"
  196. "touch-down-state:analyze a recording for logical touch down states"
  197. )
  198. _arguments -C \
  199. '--help[Print help and exit]' \
  200. ':feature:->feature' \
  201. '*:: :->option-or-argument'
  202. case $state in
  203. (feature)
  204. _describe -t features 'feature' features
  205. ;;
  206. (option-or-argument)
  207. curcontext=${curcontext%:*:*}:libinput-analyze-$words[1]:
  208. if ! _call_function ret _libinput_analyze_$words[1]; then
  209. _message "unknown feature: $words[1]"
  210. fi
  211. ;;
  212. esac
  213. return ret
  214. }
  215. (( $+functions[_libinput_record] )) || _libinput_record()
  216. {
  217. _arguments \
  218. '--help[Show help message and exit]' \
  219. '--all[Record all /dev/input/event* devices available on the system]' \
  220. '--autorestart=[Terminate the current recording after s seconds of device inactivity]' \
  221. {-o+,--output=}'[Specify the output file to use]:file:_files -g "*.yml"' \
  222. '--multiple[Record multiple devices at once]' \
  223. '--show-keycodes[Show keycodes as-is in the recording]' \
  224. '--with-libinput[Record libinput events alongside device events]' \
  225. '--with-hidraw[Record hidraw events alongside device events]' \
  226. '*::device:_files -W /dev/input/ -P /dev/input/'
  227. }
  228. (( $+functions[_libinput_replay] )) || _libinput_replay()
  229. {
  230. _arguments \
  231. '--help[Show help message and exit]' \
  232. ':recording:_files'
  233. }
  234. _libinput()
  235. {
  236. local curcontext=$curcontext state line ret=1
  237. _arguments -C \
  238. {-h,--help}'[Show help message and exit]' \
  239. '--version[Show version information and exit]' \
  240. ':command:->command' \
  241. '*:: :->option-or-argument' && return
  242. case $state in
  243. (command)
  244. _libinput_commands && ret=0
  245. ;;
  246. (option-or-argument)
  247. curcontext=${curcontext%:*:*}:libinput-$words[1]:
  248. if ! _call_function ret _libinput_$words[1]; then
  249. _message "unknown libinput command: $words[1]"
  250. fi
  251. ;;
  252. esac
  253. return ret
  254. }
  255. _libinput