| 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-area=[Set the desired area as "x1/y1 x2/y2" (within \[0.0, 1.0\]) ]' \ |
| 53 |
'--set-calibration=[Set the first 6 elements of the 3x3 calibration matrix ("1.0 0.0 0.0 0.0 1.0 0.0")]' \ |
| 54 |
'--set-click-method=[Set the desired click method]:click-method:(none clickfinger buttonareas)' \ |
| 55 |
'--set-clickfinger-map=[Set button mapping for clickfinger]:tap-map:(( \ |
| 56 |
lrm\:2-fingers\ right-click\ /\ 3-fingers\ middle-click \ |
| 57 |
lmr\:2-fingers\ middle-click\ /\ 3-fingers\ right-click \ |
| 58 |
))' \ |
| 59 |
'--set-eraser-button-button=[Set button mapping for the eraser button]:eraser-button:(BTN_STYLUS BTN_STYLUS2 BTN_STYLUS3)' \ |
| 60 |
'--set-eraser-button-mode=[Set the eraser button mode]:eraser-mode:(default button)' \ |
| 61 |
'--set-pressure-range=[Set the tablet tool pressure range (within range \[0.0, 1.0\])]' \ |
| 62 |
'--set-profile=[Set pointer acceleration profile]:accel-profile:(adaptive flat custom)' \ |
| 63 |
'--set-rotation-angle=[Set the rotation angle in degrees]' \ |
| 64 |
'--set-scroll-button=[Set the button to the given button code]' \ |
| 65 |
'--set-scroll-method=[Set the desired scroll method]:scroll-method:(none twofinger edge button)' \ |
| 66 |
'--set-speed=[Set pointer acceleration speed (within range \[-1, 1\])]' \ |
| 67 |
'--set-tap-map=[Set button mapping for tapping]:tap-map:(( \ |
| 68 |
lrm\:2-fingers\ right-click\ /\ 3-fingers\ middle-click \ |
| 69 |
lmr\:2-fingers\ middle-click\ /\ 3-fingers\ right-click \ |
| 70 |
))' \ |
| 71 |
+ '(custom pointer acceleration)' \ |
| 72 |
'--set-custom-points=[Set n points defining a custom acceleration function]' \ |
| 73 |
'--set-custom-step=[Set the distance along the x axis between the custom points]' \ |
| 74 |
'--set-custom-type=[Set the type of the acceleration function]:custom-type:(fallback motion scroll)' \ |
| 75 |
+ '(drag)' \ |
| 76 |
'--enable-drag[Enable tap-and-drag]' \ |
| 77 |
'--disable-drag[Disable tap-and-drag]' \ |
| 78 |
+ '(drag-lock)' \ |
| 79 |
'--enable-drag-lock[Enable drag-lock]' \ |
| 80 |
'--disable-drag-lock[Disable drag-lock]' \ |
| 81 |
+ '(dwt)' \ |
| 82 |
'--enable-dwt[Enable disable-while-typing]' \ |
| 83 |
'--disable-dwt[Disable disable-while-typing]' \ |
| 84 |
+ '(dwtp)' \ |
| 85 |
'--enable-dwtp[Enable disable-while-trackpointing]' \ |
| 86 |
'--disable-dwtp[Disable disable-while-trackpointing]' \ |
| 87 |
+ '(left-handed)' \ |
| 88 |
'--enable-left-handed[Enable left handed button configuration]' \ |
| 89 |
'--disable-left-handed[Disable left handed button configuration]' \ |
| 90 |
+ '(middlebutton)' \ |
| 91 |
'--enable-middlebutton[Enable middle button emulation]' \ |
| 92 |
'--disable-middlebutton[Disable middle button emulation]' \ |
| 93 |
+ '(natural-scrolling)' \ |
| 94 |
'--enable-natural-scrolling[Enable natural scrolling]' \ |
| 95 |
'--disable-natural-scrolling[Disable natural scrolling]' \ |
| 96 |
+ '(plugins)' \ |
| 97 |
'--enable-plugins[Enable plugins]' \ |
| 98 |
'--disable-plugins[Disable plugins]' \ |
| 99 |
+ '(tap-to-click)' \ |
| 100 |
'--enable-tap[Enable tap-to-click]' \ |
| 101 |
'--disable-tap[Disable tap-to-click]' |
| 102 |
} |
| 103 |
|
| 104 |
(( $+functions[_libinput_debug-gui] )) || _libinput_debug-gui() |
| 105 |
{ |
| 106 |
_arguments \ |
| 107 |
'--help[Show debug-gui help and exit]' \ |
| 108 |
'--verbose[Use verbose output]' \ |
| 109 |
'--grab[Exclusively grab all opened devices]' \ |
| 110 |
'--device=[Use the given device with the path backend]:device:_files -W /dev/input/ -P /dev/input/' \ |
| 111 |
'--udev=[Listen for notifications on the given seat]:seat:_libinput_all_seats' |
| 112 |
} |
| 113 |
|
| 114 |
(( $+functions[_libinput_debug-tablet] )) || _libinput_debug-tablet() |
| 115 |
{ |
| 116 |
_arguments \ |
| 117 |
'--help[Show debug-tablet help and exit]' \ |
| 118 |
'--device=[Use the given device with the path backend]:device:_files -W /dev/input/ -P /dev/input/' \ |
| 119 |
'--udev=[Use the first tablet device on the given seat]:seat:_libinput_all_seats' |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
(( $+functions[_libinput_measure] )) || _libinput_measure() |
| 124 |
{ |
| 125 |
local curcontext=$curcontext state line ret=1 |
| 126 |
local features |
| 127 |
features=( |
| 128 |
"fuzz:Measure touch fuzz to avoid pointer jitter" |
| 129 |
"touch-size:Measure touch size and orientation" |
| 130 |
"touchpad-tap:Measure tap-to-click time" |
| 131 |
"touchpad-pressure:Measure touch pressure" |
| 132 |
) |
| 133 |
|
| 134 |
_arguments -C \ |
| 135 |
'--help[Print help and exit]' \ |
| 136 |
':feature:->feature' \ |
| 137 |
'*:: :->option-or-argument' |
| 138 |
|
| 139 |
case $state in |
| 140 |
(feature) |
| 141 |
_describe -t features 'feature' features |
| 142 |
;; |
| 143 |
(option-or-argument) |
| 144 |
curcontext=${curcontext%:*:*}:libinput-measure-$words[1]: |
| 145 |
if ! _call_function ret _libinput_measure_$words[1]; then |
| 146 |
_message "unknown feature: $words[1]" |
| 147 |
fi |
| 148 |
;; |
| 149 |
esac |
| 150 |
return ret |
| 151 |
} |
| 152 |
|
| 153 |
(( $+functions[_libinput_measure_fuzz] )) || _libinput_measure_fuzz() |
| 154 |
{ |
| 155 |
_arguments \ |
| 156 |
'--help[Show help message and exit]' \ |
| 157 |
':device:_files -W /dev/input/ -P /dev/input/' |
| 158 |
} |
| 159 |
|
| 160 |
(( $+functions[_libinput_measure_touch-size] )) || _libinput_measure_touch-size() |
| 161 |
{ |
| 162 |
_arguments \ |
| 163 |
'--help[Show help message and exit]' \ |
| 164 |
'--touch-threshold=[Assume a touch pressure threshold of "down:up"]' \ |
| 165 |
'--palm-threshold=[Assume a palm threshold of N]' \ |
| 166 |
':device:_files -W /dev/input/ -P /dev/input/' |
| 167 |
} |
| 168 |
|
| 169 |
(( $+functions[_libinput_measure_touchpad-pressure] )) || _libinput_measure_touchpad-pressure() |
| 170 |
{ |
| 171 |
_arguments \ |
| 172 |
'--help[Show help message and exit]' \ |
| 173 |
'--touch-threshold=[Assume a touch pressure threshold of "down:up"]' \ |
| 174 |
'--palm-threshold=[Assume a palm threshold of N]' \ |
| 175 |
':device:_files -W /dev/input/ -P /dev/input/' |
| 176 |
} |
| 177 |
|
| 178 |
(( $+functions[_libinput_measure_touchpad-tap] )) || _libinput_measure_touchpad-tap() |
| 179 |
{ |
| 180 |
_arguments \ |
| 181 |
'--help[Show help message and exit]' \ |
| 182 |
'--format=dat[Specify the data format to be printed. The default is "summary"]' \ |
| 183 |
':device:_files -W /dev/input/ -P /dev/input/' |
| 184 |
} |
| 185 |
|
| 186 |
(( $+functions[_libinput_analyze_per-slot-delta] )) || _libinput_analyze_per-slot-delta() |
| 187 |
{ |
| 188 |
_arguments \ |
| 189 |
'--help[Show help message and exit]' \ |
| 190 |
':recording:_files' |
| 191 |
} |
| 192 |
|
| 193 |
(( $+functions[_libinput_analyze_touch-down-state] )) || _libinput_analyze_touch-down-state() |
| 194 |
{ |
| 195 |
_arguments \ |
| 196 |
'--help[Show help message and exit]' \ |
| 197 |
':recording:_files' |
| 198 |
} |
| 199 |
|
| 200 |
(( $+functions[_libinput_analyze_recording] )) || _libinput_analyze_recording() |
| 201 |
{ |
| 202 |
_arguments \ |
| 203 |
'--help[Show help message and exit]' \ |
| 204 |
':recording:_files' |
| 205 |
} |
| 206 |
|
| 207 |
(( $+functions[_libinput_analyze] )) || _libinput_analyze() |
| 208 |
{ |
| 209 |
local curcontext=$curcontext state line ret=1 |
| 210 |
local features |
| 211 |
features=( |
| 212 |
"per-slot-delta:analyze relative movement per touch per slot" |
| 213 |
"recording:analyze a recording by printing a pretty table" |
| 214 |
"touch-down-state:analyze a recording for logical touch down states" |
| 215 |
) |
| 216 |
|
| 217 |
_arguments -C \ |
| 218 |
'--help[Print help and exit]' \ |
| 219 |
':feature:->feature' \ |
| 220 |
'*:: :->option-or-argument' |
| 221 |
|
| 222 |
case $state in |
| 223 |
(feature) |
| 224 |
_describe -t features 'feature' features |
| 225 |
;; |
| 226 |
(option-or-argument) |
| 227 |
curcontext=${curcontext%:*:*}:libinput-analyze-$words[1]: |
| 228 |
if ! _call_function ret _libinput_analyze_$words[1]; then |
| 229 |
_message "unknown feature: $words[1]" |
| 230 |
fi |
| 231 |
;; |
| 232 |
esac |
| 233 |
return ret |
| 234 |
} |
| 235 |
|
| 236 |
(( $+functions[_libinput_record] )) || _libinput_record() |
| 237 |
{ |
| 238 |
_arguments \ |
| 239 |
'--help[Show help message and exit]' \ |
| 240 |
'--all[Record all /dev/input/event* devices available on the system]' \ |
| 241 |
'--autorestart=[Terminate the current recording after s seconds of device inactivity]' \ |
| 242 |
{-o+,--output=}'[Specify the output file to use]:file:_files -g "*.yml"' \ |
| 243 |
'--multiple[Record multiple devices at once]' \ |
| 244 |
'--show-keycodes[Show keycodes as-is in the recording]' \ |
| 245 |
'--with-libinput[Record libinput events alongside device events]' \ |
| 246 |
'--with-hidraw[Record hidraw events alongside device events]' \ |
| 247 |
'*::device:_files -W /dev/input/ -P /dev/input/' |
| 248 |
} |
| 249 |
|
| 250 |
(( $+functions[_libinput_replay] )) || _libinput_replay() |
| 251 |
{ |
| 252 |
_arguments \ |
| 253 |
'--help[Show help message and exit]' \ |
| 254 |
':recording:_files' |
| 255 |
} |
| 256 |
|
| 257 |
_libinput() |
| 258 |
{ |
| 259 |
local curcontext=$curcontext state line ret=1 |
| 260 |
|
| 261 |
_arguments -C \ |
| 262 |
{-h,--help}'[Show help message and exit]' \ |
| 263 |
'--version[Show version information and exit]' \ |
| 264 |
':command:->command' \ |
| 265 |
'*:: :->option-or-argument' && return |
| 266 |
|
| 267 |
case $state in |
| 268 |
(command) |
| 269 |
_libinput_commands && ret=0 |
| 270 |
;; |
| 271 |
(option-or-argument) |
| 272 |
curcontext=${curcontext%:*:*}:libinput-$words[1]: |
| 273 |
if ! _call_function ret _libinput_$words[1]; then |
| 274 |
_message "unknown libinput command: $words[1]" |
| 275 |
fi |
| 276 |
;; |
| 277 |
esac |
| 278 |
return ret |
| 279 |
} |
| 280 |
|
| 281 |
_libinput |