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