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