• 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		+ '(dwtp)' \
83		'--enable-dwtp[Enable disable-while-trackpointing]' \
84		'--disable-dwtp[Disable disable-while-trackpointing]'
85}
86
87(( $+functions[_libinput_debug-gui] )) || _libinput_debug-gui()
88{
89	_arguments \
90		'--help[Show debug-gui help and exit]' \
91		'--verbose[Use verbose output]' \
92		'--grab[Exclusively grab all opened devices]' \
93		'--device=[Use the given device with the path backend]:device:_files -W /dev/input/ -P /dev/input/' \
94		'--udev=[Listen for notifications on the given seat]:seat:_libinput_all_seats'
95}
96
97(( $+functions[_libinput_debug-tablet] )) || _libinput_debug-tablet()
98{
99	_arguments \
100		'--help[Show debug-tablet help and exit]' \
101		'--device=[Use the given device with the path backend]:device:_files -W /dev/input/ -P /dev/input/' \
102		'--udev=[Use the first tablet device on the given seat]:seat:_libinput_all_seats'
103}
104
105
106(( $+functions[_libinput_measure] )) || _libinput_measure()
107{
108	local curcontext=$curcontext state line ret=1
109	local features
110	features=(
111		"fuzz:Measure touch fuzz to avoid pointer jitter"
112		"touch-size:Measure touch size and orientation"
113		"touchpad-tap:Measure tap-to-click time"
114		"touchpad-pressure:Measure touch pressure"
115	)
116
117	_arguments -C \
118		'--help[Print help and exit]' \
119		':feature:->feature' \
120		'*:: :->option-or-argument'
121
122	case $state in
123		(feature)
124			_describe -t features 'feature' features
125			;;
126		(option-or-argument)
127			curcontext=${curcontext%:*:*}:libinput-measure-$words[1]:
128			if ! _call_function ret _libinput_measure_$words[1]; then
129				_message "unknown feature: $words[1]"
130			fi
131			;;
132	esac
133	return ret
134}
135
136(( $+functions[_libinput_measure_fuzz] )) || _libinput_measure_fuzz()
137{
138	_arguments \
139		'--help[Show help message and exit]' \
140		':device:_files -W /dev/input/ -P /dev/input/'
141}
142
143(( $+functions[_libinput_measure_touch-size] )) || _libinput_measure_touch-size()
144{
145	_arguments \
146		'--help[Show help message and exit]' \
147		'--touch-threshold=[Assume a touch pressure threshold of "down:up"]' \
148		'--palm-threshold=[Assume a palm threshold of N]' \
149		':device:_files -W /dev/input/ -P /dev/input/'
150}
151
152(( $+functions[_libinput_measure_touchpad-pressure] )) || _libinput_measure_touchpad-pressure()
153{
154	_arguments \
155		'--help[Show help message and exit]' \
156		'--touch-threshold=[Assume a touch pressure threshold of "down:up"]' \
157		'--palm-threshold=[Assume a palm threshold of N]' \
158		':device:_files -W /dev/input/ -P /dev/input/'
159}
160
161(( $+functions[_libinput_measure_touchpad-tap] )) || _libinput_measure_touchpad-tap()
162{
163	_arguments \
164		'--help[Show help message and exit]' \
165		'--format=dat[Specify the data format to be printed. The default is "summary"]'
166		':device:_files -W /dev/input/ -P /dev/input/'
167}
168
169(( $+functions[_libinput_analyze_per-slot-delta] )) || _libinput_analyze_per-slot-delta()
170{
171	_arguments \
172		'--help[Show help message and exit]' \
173		':recording:_files'
174}
175
176(( $+functions[_libinput_analyze_touch-down-state] )) || _libinput_analyze_touch-down-state()
177{
178	_arguments \
179		'--help[Show help message and exit]' \
180		':recording:_files'
181}
182
183(( $+functions[_libinput_analyze_recording] )) || _libinput_analyze_recording()
184{
185	_arguments \
186		'--help[Show help message and exit]' \
187		':recording:_files'
188}
189
190(( $+functions[_libinput_analyze] )) || _libinput_analyze()
191{
192	local curcontext=$curcontext state line ret=1
193	local features
194	features=(
195		"per-slot-delta:analyze relative movement per touch per slot"
196		"recording:analyze a recording by printing a pretty table"
197		"touch-down-state:analyze a recording for logical touch down states"
198	)
199
200	_arguments -C \
201		'--help[Print help and exit]' \
202		':feature:->feature' \
203		'*:: :->option-or-argument'
204
205	case $state in
206		(feature)
207			_describe -t features 'feature' features
208			;;
209		(option-or-argument)
210			curcontext=${curcontext%:*:*}:libinput-analyze-$words[1]:
211			if ! _call_function ret _libinput_analyze_$words[1]; then
212				_message "unknown feature: $words[1]"
213			fi
214			;;
215	esac
216	return ret
217}
218
219(( $+functions[_libinput_record] )) || _libinput_record()
220{
221	_arguments \
222		'--help[Show help message and exit]' \
223		'--all[Record all /dev/input/event* devices available on the system]' \
224		'--autorestart=[Terminate the current recording after s seconds of device inactivity]' \
225		{-o+,--output=}'[Specify the output file to use]:file:_files -g "*.yml"' \
226		'--multiple[Record multiple devices at once]' \
227		'--show-keycodes[Show keycodes as-is in the recording]' \
228		'--with-libinput[Record libinput events alongside device events]' \
229		'--with-hidraw[Record hidraw events alongside device events]' \
230		'*::device:_files -W /dev/input/ -P /dev/input/'
231}
232
233(( $+functions[_libinput_replay] )) || _libinput_replay()
234{
235	_arguments \
236		'--help[Show help message and exit]' \
237		':recording:_files'
238}
239
240_libinput()
241{
242	local curcontext=$curcontext state line ret=1
243
244	_arguments -C \
245		{-h,--help}'[Show help message and exit]' \
246		'--version[Show version information and exit]' \
247		':command:->command' \
248		'*:: :->option-or-argument' && return
249
250	case $state in
251		(command)
252			_libinput_commands && ret=0
253			;;
254		(option-or-argument)
255			curcontext=${curcontext%:*:*}:libinput-$words[1]:
256			if ! _call_function ret _libinput_$words[1]; then
257				_message "unknown libinput command: $words[1]"
258			fi
259			;;
260	esac
261	return ret
262}
263
264_libinput
265