"Fossies" - the Fresh Open Source Software Archive

Member "pulseaudio-13.0/shell-completion/bash/pulseaudio" (13 Jul 2018, 15570 Bytes) of package /linux/misc/pulseaudio-13.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 
    3 __cards () {
    4     while IFS=$'\t' read idx name _; do
    5         printf "%s %s\n" "$idx" "$name"
    6     done < <(pactl list cards short 2> /dev/null)
    7 }
    8 
    9 __sinks () {
   10     while IFS=$'\t' read _ name _ _ _; do
   11         printf "%s\n" "$name"
   12     done < <(pactl list sinks short 2> /dev/null)
   13 }
   14 
   15 __sinks_idx () {
   16     while IFS=$'\t' read idx _ _ _ _; do
   17         printf "%s\n" "$idx"
   18     done < <(pactl list sinks short 2> /dev/null)
   19 }
   20 
   21 __sources () {
   22     while IFS=$'\t' read _ name _ _ _; do
   23         printf "%s\n" "$name"
   24     done < <(pactl list sources short 2> /dev/null)
   25 }
   26 
   27 __sink_inputs () {
   28     while IFS=$'\t' read idx _ _ _ _; do
   29         printf "%s\n" "$idx"
   30     done < <(pactl list sink-inputs short 2> /dev/null)
   31 }
   32 
   33 __source_outputs () {
   34     while IFS=$'\t' read idx _ _ _ _; do
   35         printf "%s\n" "$idx"
   36     done < <(pactl list source-outputs short 2> /dev/null)
   37 }
   38 
   39 __ports () {
   40     pactl list cards 2> /dev/null | awk -e \
   41         '/^\tPorts:/ {
   42             flag=1; next
   43          }
   44 
   45          /^\t[A-Za-z]/ {
   46              flag=0
   47          }
   48 
   49          flag {
   50              if (/^\t\t[A-Za-z]/)
   51                  ports = ports substr($0, 3, index($0, ":")-3) " "
   52          }
   53 
   54          END {
   55              print ports
   56          }'
   57 }
   58 
   59 __profiles () {
   60     pactl list cards 2> /dev/null | awk -e \
   61         '/^\tProfiles:/ {
   62             flag=1; next
   63         }
   64 
   65         /^\t[A-Za-z]/ {
   66             flag=0
   67         }
   68 
   69         flag {
   70             if (/^\t\t[A-Za-z]/)
   71                 profiles = profiles substr($0, 3, index($0, ": ")-3) " "
   72         }
   73 
   74         END {
   75             print profiles
   76         }'
   77 }
   78 
   79 __all_modules () {
   80     while read name; do
   81         name=${name%% *}
   82         printf "%s\n" "$name"
   83     done < <(pulseaudio --dump-modules 2> /dev/null)
   84 }
   85 
   86 __loaded_modules () {
   87     while IFS=$'\t' read idx name _; do
   88         printf "%s %s\n" "$idx" "$name"
   89     done < <(pactl list modules short 2> /dev/null)
   90 }
   91 
   92 __resample_methods () {
   93     while read name; do
   94         printf "%s\n" "$name"
   95     done < <(pulseaudio --dump-resample-methods 2> /dev/null)
   96 }
   97 
   98 _pacat_file_formats () {
   99     while IFS=$'\t' read name _; do
  100         printf "%s\n" "$name"
  101     done < <(pacat --list-file-formats 2> /dev/null)
  102 }
  103 
  104 in_array() {
  105     local i
  106     for i in "${@:2}"; do
  107         [[ $1 = "$i" ]] && return
  108     done
  109 }
  110 
  111 _pactl() {
  112     local cur prev words cword preprev command
  113     local comps
  114     local flags='-h --help --version -s --server= --client-name='
  115     local list_types='short sinks sources sink-inputs source-outputs cards
  116                     modules samples clients'
  117     local commands=(stat info list exit upload-sample play-sample remove-sample
  118                     load-module unload-module move-sink-input move-source-output
  119                     suspend-sink suspend-source set-card-profile set-sink-port
  120                     set-source-port set-sink-volume set-source-volume
  121                     set-sink-input-volume set-source-output-volume set-sink-mute
  122                     set-source-mute set-sink-input-mute set-source-output-mute
  123                     set-sink-formats set-port-latency-offset subscribe help)
  124 
  125     _init_completion -n = || return
  126     preprev=${words[$cword-2]}
  127 
  128     for word in "${COMP_WORDS[@]}"; do
  129         if in_array "$word" "${commands[@]}"; then
  130             command=$word
  131             break
  132         fi
  133     done
  134 
  135     case $preprev in
  136         list) COMPREPLY=($(compgen -W 'short' -- "$cur")) ;;
  137 
  138         play-sample)
  139             comps=$(__sinks)
  140             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  141             ;;
  142 
  143         move-sink-input)
  144             comps=$(__sinks)
  145             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  146             ;;
  147 
  148         move-source-output)
  149             comps=$(__sources)
  150             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  151             ;;
  152 
  153         set-card-profile)
  154             comps=$(__profiles)
  155             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  156             ;;
  157 
  158         set-*-port)
  159             comps=$(__ports)
  160             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  161             ;;
  162 
  163         set-*-mute) COMPREPLY=($(compgen -W 'true false toggle' -- "$cur")) ;;
  164 
  165         set-sink-formats)
  166             ;; #TODO
  167 
  168         set-port-*)
  169             comps=$(__ports)
  170             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  171             ;;
  172         --server)
  173             compopt +o nospace
  174             _known_hosts_real "$cur"
  175             ;;
  176     esac
  177     [[ $COMPREPLY ]] && return 0
  178 
  179     case $prev in
  180         list) COMPREPLY=($(compgen -W '${list_types[*]}' -- "$cur")) ;;
  181 
  182         upload-sample) _filedir ;;
  183 
  184         play-sample) ;; # TODO
  185 
  186         remove-sample) ;; # TODO
  187 
  188         load-module)
  189             comps=$(__all_modules)
  190             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  191             ;;
  192 
  193         unload-module)
  194             comps=$(__loaded_modules)
  195             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  196             ;;
  197 
  198         set-card*)
  199             comps=$(__cards)
  200             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  201             ;;
  202 
  203         *sink-input*)
  204             comps=$(__sink_inputs)
  205             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  206             ;;
  207 
  208         *source-output*)
  209             comps=$(__source_outputs)
  210             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  211             ;;
  212 
  213         set-sink-formats)
  214             comps=$(__sinks_idx)
  215             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  216             ;;
  217 
  218         *sink*)
  219             comps=$(__sinks)
  220             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  221             ;;
  222 
  223         *source*)
  224             comps=$(__sources)
  225             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  226             ;;
  227 
  228         set-port*)
  229             comps=$(__cards)
  230             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  231             ;;
  232 
  233         -s)
  234             _known_hosts_real "$cur" ;;
  235     esac
  236     [[ $COMPREPLY ]] && return 0
  237 
  238     case $cur in
  239         --server=*)
  240             cur=${cur#*=}
  241             _known_hosts_real "$cur"
  242             ;;
  243 
  244         -*)
  245             COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur"))
  246             [[ $COMPREPLY == *= ]] && compopt -o nospace
  247             ;;
  248 
  249         *)
  250             [[ -z $command ]] && COMPREPLY=($(compgen -W '${commands[*]}' -- "$cur"))
  251             ;;
  252     esac
  253 }
  254 complete -F _pactl pactl
  255 
  256 _pacmd() {
  257     local cur prev words cword preprev command
  258     local comps
  259     local flags='-h --help --version'
  260     local commands=(exit help list-modules list-cards list-sinks list-sources list-clients
  261                     list-samples list-sink-inputs list-source-outputs stat info
  262                     load-module unload-module describe-module set-sink-volume
  263                     set-source-volume set-sink-input-volume set-source-output-volume
  264                     set-sink-mute set-source-mut set-sink-input-mute
  265                     set-source-output-mute update-sink-proplist update-source-proplist
  266                     update-sink-input-proplist update-source-output-proplist
  267                     set-default-sink set-default-source kill-client kill-sink-input
  268                     kill-source-output play-sample remove-sample load-sample
  269                     load-sample-lazy load-sample-dir-lazy play-file dump
  270                     move-sink-input move-source-output suspend-sink suspend-source
  271                     suspend set-card-profile set-sink-port set-source-port
  272                     set-port-latency-offset set-log-target set-log-level set-log-meta
  273                     set-log-time set-log-backtrace)
  274     _init_completion -n = || return
  275     preprev=${words[$cword-2]}
  276 
  277     for word in "${COMP_WORDS[@]}"; do
  278         if in_array "$word" "${commands[@]}"; then
  279             command=$word
  280             break
  281         fi
  282     done
  283 
  284     case $preprev in
  285         play-sample|play-file)
  286             comps=$(__sinks)
  287             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  288             ;;
  289 
  290         load-sample*) _filedir ;;
  291 
  292         move-sink-input)
  293             comps=$(__sinks)
  294             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  295             ;;
  296 
  297         move-source-output)
  298             comps=$(__sources)
  299             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  300             ;;
  301 
  302         set-card-profile)
  303             comps=$(__profiles)
  304             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  305             ;;
  306 
  307         set-*port*)
  308             comps=$(__ports)
  309             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  310             ;;
  311 
  312         set-*-mute) COMPREPLY=($(compgen -W 'true false' -- "$cur"));;
  313 
  314         set-sink-formats)
  315             ;; #TODO
  316     esac
  317 
  318     case $prev in
  319         list-*) ;;
  320         describe-module|load-module)
  321             comps=$(__all_modules)
  322             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  323             ;;
  324 
  325         unload-module)
  326             comps=$(__loaded_modules)
  327             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  328             ;;
  329 
  330         load-sample-dir-lazy) _filedir -d ;;
  331         play-file) _filedir ;;
  332 
  333         *sink-input*)
  334             comps=$(__sink_inputs)
  335             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  336             ;;
  337 
  338         *source-output*)
  339             comps=$(__source_outputs)
  340             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  341             ;;
  342 
  343         *sink*)
  344             comps=$(__sinks)
  345             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  346             ;;
  347 
  348         *source*)
  349             comps=$(__sources)
  350             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  351             ;;
  352 
  353         set-card*)
  354             comps=$(__cards)
  355             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  356             ;;
  357 
  358         set-port-*)
  359             comps=$(__cards)
  360             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  361             ;;
  362 
  363         set-log-target)
  364             COMPREPLY=($(compgen -W 'auto syslog stderr file: newfile:' -- "$cur"))
  365             ;;
  366 
  367         set-log-level)
  368             COMPREPLY=($(compgen -W '{0..4}' -- "$cur"))
  369             ;;
  370 
  371         set-log-meta|set-log-time|suspend)
  372             COMPREPLY=($(compgen -W 'true false' -- "$cur"))
  373             ;;
  374     esac
  375 
  376     case $cur in
  377         -*) COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur")) ;;
  378         suspend)
  379             COMPREPLY=($(compgen -W 'suspend suspend-sink suspend-source' -- "$cur"))
  380             ;;
  381 
  382         load-sample)
  383             COMPREPLY=($(compgen -W 'load-sample load-sample-lazy load-sample-dir-lazy' -- "$cur"))
  384             ;;
  385 
  386         *)
  387             [[ -z $command ]] && COMPREPLY=($(compgen -W '${commands[*]}' -- "$cur"))
  388             ;;
  389     esac
  390 }
  391 complete -F _pacmd pacmd
  392 
  393 _pasuspender () {
  394     local cur prev
  395     local flags='-h --help --version -s --server='
  396 
  397     _init_completion -n = || return
  398 
  399     case $cur in
  400         --server=*)
  401             cur=${cur#*=}
  402             _known_hosts_real "$cur"
  403             ;;
  404 
  405         -*)
  406             COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur"))
  407             [[ $COMPREPLY == *= ]] && compopt -o nospace
  408             ;;
  409     esac
  410 
  411     case $prev in
  412         -s) _known_hosts_real "$cur" ;;
  413     esac
  414 }
  415 complete -F _pasuspender pasuspender
  416 
  417 _padsp () {
  418     local cur prev
  419     local flags='-h -s -n -m -M -S -D -d'
  420 
  421     _get_comp_words_by_ref cur prev
  422 
  423     case $cur in
  424         -*) COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur")) ;;
  425     esac
  426 
  427     case $prev in
  428         -s) _known_hosts_real "$cur" ;;
  429     esac
  430 }
  431 complete -F _padsp padsp
  432 
  433 _pacat () {
  434     local cur prev comps
  435     local flags='-h --help --version -r --record -p --playback -v --verbose -s
  436                 --server= -d --device= -n --client-name= --stream-name= --volume=
  437                 --rate= --format= --channels= --channel-map= --fix-format --fix-rate
  438                 --fix-channels --no-remix --no-remap --latency= --process-time=
  439                 --latency-msec= --process-time-msec= --property= --raw --passthrough
  440                 --file-format= --list-file-formats --monitor-stream='
  441 
  442     _init_completion -n = || return
  443 
  444     case $cur in
  445         --server=*)
  446             cur=${cur#*=}
  447             _known_hosts_real "$cur"
  448             ;;
  449 
  450         --device=*)
  451             cur=${cur#*=}
  452             comps=$(__sinks)
  453             comps+=" "$(__sources)
  454             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  455             ;;
  456 
  457         --monitor-stream=*)
  458             cur=${cur#*=}
  459             comps=$(__sink_inputs)
  460             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  461             ;;
  462 
  463         --rate=*)
  464             cur=${cur#*=}
  465             COMPREPLY=($(compgen -W '32000 44100 48000 9600 192000' -- "$cur"))
  466             ;;
  467 
  468         --file-format=*)
  469             cur=${cur#*=}
  470             comps=$(_pacat_file_formats)
  471             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  472             ;;
  473 
  474         --*=*)
  475             ;;
  476 
  477         -*)
  478             COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur"))
  479             [[ $COMPREPLY == *= ]] && compopt -o nospace
  480             ;;
  481         *) _filedir ;;
  482     esac
  483 
  484     case $prev in
  485         -s) _known_hosts_real "$cur" ;;
  486         -d)
  487             comps=$(__sinks)
  488             comps+=" "$(__sources)
  489             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  490             ;;
  491     esac
  492 }
  493 complete -F _pacat pacat paplay parec parecord
  494 
  495 _pulseaudio()
  496 {
  497     local cur prev words cword
  498     local flags='-h --help --version --dump-conf --dump-resample-methods --cleanup-shm
  499                 --start -k --kill --check --system= -D --daemonize= --fail= --high-priority=
  500                 --realtime= --disallow-module-loading= --disallow-exit= --exit-idle-time=
  501                 --scache-idle-time= --log-level= -v --log-target= --log-meta= --log-time=
  502                 --log-backtrace= -p --dl-search-path= --resample-method= --use-pit-file=
  503                 --no-cpu-limit= --disable-shm= --enable-memfd= -L --load= -F --file= -C -n'
  504     _init_completion -n = || return
  505 
  506     case $cur in
  507         --system=*|--daemonize=*|--fail=*|--high-priority=*|--realtime=*| \
  508             --disallow-*=*|--log-meta=*|--log-time=*|--use-pid-file=*| \
  509             --no-cpu-limit=*|--disable-shm=*|--enable-memfd=*)
  510             cur=${cur#*=}
  511             COMPREPLY=($(compgen -W 'true false' -- "$cur"))
  512             ;;
  513 
  514         --log-target=*)
  515             cur=${cur#*=}
  516             COMPREPLY=($(compgen -W 'auto syslog stderr file: newfile:' -- "$cur"))
  517             ;;
  518 
  519         --log-level=*)
  520             cur=${cur#*=}
  521             COMPREPLY=($(compgen -W '{0..4}' -- "$cur"))
  522             ;;
  523 
  524         --dl-search-path=*)
  525             cur=${cur#*=}
  526             _filedir -d
  527             ;;
  528 
  529         --file=*)
  530             cur=${cur#*=}
  531             _filedir
  532             ;;
  533 
  534         --resample-method=*)
  535             cur=${cur#*=}
  536             comps=$(__resample_methods)
  537             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  538             ;;
  539 
  540         --load=*)
  541             cur=${cur#*=}
  542             comps=$(__all_modules)
  543             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  544             ;;
  545 
  546         --*=*)
  547             ;;
  548 
  549         -*)
  550             COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur"))
  551             [[ $COMPREPLY == *= ]] && compopt -o nospace
  552             ;;
  553     esac
  554 
  555     case $prev in
  556         -D) COMPREPLY=($(compgen -W 'true false' -- "$cur")) ;;
  557         -p) _filedir -d ;;
  558         -F) _filedir ;;
  559         -L)
  560             cur=${cur#*=}
  561             comps=$(__all_modules)
  562             COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
  563             ;;
  564     esac
  565 }
  566 complete -F _pulseaudio pulseaudio
  567 
  568 #vim: set ft=zsh sw=4 ts=4 noet