1#compdef pulseaudio pactl pacmd pacat paplay parec parecord padsp pasuspender 2 3_set_remote() { 4 for (( i = 0; i < ${#words[@]}; i++ )) do 5 if [[ ${words[$i]} == -s || ${words[$i]} == --server ]]; then 6 remote="-s ${words[$i+1]}" 7 break; 8 elif [[ ${words[$i]} == --server=* ]]; then 9 remote=${words[$i]} 10 fi 11 done 12} 13 14_devices() { 15 local -a _device_list 16 local cmd _device _device_description 17 18 if [[ $service == pactl || $service == pacmd ]]; then 19 case $words[$((CURRENT - 1))] in 20 set-sink-input-*) cmd=('sink-inputs');; 21 set-sink-*) cmd=('sinks');; 22 set-default-sink) cmd=('sinks');; 23 set-default-source) cmd=('sources');; 24 set-source-output-*) cmd=('source-outputs');; 25 set-source-*) cmd=('sources');; 26 suspend-sink) cmd=('sinks');; 27 suspend-source) cmd=('sources');; 28 move-sink-input) cmd=('sink-inputs');; 29 move-source-output) cmd=('source-outputs');; 30 kill-sink-input) cmd=('sink-inputs');; 31 kill-source-output) cmd=('source-outputs');; 32 esac 33 34 case $words[$((CURRENT - 2))] in 35 move-sink-input) cmd=('sinks');; 36 move-source-output) cmd=('sources');; 37 play-sample) cmd=('sinks');; 38 esac 39 40 elif [[ $service == (pacat|paplay|parec|parecord) ]]; then 41 case $words[$((CURRENT))] in 42 --device=*) 43 if [[ $words == *(--playback|-p)[[:space:]]* || 44 $service == paplay ]]; then 45 cmd=('sinks') 46 elif [[ $words == *(--record|-r)[[:space:]]* || 47 $service == (parec|parecord) ]]; then 48 cmd=('sources') 49 else 50 cmd=('sinks' 'sources') 51 fi 52 ;; 53 --monitor-stream=*) cmd=('sink-inputs');; 54 esac 55 56 case $words[$((CURRENT - 1))] in 57 -d) 58 if [[ $words == *(--playback|-p)[[:space:]]* || 59 $service == paplay ]]; then 60 cmd=('sinks') 61 elif [[ $words == *(--record|-r)[[:space:]]* || 62 $service == (parec|parecord) ]]; then 63 cmd=('sources') 64 else 65 cmd=('sinks' 'sources') 66 fi 67 ;; 68 esac 69 70 fi 71 72 for target in $cmd; do 73 for device_info in ${(ps:\n\n:)"$(_call_program device_tag "pactl $remote list $target 2> /dev/null")"}; do 74 for line in ${(f)device_info}; do 75 if [[ $target == (sink-inputs|source-outputs) ]]; then 76 if [[ $line == (Sink*Input|Source*Output)* ]]; then 77 _device=${line#*\#} 78 elif [[ $line == *application.name* ]]; then 79 _device_description=${line#*= } 80 fi 81 82 else 83 if [[ $words[$((CURRENT - 1))] == *set-sink-formats* ]]; then 84 if [[ $line == Sink* ]]; then 85 _device=${line#*\#} 86 elif [[ $line == *Description:* ]]; then 87 _device_description=${line#*: } 88 fi 89 90 else 91 if [[ $line == *Name:* ]]; then 92 _device=${line#*: } 93 elif [[ $line == *Description:* ]]; then 94 _device_description=${line#*: } 95 fi 96 fi 97 fi 98 done 99 _device_list+=($_device:$_device_description) 100 done 101 done 102 103 _describe 'device list' _device_list 104} 105 106_profiles() { 107 local -a _profile_list 108 local _current_card _raw_profiles _profile_name _profile_description 109 110 _current_card=$words[$((CURRENT - 1))] 111 112 for card in ${(ps:\n\n:)"$(_call_program profiles_tag "pactl $remote list cards 2> /dev/null")"}; do 113 if [[ $card == *$_current_card* ]]; then 114 _raw_profiles=${card##*Profiles:} 115 _raw_profiles=${_raw_profiles%%Active Profile:*} 116 for profile in ${(f)_raw_profiles}; do 117 if [[ $profile != [[:blank:]] ]]; then 118 _profile_name=${profile%%: *} 119 _profile_name=${_profile_name//[[:blank:]]/} 120 _profile_name=${_profile_name//:/\\:} 121 _profile_description=${profile#*: } 122 _profile_list+=($_profile_name:$_profile_description) 123 fi 124 done 125 fi 126 done 127 128 _describe 'profile list' _profile_list 129} 130 131_ports() { 132 local -a _port_list 133 local _raw_ports _port_name _port_description _current_device 134 135 case $words[$((CURRENT - 2))] in 136 set-sink-port) cmd="sinks";; 137 set-source-port) cmd="sources";; 138 set-port-latency-offset) cmd="cards";; 139 esac 140 141 _current_device=$words[$((CURRENT - 1))] 142 143 for device in ${(ps:\n\n:)"$(_call_program port_tag "pactl $remote list $cmd 2> /dev/null")"}; do 144 if [[ $device == *Ports:* && $device == *$_current_device* ]]; then 145 _raw_ports=${device##*Ports:} 146 _raw_ports=${_raw_ports%%Active Port:*} 147 for line in ${(f)_raw_ports}; do 148 if [[ $line != [[:blank:]] && 149 $line != (*Part?of*|*Properties:*|*device.icon_name*) ]]; then 150 _port_name=${line%%: *} 151 _port_name=${_port_name##[[:blank:]]#} 152 _port_description=${line#*: } 153 _port_list+=($_port_name:$_port_description) 154 fi 155 done 156 fi 157 done 158 159 _describe 'port list' _port_list 160} 161 162_sample_names() { 163 local -a _sample_names 164 sample_names=(${${${(f)"$(_call_program samples_tag "pactl $remote list samples short 2> /dev/null")"}##[[:digit:]]#[[:blank:]]#}%%[[:blank:]]*}) 165 166 _wanted pactl-samples expl 'sample list' compadd $sample_names 167} 168 169_cards(){ 170 local -a _card_list 171 local _card _cad_name 172 173 for card_info in ${(ps:\n\n:)"$(_call_program card_tag "pactl $remote list cards 2> /dev/null")"}; do 174 for line in ${(f)card_info}; do 175 if [[ $line == *Name:* ]]; then 176 _card=${line#*: } 177 elif [[ $line == *alsa.long_card_name* ]]; then 178 _card_name=${line#*= \"} 179 _card_name=${_card_name%at*} 180 fi 181 done 182 _card_list+=($_card:$_card_name) 183 done 184 185 _describe 'card list' _card_list 186} 187 188_all_modules(){ 189 local -a _all_modules_list 190 for module in ${(f)"$(_call_program modules_tag "pulseaudio --dump-modules 2> /dev/null")"}; do 191 _all_modules_list+=${module%% *} 192 done 193 _describe 'module list' _all_modules_list 194} 195 196_loaded_modules(){ 197 local -a _loaded_modules_list 198 199 for module in ${(f)"$(_call_program modules_tag "pactl $remote list modules short 2> /dev/null")"}; do 200 _loaded_modules_list+=(${${(ps:\t:)module}[1]}:${${(ps:\t:)module}[2]}) 201 done 202 _describe 'module list' _loaded_modules_list 203} 204 205_resample_methods() { 206 local -a _resample_method_list 207 for method in ${(f)"$(_call_program modules_tag "pulseaudio --dump-resample-methods 2> /dev/null")"}; do 208 _resample_method_list+=$method 209 done 210 _describe 'resample method list' _resample_method_list 211} 212 213_clients() { 214 local -a _client_list 215 local _client _client_description 216 217 for client_info in ${(ps:\n\n:)"$(_call_program clients_tag "pactl $remote list clients 2> /dev/null")"}; do 218 for line in ${(f)client_info}; do 219 if [[ $line == Client[[:space:]]#* ]]; then 220 _client=${line#*\#} 221 elif [[ $line == *application.name* ]]; then 222 _client_description=${line#*=} 223 fi 224 done 225 _client_list+=($_client:$_client_description) 226 done 227 _describe 'client list' _client_list 228} 229 230_pacat_file_formats() { 231 local -a _file_format_list 232 for format in ${(f)"$(_call_program fformats_tag "pacat --list-file-formats")"}; do 233 _file_format_list+=(${${(ps:\t:)format}[1]}:${${(ps:\t:)format}[2]}) 234 done 235 _describe 'file format list' _file_format_list 236} 237 238_pactl_completion() { 239 _set_remote 240 241 _pactl_command(){ 242 local -a _pactl_commands 243 244 _pactl_commands=( 245 'help: show help and exit' 246 'stat: dump statistics about the PulseAudio daemon' 247 'info: dump info about the PulseAudio daemon' 248 'list: list modules/sources/streams/cards etc...' 249 'exit: ask the PulseAudio daemon to exit' 250 'upload-sample: upload a sound from a file into the sample cache' 251 'play-sample: play the specified sample from the sample cache' 252 'remove-sample: remove the specified sample from the sample cache' 253 'load-module: load a module' 254 'unload-module: unload a module' 255 'move-sink-input: move a stream to a sink' 256 'move-source-output: move a recording stream to a source' 257 'suspend-sink: suspend or resume a sink' 258 'suspend-source: suspend or resume a source' 259 'set-card-profile: set a card profile' 260 'set-default-sink: set the default sink' 261 'set-default-source: set the default source' 262 'set-sink-port: set the sink port of a sink' 263 'set-source-port: set the source port of a source' 264 'set-port-latency-offset: set a latency offset on a port' 265 'set-sink-volume: set the volume of a sink' 266 'set-source-volume: set the volume of a source' 267 'set-sink-input-volume: set the volume of a stream' 268 'set-source-output-volume: set the volume of a recording stream' 269 'set-sink-mute: mute a sink' 270 'set-source-mute: mute a source' 271 'set-sink-input-mute: mute a stream' 272 'set-source-output-mute: mute a recording stream' 273 'set-sink-formats: set supported formats of a sink' 274 'send-message: send a message to a pulseaudio object' 275 'subscribe: subscribe to events' 276 ) 277 278 _describe 'pactl commands' _pactl_commands 279 } 280 281 _pactl_command_parameter() { 282 local _command 283 284 _list_parameter() { 285 local -a _objects; 286 287 _objects=( 288 'modules: list loaded modules' 289 'sinks: list available sinks' 290 'sources: list available sources' 291 'sink-inputs: list connected sink inputs' 292 'source-outputs: list connected source outputs' 293 'clients: list connected clients' 294 'samples: list samples' 295 'cards: list available cards' 296 'message-handlers: list available message-handlers' 297 ) 298 299 if ((CURRENT == 2)); then 300 # We're completing the first parameter after "list". 301 # "pactl list cards short" and "pactl list short cards" are 302 # treated as equivalent by pactl, but here we only support the 303 # first form, so "short" isn't a valid completion. 304 _describe 'objects' _objects 305 elif ((CURRENT == 3)); then 306 # We're completing the second parameter after "list". As 307 # explained in the previous comment, we only support the 308 # "pactl list cards short" form, so "short" is the only valid 309 # completion here. 310 compadd short 311 fi 312 } 313 314 _play_sample_parameter() { 315 if ((CURRENT == 2)); then 316 # We're completing the first parameter after "play-sample". 317 _sample_names 318 elif ((CURRENT == 3)); then 319 # We're completing the second parameter after "play-sample". 320 _devices 321 fi 322 } 323 324 _load_module_parameter() { 325 if ((CURRENT == 2)); then 326 # We're completing the first parameter after "load-module". 327 _all_modules 328 else 329 # We're completing the second or later parameter after 330 # "load-module", i.e. the module arguments. 331 # TODO: Implement module argument completion. 332 fi 333 } 334 335 _move_sink_input_parameter() { 336 if ((CURRENT == 2)); then 337 # We're completing the first parameter after "move-sink-input". 338 # Even though the function name is "_devices", it actually 339 # completes the sink input index. _devices is magical like 340 # that. 341 _devices 342 elif ((CURRENT == 3)); then 343 # We're completing the second parameter after 344 # "move-sink-input". 345 _devices 346 fi 347 } 348 349 _move_source_output_parameter() { 350 if ((CURRENT == 2)); then 351 # We're completing the first parameter after 352 # "move-source-output". Even though the function name is 353 # "_devices", it actually completes the source output index. 354 # _devices is magical like that. 355 _devices 356 elif ((CURRENT == 3)); then 357 # We're completing the second parameter after 358 # "move-source-output". 359 _devices 360 fi 361 } 362 363 _suspend_sink_parameter() { 364 if ((CURRENT == 2)); then 365 # We're completing the first parameter after "suspend-sink". 366 _devices 367 elif ((CURRENT == 3)); then 368 # We're completing the second parameter after "suspend-sink". 369 compadd true false 370 fi 371 } 372 373 _suspend_source_parameter() { 374 if ((CURRENT == 2)); then 375 # We're completing the first parameter after "suspend-source". 376 _devices 377 elif ((CURRENT == 3)); then 378 # We're completing the second parameter after "suspend-source". 379 compadd true false 380 fi 381 } 382 383 _set_card_profile_parameter() { 384 if ((CURRENT == 2)); then 385 # We're completing the first parameter after 386 # "set-card-profile". 387 _cards 388 elif ((CURRENT == 3)); then 389 # We're completing the second parameter after 390 # "set-card-profile". 391 _profiles 392 fi 393 } 394 395 _set_sink_port_parameter() { 396 if ((CURRENT == 2)); then 397 # We're completing the first parameter after "set-sink-port". 398 _devices 399 elif ((CURRENT == 3)); then 400 # We're completing the second parameter after "set-sink-port". 401 _ports 402 fi 403 } 404 405 _set_source_port_parameter() { 406 if ((CURRENT == 2)); then 407 # We're completing the first parameter after "set-source-port". 408 _devices 409 elif ((CURRENT == 3)); then 410 # We're completing the second parameter after 411 # "set-source-port". 412 _ports 413 fi 414 } 415 416 _set_sink_mute_parameter() { 417 if ((CURRENT == 2)); then 418 # We're completing the first parameter after "set-sink-mute". 419 _devices 420 elif ((CURRENT == 3)); then 421 # We're completing the second parameter after "set-sink-mute". 422 compadd true false toggle 423 fi 424 } 425 426 _set_source_mute_parameter() { 427 if ((CURRENT == 2)); then 428 # We're completing the first parameter after "set-source-mute". 429 _devices 430 elif ((CURRENT == 3)); then 431 # We're completing the second parameter after 432 # "set-source-mute". 433 compadd true false toggle 434 fi 435 } 436 437 _set_sink_input_mute_parameter() { 438 if ((CURRENT == 2)); then 439 # We're completing the first parameter after 440 # "set-sink-input-mute". Even though the function name is 441 # "_devices", it actually completes the sink input index. 442 # _devices is magical like that. 443 _devices 444 elif ((CURRENT == 3)); then 445 # We're completing the second parameter after 446 # "set-sink-input-mute". 447 compadd true false toggle 448 fi 449 } 450 451 _set_source_output_mute_parameter() { 452 if ((CURRENT == 2)); then 453 # We're completing the first parameter after 454 # "set-source-output-mute". Even though the function name is 455 # "_devices", it actually completes the source output index. 456 # _devices is magical like that. 457 _devices 458 elif ((CURRENT == 3)); then 459 # We're completing the second parameter after 460 # "set-source-output-mute". 461 compadd true false toggle 462 fi 463 } 464 465 _set_port_latency_offset_parameter() { 466 if ((CURRENT == 2)); then 467 # We're completing the first parameter after 468 # "set-port-latency-offset". 469 _cards 470 elif ((CURRENT == 3)); then 471 # We're completing the second parameter after 472 # "set-port-latency-offset". 473 _ports 474 fi 475 } 476 477 _command=$words[1] 478 479 case $_command in 480 list) _list_parameter;; 481 upload-sample) if ((CURRENT == 2)); then _files; fi;; 482 play-sample) _play_sample_parameter;; 483 remove-sample) if ((CURRENT == 2)); then _sample_names; fi;; 484 load-module) _load_module_parameter;; 485 unload-module) if ((CURRENT == 2)); then _loaded_modules; fi;; 486 move-sink-input) _move_sink_input_parameter;; 487 move-source-output) _move_source_output_parameter;; 488 suspend-sink) _suspend_sink_parameter;; 489 suspend-source) _suspend_source_parameter;; 490 set-card-profile) _set_card_profile_parameter;; 491 set-default-sink) if ((CURRENT == 2)); then _devices; fi;; 492 set-default-source) if ((CURRENT == 2)); then _devices; fi;; 493 set-sink-port) _set_sink_port_parameter;; 494 set-source-port) _set_source_port_parameter;; 495 set-sink-volume) if ((CURRENT == 2)); then _devices; fi;; 496 set-source-volume) if ((CURRENT == 2)); then _devices; fi;; 497 set-sink-input-volume) if ((CURRENT == 2)); then _devices; fi;; 498 set-source-output-volume) if ((CURRENT == 2)); then _devices; fi;; 499 set-sink-mute) _set_sink_mute_parameter;; 500 set-source-mute) _set_source_mute_parameter;; 501 set-sink-input-mute) _set_sink_input_mute_parameter;; 502 set-source-output-mute) _set_source_output_mute_parameter;; 503 set-sink-formats) if ((CURRENT == 2)); then _devices; fi;; 504 set-port-latency-offset) _set_port_latency_offset_parameter;; 505 esac 506 } 507 508 _arguments -C -S -A '-*' \ 509 {-h,--help}'[display help and exit]' \ 510 '--version[show version and exit]' \ 511 {-s,--server=}'[name of server to connect to]:host:_hosts' \ 512 {-n,--client-name=}'[client name to use]:name' \ 513 '::pactl command:_pactl_command' \ 514 '*::pactl command parameter:_pactl_command_parameter' 515} 516 517_pacmd_completion() { 518 _pacmd_command(){ 519 _pacmd_commands=( 520 'help: show help and exit' 521 'list-modules: list modules' 522 'list-cards: list cards' 523 'list-sinks: list sinks' 524 'list-sources: list sources' 525 'list-clients: list clients' 526 'list-sink-inputs: list sink-inputs' 527 'list-source-outputs: list source-outputs' 528 'stat: dump statistics about the PulseAudio daemon' 529 'info: dump info about the PulseAudio daemon' 530 'load-module: load a module' 531 'unload-module: unload a module' 532 'describe-module: print info for a module' 533 'set-sink-volume: set the volume of a sink' 534 'set-source-volume: set the volume of a source' 535 'set-sink-mute: mute a sink' 536 'set-source-mute: mute a source' 537 'set-sink-input-volume: set the volume of a stream' 538 'set-source-output-volume: set the volume of a recording stream' 539 'set-sink-input-mute: mute a stream' 540 'set-source-output-mute: mute a recording stream' 541 'set-default-sink: set the default sink' 542 'set-default-source: set the default source' 543 'set-card-profile: set a card profile' 544 'set-sink-port: set the sink port of a sink' 545 'set-source-port: set the source port of a source' 546 'set-port-latency-offset: set a latency offset on a port' 547 'suspend-sink: suspend or resume a sink' 548 'suspend-source: suspend or resume a source' 549 'suspend: suspend all sinks and sources' 550 'move-sink-input: move a stream to a sink' 551 'move-source-output: move a recording stream to a source' 552 'update-sink-proplist: update the properties of a sink' 553 'update-source-proplist: update the properties of a source' 554 'update-sink-input-proplist: update the properties of a sink-input' 555 'update-source-output-proplist: update the properties of a source-output' 556 'list-samples: list samples' 557 'play-sample: play the specified sample from the sample cache' # TODO 558 'remove-sample: remove the specified sample from the sample cache' # TODO 559 'load-sample: upload a sound from a file into the sample cache' 560 'load-sample-lazy: lazily upload a sound file into the sample cache' 561 'load-sample-dir-lazy: lazily upload all sound files in a directory into the sample cache' 562 'kill-client: kill a client' 563 'kill-sink-input: kill a sink input' 564 'kill-source-output: kill a source output' 565 'set-log-target: change the log target' 566 'set-log-level: change the log level' 567 'set-log-meta: show source code location in log messages' 568 'set-log-time: show timestamps in log messages' 569 'set-log-backtrace: show backtrace in log messages' 570 'play-file: play a sound file' 571 'dump: show daemon configuration' 572 'dump-volumes: show the state of all volumes' 573 'shared: show shared properties' 574 'send-message: send a message to a pulseaudio object' 575 'exit: ask the PulseAudio daemon to exit' 576 ) 577 _describe 'pacmd commands' _pacmd_commands 578 } 579 580 _arguments -C -S -A "-*" \ 581 {-h,--help}'[display help and exit]' \ 582 '--version[show version and exit]' \ 583 '::pacmd commands:_pacmd_command' \ 584 585 case $words[$((CURRENT - 1))] in 586 set-card-profile) _cards;; 587 set-sink-*) _devices;; 588 set-source-*) _devices;; 589 load-module) _all_modules;; 590 describe-module) _all_modules;; 591 unload-module) _loaded_modules;; 592 suspend-*) _devices;; 593 move-*) _devices;; 594 set-port-latency-offset) _cards;; 595 load-sample*) _files;; 596 kill-client) _clients;; 597 kill-(sink|source)-*) _devices;; 598 set-log-target) compadd null auto syslog stderr file:;; 599 set-log-*) compadd true false;; 600 play-file) _files;; 601 esac 602 603 case $words[$((CURRENT - 2))] in 604 set-card-profile) _profiles;; 605 set-(sink|source)-port) _ports;; 606 set-port-latency-offset) _ports;; 607 set-*-mute) compadd true false;; 608 suspend-*) compadd true false;; 609 move-*) _devices;; 610 esac 611} 612 613_pasuspender_completion() { 614 # parenthesis expressions specify which options should not get suggested afterwards 615 # e.g. after -s, help and version will not get suggested, -- remains the only valid argument 616 # after "--" external commands get suggested 617 _arguments -C \ 618 '(-)'{-h,--help}'[display help and exit]' \ 619 '(-)--version[show version and exit]' \ 620 '(-h --help --version -s --server)'{-s,--server=}'[name of server to connect to]:host:_hosts' \ 621 '(-)--[program]:program: _command_names -e' && return 0 622 # check if "--" is one of the words in the command line 623 # if so, ${words[(i)--]} is the position of "--" 624 # shift the arguments and reduce CURRENT, such that further completions see only what follows "--" 625 if [[ ${words[(r)--]} == "--" ]]; then 626 for ((j = ${words[(i)--]}; j > 0; j--)); 627 do 628 shift words 629 (( CURRENT-- )) 630 done 631 # proceed with normal completion 632 _normal 633 fi 634} 635 636_padsp_completion() { 637 _arguments -C -S -A "-*" \ 638 '-h[display help and exit]' \ 639 '-s[name of server to connect to]:host:_hosts' \ 640 '-n[client name to use]:name:' \ 641 '-m[stream name to use]:name:' \ 642 '-M[disable /dev/mixer emulation]' \ 643 '-S[disable /dev/sndstat emulation]' \ 644 '-D[disable /dev/dsp emulation]' \ 645 '-d[enable debug output]' \ 646 '--[disable further command line parsing]' \ 647} 648 649# TODO channel map completion 650_pacat_completion() { 651 _set_remote 652 653 _pacat_sample_formats=('s16le' 's16be' 'u8' 'float32le' 'float32be' 654 'ulaw' 'alaw' 's32le' 's32be' 's24le' 's24-32le' 's24-32be') 655 656 _arguments -C -S -A "-*" \ 657 {-h,--help}'[display this help and exit]' \ 658 '--version[show version and exit]' \ 659 {-r,--record}'[create a connection for recording]' \ 660 {-p,--playback}'[create a connection for playback]' \ 661 {-s,--server=}'[name of server to connect to]:host:_hosts' \ 662 {-d,--device=}'[name of sink/source to connect to]:device:_devices' \ 663 '--monitor-stream=[index of the sink input to record from]:device:_devices' \ 664 {-n,--client-name=}'[client name to use]:name' \ 665 '--stream-name=[how to call this stream]:name' \ 666 '--volume=[initial volume to use]:volume' \ 667 '--rate=[sample rate to use]:rate:(44100 48000 96000)' \ 668 '--format=[sample type to use]:format:((${(q)_pacat_sample_formats}))' \ 669 '--channels=[number of channels to use]:number:(1 2)' \ 670 '--channel-map=[channel map to use]:map' \ 671 '--fix-format[use the sample format of the sink]' \ 672 '--fix-rate[use the rate of the sink]' \ 673 '--fix-channels[channel map of the sink]' \ 674 '--no-remix[do not upmix or downmix channels]' \ 675 '--no-remap[map channels by index instead of name]' \ 676 '--latency=[request the specified latency]:bytes' \ 677 '--process-time=[request the specified process time]:bytes' \ 678 '--latency-msec=[request the specified latency in msec]:msec' \ 679 '--process-time-msec=[request the specified process time in msec]:msec' \ 680 '--property=[set the specified property]:property' \ 681 '--raw[record/play raw PCM data]' \ 682 '--passthrough[passthrough data]' \ 683 '--file-format=[record/play formatted PCM data]:format:_pacat_file_formats' \ 684 '--list-file-formats[list available formats]' \ 685 '::files:_files' \ 686} 687 688# TODO log-target file completion 689_pulseaudio_completion() { 690 _arguments -C \ 691 {-h,--help}'[display this help and exit]' \ 692 '--version[show version and exit]' \ 693 '--dump-conf[show default configuration]' \ 694 '--dump-modules[show available modules]' \ 695 '--dump-resample-methods[show available resample methods]' \ 696 '--cleanup-shm[cleanup shared memory]' \ 697 '--start[start the daemon]' \ 698 {-k,--kill}'[kill a running daemon]' \ 699 '--check[check for a running daemon]' \ 700 '--system=[run as systemd-wide daemon]:bool:(true false)' \ 701 {-D,--daemonize=}'[daemonize after startup]:bool:(true false)' \ 702 '--fail=[quit when startup fails]:bool:(true false)' \ 703 '--high-priority=[try to set high nice level]:bool:(true false)' \ 704 '--realtime=[try to enable rt scheduling]:bool:(true false)' \ 705 '--disallow-module-loading=[disallow module loading]:bool:(true false)' \ 706 '--disallow-exit=[disallow user requested exit]' \ 707 '--exit-idle-time=[terminate the daemon on passed idle time]:time' \ 708 '--scache-idle-time=[unload autoloaded samples on passed idle time]:time' \ 709 '--log-level=[set the verbosity level]:level' \ 710 '-v[increase the verbosity level]' \ 711 '--log-target=[set the log target]:target:(auto syslog stderr file\: new_file\:):file' \ 712 '--log-meta=[include code location in log messages]:bool:(true false)' \ 713 '--log-time=[include timestamps in log messages]:bool:(true false)' \ 714 '--log-backtrace=[include backtrace in log messages]:frames' \ 715 {-p,--dl-search-path=}'[set the search path for plugins]:dir:_files' \ 716 '--resample-method=[set the resample method]:method:_resample_methods' \ 717 '--use-pid-file=[create a PID file]:bool:(true false)' \ 718 '--no-cpu-limit=[do not install CPU load limiter]:bool:(true false)' \ 719 '--disable-shm=[disable shared memory support]:bool:(true false)' \ 720 '--enable-memfd=[enable memfd shared memory support]:bool:(true false)' \ 721 {-L,--load=}'[load the specified module]:modules:_all_modules' \ 722 {-F,--file=}'[run the specified script]:file:_files' \ 723 '-C[open a command line on the running tty]' \ 724 '-n[do not load the default script file]' \ 725} 726 727_pulseaudio() { 728 local state line curcontext="$curcontext" 729 730 # Some commands, like pactl and pacat, have an option for specifying the 731 # server address, like "--server=somehost". If that option is set, then the 732 # helper commands that are run as part of the autocompletion need to use 733 # that same option. The option is saved in this variable in _set_remote(), 734 # which is called in the beginning of _pactl_completion() and others. The 735 # autocompletion commands can then find the option in that variable if the 736 # option is set. 737 local remote 738 739 case $service in 740 pulseaudio) _pulseaudio_completion;; 741 pactl) _pactl_completion;; 742 pacmd) _pacmd_completion;; 743 pacat) _pacat_completion;; 744 paplay)_pacat_completion;; 745 parec) _pacat_completion;; 746 parecord)_pacat_completion;; 747 padsp) _padsp_completion;; 748 pasuspender) _pasuspender_completion;; 749 *) _message "Err";; 750 esac 751} 752 753_pulseaudio "$@" 754 755#vim: set ft=zsh sw=4 ts=4 noet 756