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] )) || _libinput_analyze() 167{ 168 local curcontext=$curcontext state line ret=1 169 local features 170 features=( 171 "per-slot-delta:analyze relative movement per touch per slot" 172 ) 173 174 _arguments -C \ 175 '--help[Print help and exit]' \ 176 ':feature:->feature' \ 177 '*:: :->option-or-argument' 178 179 case $state in 180 (feature) 181 _describe -t features 'feature' features 182 ;; 183 (option-or-argument) 184 curcontext=${curcontext%:*:*}:libinput-analyze-$words[1]: 185 if ! _call_function ret _libinput_analyze_$words[1]; then 186 _message "unknown feature: $words[1]" 187 fi 188 ;; 189 esac 190 return ret 191} 192 193(( $+functions[_libinput_record] )) || _libinput_record() 194{ 195 _arguments \ 196 '--help[Show help message and exit]' \ 197 '--all[Record all /dev/input/event* devices available on the system]' \ 198 '--autorestart=[Terminate the current recording after s seconds of device inactivity]' \ 199 {-o+,--output=}'[Speficy the output file to use]:file:_files -g "*.yml"' \ 200 '--multiple[Record multiple devices at once]' \ 201 '--show-keycodes[Show keycodes as-is in the recording]' \ 202 '--with-libinput[Record libinput events alongside device events]' \ 203 '*::device:_files -W /dev/input/ -P /dev/input/' 204} 205 206(( $+functions[_libinput_replay] )) || _libinput_replay() 207{ 208 _arguments \ 209 '--help[Show help message and exit]' \ 210 ':recording:_files' 211} 212 213_libinput() 214{ 215 local curcontext=$curcontext state line ret=1 216 217 _arguments -C \ 218 {-h,--help}'[Show help message and exit]' \ 219 '--version[Show version information and exit]' \ 220 ':command:->command' \ 221 '*:: :->option-or-argument' && return 222 223 case $state in 224 (command) 225 _libinput_commands && ret=0 226 ;; 227 (option-or-argument) 228 curcontext=${curcontext%:*:*}:libinput-$words[1]: 229 if ! _call_function ret _libinput_$words[1]; then 230 _message "unknown libinput command: $words[1]" 231 fi 232 ;; 233 esac 234 return ret 235} 236 237_libinput 238