[4145] | 1 | # |
---|
| 2 | # /etc/bash_completion.d/roaraudio |
---|
| 3 | # |
---|
| 4 | # Bash completion function for the RoarAudio. |
---|
| 5 | # http://roaraudio.keep-cool.org/ |
---|
| 6 | # |
---|
| 7 | # Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org> |
---|
| 8 | # -- |
---|
| 9 | # |
---|
| 10 | |
---|
| 11 | # Tools supported completly: |
---|
| 12 | #roarctl |
---|
| 13 | #roard |
---|
| 14 | #roarvumeter |
---|
| 15 | #roarcat |
---|
| 16 | #roarmon |
---|
| 17 | #roarinterconnect |
---|
| 18 | #roarcatplay |
---|
| 19 | #roarradio |
---|
| 20 | #roarvorbis |
---|
| 21 | #roarbidir |
---|
| 22 | #roarphone |
---|
| 23 | #roarcatvio |
---|
| 24 | #roarcatpassfh |
---|
| 25 | #roarcatsendfile |
---|
| 26 | #roarcatad |
---|
| 27 | #roarcat2sock |
---|
| 28 | #roartypes |
---|
| 29 | #roarsocktypes |
---|
| 30 | |
---|
| 31 | # Tools supported partly: |
---|
| 32 | #roarify |
---|
| 33 | |
---|
| 34 | # Tools not supported at all: |
---|
| 35 | #roarfilt |
---|
| 36 | #roarfish |
---|
| 37 | #roarlight |
---|
| 38 | #roarshout |
---|
| 39 | #roarsin |
---|
| 40 | |
---|
| 41 | # Tools not supported at all and unimportent: |
---|
| 42 | #roarfctest |
---|
| 43 | #roarsockconnect |
---|
| 44 | |
---|
| 45 | # Unsupported devel tools: |
---|
| 46 | #roar-config |
---|
| 47 | |
---|
| 48 | # The rest: |
---|
| 49 | #roarmonhttp |
---|
| 50 | |
---|
| 51 | _roar_no_opts() { |
---|
| 52 | COMPREPLY=() |
---|
| 53 | } |
---|
| 54 | complete -F _roar_no_opts roarsocktypes roartypes |
---|
| 55 | |
---|
| 56 | _roar_server() { |
---|
| 57 | COMPREPLY=( $(_roar_server_exec "$1") ) |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | _roar_server_exec() { |
---|
| 61 | local cur link words nodes stdsocks x11sock |
---|
| 62 | cur="$1" |
---|
| 63 | link=$(readlink /etc/roarserver 2> /dev/null) |
---|
| 64 | |
---|
| 65 | nodes=$(grep '^\(node\|executor\)' /etc/decnet.conf 2> /dev/null | sed 's/^.*\tname\t\t*//; s/\t.*$//; s/$/::/') |
---|
| 66 | |
---|
| 67 | stdsocks="/tmp/roar $HOME/.roar localhost 0.0"; |
---|
| 68 | |
---|
| 69 | x11sock=$(xprop -root 2>/dev/null | grep '^ROAR_SERVER(STRING) = ' | sed 's/^[^"]*"//; s/"$//') |
---|
| 70 | |
---|
| 71 | words="$link $nodes $stdsocks $x11sock +slp +fork" |
---|
| 72 | |
---|
| 73 | compgen -A hostname $cur |
---|
| 74 | compgen -W "$words" $cur |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | _roar_jumbo_mtu() { |
---|
| 78 | COMPREPLY=($(compgen -W "750 1000 1100 1200 1300" -- "${COMP_WORDS[COMP_CWORD]}")) |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | _roar_rate() { |
---|
| 82 | local cur |
---|
| 83 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 84 | COMPREPLY=($(compgen -W "8000 16000 32000 11025 22050 44100 48000 96000" -- ${cur})) |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | _roar_bits() { |
---|
| 88 | local cur |
---|
| 89 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 90 | COMPREPLY=($(compgen -W "8 16 24 32" -- ${cur})) |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | _roar_channels() { |
---|
| 94 | local cur |
---|
| 95 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 96 | COMPREPLY=($(compgen -W "1 2 3 4 5 6 7 8 9" -- ${cur})) |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | _roar_codec() { |
---|
| 100 | local cur |
---|
| 101 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 102 | words=$(roard --list-cf | tail -n +4 | sed 's/^ *//; s/ .*$//') |
---|
| 103 | COMPREPLY=($(compgen -W "${words} default pcm" -- ${cur})) |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | _roar_flag() { |
---|
| 107 | local cur |
---|
| 108 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 109 | COMPREPLY=($(compgen -W "meta primary sync cleanmeta hwmixer pause mute mmap antiecho recsource passmixer virtual prethru immutable enhance" -- ${cur})) |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | _roar_dir() { |
---|
| 113 | local cur |
---|
| 114 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 115 | COMPREPLY=($(compgen -W "play record monitor filter output mixing meta bidir thru bridge midi_in midi_out light_in light_out raw_in raw_out complex_in complex_out rdtcs_in rdtcs_out" -- ${cur})) |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | _roar_metatype() { |
---|
| 119 | local cur |
---|
| 120 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 121 | COMPREPLY=($(compgen -W "none title album author autor artist version date license tracknumber organization description genre location contact streamurl homepage thumbnail length comment other filename fileurl server duration www woaf encoder encodedby year discid rpg_track_peak rpg_track_gain rpg_album_peak rpg_album_gain hash signalinfo audioinfo offset performer copyright" -- ${cur})) |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | _roar_baseopts() { |
---|
| 125 | case "$1" in |
---|
| 126 | '--rate') |
---|
| 127 | _roar_rate |
---|
| 128 | return 0 |
---|
| 129 | ;; |
---|
| 130 | '--bits') |
---|
| 131 | _roar_bits |
---|
| 132 | return 0 |
---|
| 133 | ;; |
---|
| 134 | '--chans') |
---|
| 135 | _roar_channels |
---|
| 136 | return 0 |
---|
| 137 | ;; |
---|
| 138 | '--server') |
---|
| 139 | _roar_server "${COMP_WORDS[COMP_CWORD]}" |
---|
| 140 | return 0 |
---|
| 141 | ;; |
---|
| 142 | *) |
---|
| 143 | ;; |
---|
| 144 | esac |
---|
| 145 | |
---|
| 146 | return 77 |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | _roar_basecodec() { |
---|
| 150 | case "$1" in |
---|
| 151 | '--codec') |
---|
| 152 | _roar_codec |
---|
| 153 | return 0 |
---|
| 154 | ;; |
---|
| 155 | *) |
---|
| 156 | ;; |
---|
| 157 | esac |
---|
| 158 | |
---|
| 159 | return 77 |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | _roar_baseclients() { |
---|
| 164 | local cur prev opts dirs |
---|
| 165 | COMPREPLY=() |
---|
| 166 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 167 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 168 | |
---|
| 169 | dirs="--wave --midi --light --raw --complex --rdtcs" |
---|
| 170 | opts="$dirs --server --rate -R --bits -B --chans -C --codec --rel-id --help" |
---|
| 171 | |
---|
| 172 | [ "${COMP_WORDS[0]}" = "roarmon" ] && opts="$opts --prethru" |
---|
| 173 | |
---|
| 174 | _roar_baseopts "$prev" && return 0; |
---|
| 175 | _roar_basecodec "$prev" && return 0; |
---|
| 176 | |
---|
| 177 | case "${prev}" in |
---|
| 178 | '-R') |
---|
| 179 | _roar_rate |
---|
| 180 | return 0 |
---|
| 181 | ;; |
---|
| 182 | '-B') |
---|
| 183 | _roar_bits |
---|
| 184 | return 0 |
---|
| 185 | ;; |
---|
| 186 | '-C') |
---|
| 187 | _roar_channels |
---|
| 188 | return 0 |
---|
| 189 | ;; |
---|
| 190 | *) |
---|
| 191 | ;; |
---|
| 192 | esac |
---|
| 193 | |
---|
| 194 | _filedir |
---|
| 195 | COMPREPLY=(${COMPREPLY[*]} $(compgen -W "${opts}" -- ${cur})) |
---|
| 196 | return 0 |
---|
| 197 | } |
---|
| 198 | complete -F _roar_baseclients roarcat roarmon |
---|
| 199 | |
---|
| 200 | _roarcatplay() { |
---|
| 201 | local cur prev opts |
---|
| 202 | COMPREPLY=() |
---|
| 203 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 204 | |
---|
| 205 | opts="--server --simple --passive --background --verbose --help" |
---|
| 206 | |
---|
| 207 | case "${COMP_WORDS[COMP_CWORD-1]}" in |
---|
| 208 | '--server') |
---|
| 209 | _roar_server "$cur" |
---|
| 210 | return 0 |
---|
| 211 | ;; |
---|
| 212 | *) |
---|
| 213 | ;; |
---|
| 214 | esac |
---|
| 215 | |
---|
| 216 | _filedir |
---|
| 217 | COMPREPLY=(${COMPREPLY[*]} $(compgen -W "${opts}" -- ${cur})) |
---|
| 218 | return 0 |
---|
| 219 | } |
---|
| 220 | complete -F _roarcatplay roarcatplay |
---|
| 221 | |
---|
| 222 | _roarvumeter() { |
---|
| 223 | local cur prev opts |
---|
| 224 | COMPREPLY=() |
---|
| 225 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 226 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 227 | |
---|
| 228 | opts="--server --rate --bits --chans --samples --pc --db --beat --lowpass --help" |
---|
| 229 | |
---|
| 230 | _roar_baseopts "$prev" && return 0; |
---|
| 231 | |
---|
| 232 | case "${prev}" in |
---|
| 233 | '--samples') |
---|
| 234 | COMPREPLY=($(compgen -W "5000 50000" -- ${cur})) |
---|
| 235 | return 0 |
---|
| 236 | ;; |
---|
| 237 | '--lowpass') |
---|
| 238 | COMPREPLY=($(compgen -W "100 200 300 400 500" -- ${cur})) |
---|
| 239 | return 0 |
---|
| 240 | ;; |
---|
| 241 | *) |
---|
| 242 | ;; |
---|
| 243 | esac |
---|
| 244 | |
---|
| 245 | COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
---|
| 246 | return 0 |
---|
| 247 | } |
---|
| 248 | complete -F _roarvumeter roarvumeter |
---|
| 249 | |
---|
| 250 | _roarradio() { |
---|
| 251 | local cur prev opts |
---|
| 252 | COMPREPLY=() |
---|
| 253 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 254 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 255 | |
---|
| 256 | opts="--server --rate --bits --chans --codec --help" |
---|
| 257 | |
---|
| 258 | _roar_baseopts "$prev" && return 0; |
---|
| 259 | _roar_basecodec "$prev" && return 0; |
---|
| 260 | |
---|
| 261 | COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
---|
| 262 | return 0 |
---|
| 263 | } |
---|
| 264 | complete -F _roarradio roarradio |
---|
| 265 | |
---|
| 266 | _roarvorbis() { |
---|
| 267 | local cur prev opts |
---|
| 268 | COMPREPLY=() |
---|
| 269 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 270 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 271 | |
---|
| 272 | opts="--server --vclt-out --help" |
---|
| 273 | |
---|
| 274 | case "${prev}" in |
---|
| 275 | '--vclt-out') |
---|
| 276 | _filedir |
---|
| 277 | return 0 |
---|
| 278 | ;; |
---|
| 279 | '--server') |
---|
| 280 | _roar_server "$cur" |
---|
| 281 | return 0 |
---|
| 282 | ;; |
---|
| 283 | *) |
---|
| 284 | ;; |
---|
| 285 | esac |
---|
| 286 | |
---|
| 287 | COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
---|
| 288 | return 0 |
---|
| 289 | } |
---|
| 290 | complete -F _roarvorbis roarvorbis |
---|
| 291 | |
---|
| 292 | |
---|
| 293 | _roarinterconnect() { |
---|
| 294 | local cur prev opts |
---|
| 295 | COMPREPLY=() |
---|
| 296 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 297 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 298 | |
---|
| 299 | opts="--server --remote --type --rate --bits --chans --codec --help" |
---|
| 300 | |
---|
| 301 | _roar_baseopts "$prev" && return 0; |
---|
| 302 | _roar_basecodec "$prev" && return 0; |
---|
| 303 | |
---|
| 304 | case "${prev}" in |
---|
| 305 | '--remote') |
---|
| 306 | _roar_server "$cur" |
---|
| 307 | return 0 |
---|
| 308 | ;; |
---|
| 309 | '--type') |
---|
| 310 | COMPREPLY=($(compgen -W "roar esd bidir filter transmit receive" -- ${cur})) |
---|
| 311 | return 0 |
---|
| 312 | ;; |
---|
| 313 | *) |
---|
| 314 | ;; |
---|
| 315 | esac |
---|
| 316 | |
---|
| 317 | COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
---|
| 318 | return 0 |
---|
| 319 | } |
---|
| 320 | complete -F _roarinterconnect roarinterconnect |
---|
| 321 | |
---|
| 322 | _roarbidir() { |
---|
| 323 | local cur prev opts |
---|
| 324 | COMPREPLY=() |
---|
| 325 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 326 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 327 | |
---|
| 328 | opts="--server --rate --bits --chans --codec --help" |
---|
| 329 | |
---|
| 330 | _roar_baseopts "$prev" && return 0; |
---|
| 331 | _roar_basecodec "$prev" && return 0; |
---|
| 332 | |
---|
| 333 | _filedir |
---|
| 334 | COMPREPLY=(${COMPREPLY[*]} $(compgen -W "${opts}" -- ${cur})) |
---|
| 335 | return 0 |
---|
| 336 | } |
---|
| 337 | complete -F _roarbidir roarbidir roarcatvio roarcatpassfh roarcatsendfile |
---|
| 338 | |
---|
| 339 | _roarcatad() { |
---|
| 340 | local cur prev opts |
---|
| 341 | COMPREPLY=() |
---|
| 342 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 343 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 344 | |
---|
| 345 | opts="--server --rate --bits --chans --help" |
---|
| 346 | |
---|
| 347 | _roar_baseopts "$prev" && return 0; |
---|
| 348 | |
---|
| 349 | _filedir |
---|
| 350 | COMPREPLY=(${COMPREPLY[*]} $(compgen -W "${opts}" -- ${cur})) |
---|
| 351 | return 0 |
---|
| 352 | } |
---|
| 353 | complete -F _roarcatad roarcatad roarcat2sock |
---|
| 354 | |
---|
| 355 | _roarphone() { |
---|
| 356 | local cur prev opts mopts |
---|
| 357 | COMPREPLY=() |
---|
| 358 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 359 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 360 | |
---|
| 361 | mopts="--m-rn --m-nick --m-email --m-hp --m-thumbn --m-loc --m-org" |
---|
| 362 | opts="--server --jumbo-mtu --io-flush --rate --bits --chans --afi-downmix --afi-lowpass --afi-speex-prep --afi-speex-denoise --afi-speex-agc --afi-speex-vad --codec --transcode --driver --device --antiecho --threshold --help $mopts" |
---|
| 363 | |
---|
| 364 | _roar_baseopts "$prev" && return 0; |
---|
| 365 | _roar_basecodec "$prev" && return 0; |
---|
| 366 | |
---|
| 367 | case "${prev}" in |
---|
| 368 | '--jumbo-mtu') |
---|
| 369 | _roar_jumbo_mtu |
---|
| 370 | return 0 |
---|
| 371 | ;; |
---|
| 372 | '--io-flush') |
---|
| 373 | return 0 |
---|
| 374 | ;; |
---|
| 375 | '--afi-lowpass') |
---|
| 376 | return 0 |
---|
| 377 | ;; |
---|
| 378 | '--driver') |
---|
| 379 | return 0 |
---|
| 380 | ;; |
---|
| 381 | '--device') |
---|
| 382 | _filedir |
---|
| 383 | return 0 |
---|
| 384 | ;; |
---|
| 385 | '--antiecho') |
---|
| 386 | COMPREPLY=($(compgen -W "none simple speex roard" -- ${cur})) |
---|
| 387 | return 0 |
---|
| 388 | ;; |
---|
| 389 | '--threshold') |
---|
| 390 | return 0 |
---|
| 391 | ;; |
---|
| 392 | '--m-rn') |
---|
| 393 | return 0 |
---|
| 394 | ;; |
---|
| 395 | '--m-nick') |
---|
| 396 | COMPREPLY=($(compgen -W "$USER" -- ${cur})) |
---|
| 397 | return 0 |
---|
| 398 | ;; |
---|
| 399 | '--m-email') |
---|
| 400 | COMPREPLY=($(compgen -W "$USER@$HOSTNAME" -- ${cur})) |
---|
| 401 | return 0 |
---|
| 402 | ;; |
---|
| 403 | '--m-hp') |
---|
| 404 | return 0 |
---|
| 405 | ;; |
---|
| 406 | '--m-thumbn') |
---|
| 407 | return 0 |
---|
| 408 | ;; |
---|
| 409 | '--m-loc') |
---|
| 410 | return 0 |
---|
| 411 | ;; |
---|
| 412 | '--m-org') |
---|
| 413 | return 0 |
---|
| 414 | ;; |
---|
| 415 | *) |
---|
| 416 | ;; |
---|
| 417 | esac |
---|
| 418 | |
---|
| 419 | COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
---|
| 420 | return 0 |
---|
| 421 | } |
---|
| 422 | complete -F _roarphone roarphone |
---|
| 423 | |
---|
| 424 | _roarctl() { |
---|
| 425 | local cur prev pprev opts cmds |
---|
| 426 | COMPREPLY=() |
---|
| 427 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 428 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 429 | |
---|
| 430 | pprev="--NX-COMMAND--" |
---|
| 431 | if [ "$COMP_CWORD" -ge 2 ] |
---|
| 432 | then |
---|
| 433 | pprev="${COMP_WORDS[COMP_CWORD-2]}" |
---|
| 434 | fi |
---|
| 435 | |
---|
| 436 | if [ "$COMP_CWORD" -ge 3 ] |
---|
| 437 | then |
---|
| 438 | if [ "${COMP_WORDS[COMP_CWORD-3]}" = 'newvirtual' ] |
---|
| 439 | then |
---|
| 440 | _roar_codec |
---|
| 441 | return 0 |
---|
| 442 | fi |
---|
| 443 | if [ "$COMP_CWORD" -ge 4 ] |
---|
| 444 | then |
---|
| 445 | if [ "${COMP_WORDS[COMP_CWORD-4]}" = 'newvirtual' ] |
---|
| 446 | then |
---|
| 447 | _roar_rate |
---|
| 448 | return 0 |
---|
| 449 | fi |
---|
| 450 | if [ "$COMP_CWORD" -ge 5 ] |
---|
| 451 | then |
---|
| 452 | if [ "${COMP_WORDS[COMP_CWORD-5]}" = 'newvirtual' ] |
---|
| 453 | then |
---|
| 454 | _roar_bits |
---|
| 455 | return 0 |
---|
| 456 | fi |
---|
| 457 | if [ "$COMP_CWORD" -ge 6 ] |
---|
| 458 | then |
---|
| 459 | if [ "${COMP_WORDS[COMP_CWORD-6]}" = 'newvirtual' ] |
---|
| 460 | then |
---|
| 461 | _roar_channels |
---|
| 462 | return 0 |
---|
| 463 | fi |
---|
| 464 | fi |
---|
| 465 | fi |
---|
| 466 | fi |
---|
| 467 | fi |
---|
| 468 | |
---|
| 469 | opts="--server --help --verbose -v --list-aiprofiles" |
---|
| 470 | cmds="help sleep ping whoami listaiprofiles aiprofileget standby off resume on standbymode exit terminate volume flag unflag kick newvirtual metaget metasave metaload serveroinfo listclients liststreams allinfo" |
---|
| 471 | |
---|
| 472 | case "${pprev}" in |
---|
| 473 | 'volume') |
---|
| 474 | COMPREPLY=($(compgen -W "mono stereo 1 2 3 4 5 6 7 8 9" -- ${cur})) |
---|
| 475 | return 0 |
---|
| 476 | ;; |
---|
| 477 | 'flag') |
---|
| 478 | _roar_flag |
---|
| 479 | return 0 |
---|
| 480 | ;; |
---|
| 481 | 'unflag') |
---|
| 482 | _roar_flag |
---|
| 483 | return 0 |
---|
| 484 | ;; |
---|
| 485 | 'kick') |
---|
| 486 | return 0 |
---|
| 487 | ;; |
---|
| 488 | 'newvirtual') |
---|
| 489 | _roar_dir |
---|
| 490 | return 0 |
---|
| 491 | ;; |
---|
| 492 | 'metaget') |
---|
| 493 | _roar_metatype |
---|
| 494 | return 0 |
---|
| 495 | ;; |
---|
| 496 | 'metasave') |
---|
| 497 | _filedir |
---|
| 498 | return 0 |
---|
| 499 | ;; |
---|
| 500 | 'metaload') |
---|
| 501 | _filedir |
---|
| 502 | return 0 |
---|
| 503 | ;; |
---|
| 504 | *) |
---|
| 505 | ;; |
---|
| 506 | esac |
---|
| 507 | |
---|
| 508 | case "${prev}" in |
---|
| 509 | '--server') |
---|
| 510 | _roar_server "$cur" |
---|
| 511 | return 0 |
---|
| 512 | ;; |
---|
| 513 | 'sleep') |
---|
| 514 | return 0 |
---|
| 515 | ;; |
---|
| 516 | 'ping') |
---|
| 517 | return 0 |
---|
| 518 | ;; |
---|
| 519 | 'aiprofileget') |
---|
| 520 | COMPREPLY=($(compgen -W "$(roarctl --list-aiprofiles | grep '^Profile Name *: *' | sed 's/^.*: *//')" -- ${cur})) |
---|
| 521 | return 0 |
---|
| 522 | ;; |
---|
| 523 | 'volume') |
---|
| 524 | return 0 |
---|
| 525 | ;; |
---|
| 526 | 'flag') |
---|
| 527 | return 0 |
---|
| 528 | ;; |
---|
| 529 | 'unflag') |
---|
| 530 | return 0 |
---|
| 531 | ;; |
---|
| 532 | 'kick') |
---|
| 533 | COMPREPLY=($(compgen -W "client stream sample source" -- ${cur})) |
---|
| 534 | return 0 |
---|
| 535 | ;; |
---|
| 536 | 'newvirtual') |
---|
| 537 | return 0 |
---|
| 538 | ;; |
---|
| 539 | 'metaget') |
---|
| 540 | return 0 |
---|
| 541 | ;; |
---|
| 542 | 'metasave') |
---|
| 543 | return 0 |
---|
| 544 | ;; |
---|
| 545 | 'metaload') |
---|
| 546 | return 0 |
---|
| 547 | ;; |
---|
| 548 | *) |
---|
| 549 | ;; |
---|
| 550 | esac |
---|
| 551 | |
---|
| 552 | COMPREPLY=($(compgen -W "${opts} ${cmds}" -- ${cur})) |
---|
| 553 | return 0 |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | complete -F _roarctl roarctl |
---|
| 557 | |
---|
| 558 | _roard() |
---|
| 559 | { |
---|
| 560 | local cur prev opts |
---|
| 561 | local opts_misc opts_audio opts_stream opts_driver opts_output opts_source opts_cf opts_midi opts_rdtcs opts_server opts_plugins |
---|
| 562 | COMPREPLY=() |
---|
| 563 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 564 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 565 | |
---|
| 566 | # |
---|
| 567 | # The basic options we'll complete. |
---|
| 568 | # |
---|
| 569 | opts_misc="--daemon --verbose --terminate --start --restart --stop --shutdown --realtime --chroot --setgid --setuid --sysclocksync --location --pidfile" |
---|
| 570 | opts_audio="--rate --bits --chans -R -B -C --aiprofile" |
---|
| 571 | opts_stream="--stream-flags" |
---|
| 572 | opts_driver="--driver --device -d -D --list-driver" |
---|
| 573 | opts_output="--odriver --odevice -o -O -oO -oP -oN" |
---|
| 574 | opts_source="--source -s -S -sO -sP -sN --list-sources" |
---|
| 575 | opts_cf="--list-cf" |
---|
| 576 | opts_midi="--midi-no-console --midi-console-enable --midi-console --ssynth-enable --ssynth-disable" |
---|
| 577 | opts_light="--light-channels" |
---|
| 578 | opts_rdtcs="--rds-pi --rds-ps --rds-pty --rds-tp --rds-ct" |
---|
| 579 | opts_server="--tcp --unix --decnet -t -u -n -4 -6 -64 --port -p --bind -b --sock --proto --proto-dir --proto-rate --proto-bits --proto-codec --proto-chans --list-proto --list-profiles --proto-profile --proto-aiprofile --new-sock --slp --x11 --jumbo-mtu -G -U --no-listen --client-fh --close-fh --standby --auto-standby" |
---|
| 580 | opts_plugins="--plugin-load" |
---|
| 581 | |
---|
| 582 | opts="$opts_misc $opts_audio $opts_stream $opts_driver $opts_output $opts_source $opts_cf $opts_midi $opts_light $opts_rdtcs $opts_server $opts_plugins --help" |
---|
| 583 | |
---|
| 584 | |
---|
| 585 | # |
---|
| 586 | # Complete the arguments to some of the basic commands. |
---|
| 587 | # |
---|
| 588 | case "${prev}" in |
---|
| 589 | # DIR/FILE: |
---|
| 590 | '--chroot') |
---|
| 591 | _filedir -d |
---|
| 592 | return 0 |
---|
| 593 | ;; |
---|
| 594 | '--pidfile') |
---|
| 595 | _filedir |
---|
| 596 | return 0 |
---|
| 597 | ;; |
---|
| 598 | '--plugin-load') |
---|
| 599 | _filedir |
---|
| 600 | return 0 |
---|
| 601 | ;; |
---|
| 602 | # String: |
---|
| 603 | '--location') |
---|
| 604 | return 0 |
---|
| 605 | ;; |
---|
| 606 | # Int: |
---|
| 607 | '--rate'|'-R'|'--proto-rate') |
---|
| 608 | _roar_rate |
---|
| 609 | return 0 |
---|
| 610 | ;; |
---|
| 611 | '--bits'|'-B'|'--proto-bits') |
---|
| 612 | _roar_bits |
---|
| 613 | return 0 |
---|
| 614 | ;; |
---|
| 615 | '--chans'|'-C'|'--proto-chans') |
---|
| 616 | _roar_channels |
---|
| 617 | return 0 |
---|
| 618 | ;; |
---|
| 619 | '--light-channels') |
---|
| 620 | COMPREPLY=($(compgen -W "512 1024 1536 2048 4096 8192" -- ${cur})) |
---|
| 621 | return 0 |
---|
| 622 | ;; |
---|
| 623 | '--jumbo-mtu') |
---|
| 624 | _roar_jumbo_mtu |
---|
| 625 | return 0 |
---|
| 626 | ;; |
---|
| 627 | # C=F: |
---|
| 628 | '--stream-flags') |
---|
| 629 | return 0 |
---|
| 630 | ;; |
---|
| 631 | # driver: |
---|
| 632 | '--driver'|'-d') |
---|
| 633 | words=$(roard --list-driver | tail -n +3 | sed 's/^ *//; s/ .*$//') |
---|
| 634 | COMPREPLY=($(compgen -W "${words}" -- ${cur})) |
---|
| 635 | return 0 |
---|
| 636 | ;; |
---|
| 637 | '--odriver'|'-o') |
---|
| 638 | words=$(roard --list-driver | tail -n +3 | sed 's/^ *//; s/ .*$//') |
---|
| 639 | COMPREPLY=($(compgen -W "${words}" -- ${cur})) |
---|
| 640 | return 0 |
---|
| 641 | ;; |
---|
| 642 | # Source: |
---|
| 643 | '--source'|'-s') |
---|
| 644 | words=$(roard --list-sources | tail -n +3 | sed 's/^ *//; s/ .*$//') |
---|
| 645 | COMPREPLY=($(compgen -W "${words}" -- ${cur})) |
---|
| 646 | return 0 |
---|
| 647 | ;; |
---|
| 648 | # Device: |
---|
| 649 | # FIXME: add support for non file devices |
---|
| 650 | '--device'|'-D') |
---|
| 651 | _filedir |
---|
| 652 | return 0 |
---|
| 653 | ;; |
---|
| 654 | '--odevice'|'-O') |
---|
| 655 | _filedir |
---|
| 656 | return 0 |
---|
| 657 | ;; |
---|
| 658 | '-S') |
---|
| 659 | _filedir |
---|
| 660 | return 0 |
---|
| 661 | ;; |
---|
| 662 | '--midi-console') |
---|
| 663 | _filedir |
---|
| 664 | return 0 |
---|
| 665 | ;; |
---|
| 666 | # Options: |
---|
| 667 | '-dO') |
---|
| 668 | return 0 |
---|
| 669 | ;; |
---|
| 670 | '-oO') |
---|
| 671 | return 0 |
---|
| 672 | ;; |
---|
| 673 | '-sO') |
---|
| 674 | return 0 |
---|
| 675 | ;; |
---|
| 676 | # RDS: |
---|
| 677 | '--rds-pi') |
---|
| 678 | return 0 |
---|
| 679 | ;; |
---|
| 680 | '--rds-ps') |
---|
| 681 | return 0 |
---|
| 682 | ;; |
---|
| 683 | '--rds-pty') |
---|
| 684 | return 0 |
---|
| 685 | ;; |
---|
| 686 | # Port: |
---|
| 687 | '--port'|'-p') |
---|
| 688 | COMPREPLY=( $( compgen -s $cur ) ) |
---|
| 689 | return 0 |
---|
| 690 | ;; |
---|
| 691 | # Host/Node/File: |
---|
| 692 | '--bind'|'-b') |
---|
| 693 | COMPREPLY=( $( compgen -A hostname $cur ) "0.0.0.0" ) |
---|
| 694 | return 0 |
---|
| 695 | ;; |
---|
| 696 | '--sock') |
---|
| 697 | _filedir |
---|
| 698 | return 0 |
---|
| 699 | ;; |
---|
| 700 | # Proto: |
---|
| 701 | '--proto') |
---|
| 702 | words=$(roard --list-proto | tail -n +3 | sed 's/^ *//; s/ .*$//') |
---|
| 703 | COMPREPLY=($(compgen -W "${words}" -- ${cur})) |
---|
| 704 | return 0 |
---|
| 705 | ;; |
---|
| 706 | '--proto-profile') |
---|
| 707 | words=$(roard --list-profiles | tail -n +3 | sed 's/^ *//; s/ .*$//') |
---|
| 708 | COMPREPLY=($(compgen -W "${words}" -- ${cur})) |
---|
| 709 | return 0 |
---|
| 710 | ;; |
---|
| 711 | '--proto-aiprofile'|'--aiprofile') |
---|
| 712 | words=$(roarctl --list-aiprofiles | grep '^Profile Name' | sed 's/^.*: *//') |
---|
| 713 | COMPREPLY=($(compgen -W "${words}" -- ${cur})) |
---|
| 714 | return 0 |
---|
| 715 | ;; |
---|
| 716 | # FH: |
---|
| 717 | '--client-fh') |
---|
| 718 | words=$(command ls /proc/self/fd 2> /dev/null) |
---|
| 719 | COMPREPLY=($(compgen -W "${words}" -- ${cur})) |
---|
| 720 | return 0 |
---|
| 721 | ;; |
---|
| 722 | '--close-fh') |
---|
| 723 | words=$(command ls /proc/self/fd 2> /dev/null) |
---|
| 724 | COMPREPLY=($(compgen -W "${words}" -- ${cur})) |
---|
| 725 | return 0 |
---|
| 726 | ;; |
---|
| 727 | # Dir: |
---|
| 728 | '--proto-dir') |
---|
| 729 | _roar_dir |
---|
| 730 | return 0; |
---|
| 731 | ;; |
---|
| 732 | # Codec: |
---|
| 733 | '--proto-codec') |
---|
| 734 | _roar_codec |
---|
| 735 | return 0; |
---|
| 736 | ;; |
---|
| 737 | |
---|
| 738 | *) |
---|
| 739 | ;; |
---|
| 740 | esac |
---|
| 741 | |
---|
| 742 | COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
---|
| 743 | return 0 |
---|
| 744 | } |
---|
| 745 | complete -F _roard roard |
---|
| 746 | |
---|
| 747 | complete -F _command roarify |
---|
| 748 | |
---|
| 749 | # vim:ft=sh: |
---|
| 750 | |
---|
| 751 | #ll |
---|