[pulseaudio-commits] 3 commits - shell-completion/pulseaudio-zsh-completion.zsh

Tanu Kaskinen tanuk at kemper.freedesktop.org
Mon Mar 18 12:29:39 PDT 2013


 shell-completion/pulseaudio-zsh-completion.zsh |   82 +++++++++++++++++++------
 1 file changed, 65 insertions(+), 17 deletions(-)

New commits:
commit ada92732f0086035c850e877c791e23a79bf923d
Author: poljar (Damir Jelić) <poljarinho at gmail.com>
Date:   Sun Mar 17 22:06:41 2013 +0100

    zsh-completion: Fix pacat completion.
    
    pacat --format needs = (--format=).
    Also pacat should complete files firstly and command line arguments
    secondly.

diff --git a/shell-completion/pulseaudio-zsh-completion.zsh b/shell-completion/pulseaudio-zsh-completion.zsh
index 4a85956..d73b74d 100644
--- a/shell-completion/pulseaudio-zsh-completion.zsh
+++ b/shell-completion/pulseaudio-zsh-completion.zsh
@@ -470,8 +470,9 @@ _pacat_completion() {
         '--property=[set the specified property]:property' \
         '--raw[record/play raw PCM data]' \
         '--passthrough[passtrough data]' \
-        '--file-format[record/play formatted PCM data]:format:_pacat_file_formats' \
+        '--file-format=[record/play formatted PCM data]:format:_pacat_file_formats' \
         '--list-file-formats[list available formats]' \
+        '::files:_files' \
 }
 
 # TODO log-target file completion

commit d127e801dc8c881bb5c58b659f19c362c1dcfccf
Author: poljar (Damir Jelić) <poljarinho at gmail.com>
Date:   Sun Mar 17 22:06:40 2013 +0100

    zsh-completion: Add support for the new pactl commands.
    
    This adds support for set-(sink|source)-default completion and adds
    toggle to the supported arguments for the mute command.

diff --git a/shell-completion/pulseaudio-zsh-completion.zsh b/shell-completion/pulseaudio-zsh-completion.zsh
index f9002ef..4a85956 100644
--- a/shell-completion/pulseaudio-zsh-completion.zsh
+++ b/shell-completion/pulseaudio-zsh-completion.zsh
@@ -257,6 +257,8 @@ _pactl_completion() {
             'suspend-sink: suspend or resume a sink'
             'suspend-source: suspend or resume a source'
             'set-card-profile: set a card profile:cards:_cards'
+            'set-sink-default: set the default sink'
+            'set-source-default: set the default source'
             'set-sink-port: set the sink port of a sink'
             'set-source-port: set the source port of a source'
             'set-port-latency-offset: set a latency offset on a port'
@@ -313,7 +315,7 @@ _pactl_completion() {
         set-card-profile) _profiles;;
         set-(sink|source)-port) _ports;;
         set-port-latency-offset) _ports;;
-        set-*-mute) compadd true false;;
+        set-*-mute) compadd true false toggle;;
         suspend-*) compadd true false;;
         list) compadd short;;
         move-*) _devices;;

commit 993e756e13903173b8d9a6265bcfa2c38bdad27e
Author: poljar (Damir Jelić) <poljarinho at gmail.com>
Date:   Sun Mar 17 22:06:39 2013 +0100

    zsh-completion: Add support for remote servers.
    
    This patch adds support for completion of remote PulseAudio server
    arguments it also suppresses error messages when unable to connect to
    PulseAudio (only for the completion function).

diff --git a/shell-completion/pulseaudio-zsh-completion.zsh b/shell-completion/pulseaudio-zsh-completion.zsh
index c3baf9d..f9002ef 100644
--- a/shell-completion/pulseaudio-zsh-completion.zsh
+++ b/shell-completion/pulseaudio-zsh-completion.zsh
@@ -2,7 +2,7 @@
 
 _devices() {
     local -a _device_list
-    local cmd _device _device_description
+    local cmd _device _device_description _remote_cmd
 
     if [[ $service == pactl  || $service == pacmd ]]; then
         case $words[$((CURRENT - 1))] in
@@ -38,8 +38,15 @@ _devices() {
         cmd=('sources')
     fi
 
+    for (( i = 0; i < ${#words[@]}; i++ )) do
+        if [[ ${words[$i]} == -s ]]; then
+            _remote_cmd="-s ${words[$i+1]}"
+            break;
+        fi
+    done
+
     for target in $cmd; do
-        for device_info in ${(ps:\n\n:)"$(_call_program card_tag "pactl list $target")"}; do
+        for device_info in ${(ps:\n\n:)"$(_call_program device_tag "pactl $_remote_cmd list $target 2> /dev/null")"}; do
             for line in ${(f)device_info}; do
                 if [[ $target == (sink-inputs|source-outputs) ]]; then
                     if [[ $line == (Sink*Input|Source*Output)* ]]; then
@@ -74,11 +81,18 @@ _devices() {
 
 _profiles() {
     local -a _profile_list
-    local _current_card _raw_profiles _profile_name _profile_description
+    local _current_card _raw_profiles _profile_name _profile_description _remote_cmd
 
     _current_card=$words[$((CURRENT - 1))]
 
-    for card in ${(ps:\n\n:)"$(_call_program card_tag "pactl list cards")"}; do
+    for (( i = 0; i < ${#words[@]}; i++ )) do
+        if [[ ${words[$i]} == -s ]]; then
+            _remote_cmd="-s ${words[$i+1]}"
+            break;
+        fi
+    done
+
+    for card in ${(ps:\n\n:)"$(_call_program profiles_tag "pactl $_remote_cmd list cards 2> /dev/null")"}; do
         if [[ $card == *$_current_card* ]]; then
             _raw_profiles=${card##*Profiles:}
             _raw_profiles=${_raw_profiles%%Active Profile:*}
@@ -99,7 +113,7 @@ _profiles() {
 
 _ports() {
     local -a _port_list
-    local _raw_ports _port_name _port_description _current_device
+    local _raw_ports _port_name _port_description _current_device _remote_cmd
 
     case $words[$((CURRENT - 2))] in
         set-sink-port) cmd="sinks";;
@@ -109,7 +123,14 @@ _ports() {
 
     _current_device=$words[$((CURRENT - 1))]
 
-    for device in ${(ps:\n\n:)"$(_call_program card_tag "pactl list $cmd")"}; do
+    for (( i = 0; i < ${#words[@]}; i++ )) do
+        if [[ ${words[$i]} == -s ]]; then
+            _remote_cmd="-s ${words[$i+1]}"
+            break;
+        fi
+    done
+
+    for device in ${(ps:\n\n:)"$(_call_program port_tag "pactl $_remote_cmd list $cmd 2> /dev/null")"}; do
         if [[ $device == *Ports:* && $device == *$_current_device* ]]; then
             _raw_ports=${device##*Ports:}
             _raw_ports=${_raw_ports%%Active Port:*}
@@ -130,8 +151,16 @@ _ports() {
 
 _cards(){
     local -a _card_list
-    local _card _cad_name
-    for card_info in ${(ps:\n\n:)"$(_call_program card_tag "pactl list cards")"}; do
+    local _card _cad_name _remote_cmd
+
+    for (( i = 0; i < ${#words[@]}; i++ )) do
+        if [[ ${words[$i]} == -s ]]; then
+            _remote_cmd="-s ${words[$i+1]}"
+            break;
+        fi
+    done
+
+    for card_info in ${(ps:\n\n:)"$(_call_program card_tag "pactl $_remote_cmd list cards 2> /dev/null")"}; do
         for line in ${(f)card_info}; do
             if [[ $line == *Name:* ]]; then
                 _card=${line#*: }
@@ -148,15 +177,23 @@ _cards(){
 
 _all_modules(){
     local -a _all_modules_list
-    for module in ${(f)"$(_call_program modules_tag "pulseaudio --dump-modules")"}; do
+    for module in ${(f)"$(_call_program modules_tag "pulseaudio --dump-modules 2> /dev/null")"}; do
         _all_modules_list+=${module%% *}
     done
     _describe 'module list' _all_modules_list
 }
 
 _loaded_modules(){
-    local -a _loaded_modules_list
-    for module in ${(f)"$(_call_program modules_tag "pactl list modules short")"}; do
+    local -a _loaded_modules_list _remote_cmd
+
+    for (( i = 0; i < ${#words[@]}; i++ )) do
+        if [[ ${words[$i]} == -s ]]; then
+            _remote_cmd="-s ${words[$i+1]}"
+            break;
+        fi
+    done
+
+    for module in ${(f)"$(_call_program modules_tag "pactl $_remote_cmd list modules short 2> /dev/null")"}; do
         _loaded_modules_list+=(${${(ps:\t:)module}[1]}:${${(ps:\t:)module}[2]})
     done
     _describe 'module list' _loaded_modules_list
@@ -164,7 +201,7 @@ _loaded_modules(){
 
 _resample_methods() {
     local -a _resample_method_list
-    for method in ${(f)"$(_call_program modules_tag "pulseaudio --dump-resample-methods")"}; do
+    for method in ${(f)"$(_call_program modules_tag "pulseaudio --dump-resample-methods 2> /dev/null")"}; do
         _resample_method_list+=$method
     done
     _describe 'resample method list' _resample_method_list
@@ -172,8 +209,16 @@ _resample_methods() {
 
 _clients() {
     local -a _client_list
-    local _client _client_description
-    for client_info in ${(ps:\n\n:)"$(_call_program card_tag "pactl list clients")"}; do
+    local _client _client_description _remote_cmd
+
+    for (( i = 0; i < ${#words[@]}; i++ )) do
+        if [[ ${words[$i]} == -s ]]; then
+            _remote_cmd="-s ${words[$i+1]}"
+            break;
+        fi
+    done
+
+    for client_info in ${(ps:\n\n:)"$(_call_program clients_tag "pactl $_remote_cmd list clients 2> /dev/null")"}; do
         for line in ${(f)client_info}; do
             if [[ $line == Client[[:space:]]#* ]]; then
                 _client=${line#*\#}
@@ -188,7 +233,7 @@ _clients() {
 
 _pacat_file_formats() {
     local -a _file_format_list
-    for format in ${(f)"$(_call_program modules_tag "pacat --list-file-formats")"}; do
+    for format in ${(f)"$(_call_program fformats_tag "pacat --list-file-formats")"}; do
         _file_format_list+=(${${(ps:\t:)format}[1]}:${${(ps:\t:)format}[2]})
     done
     _describe 'file format list' _file_format_list



More information about the pulseaudio-commits mailing list