diff options
author | Fabian Homborg <FHomborg@gmail.com> | 2016-01-14 23:31:17 +0100 |
---|---|---|
committer | Fabian Homborg <FHomborg@gmail.com> | 2016-01-14 23:31:17 +0100 |
commit | 8db1a5fae797c03c439fa1c8bcdd3aa3c19691b2 (patch) | |
tree | fbe42893fc014b4a84197882af640d4f3c987c54 /share | |
parent | 6bf70c86d2b289229a81df94a0c7b8c2addd18dc (diff) |
Add completions for Pulseaudio's pacmd
To implement this mostly as a wrapper around pactl, we add the list of
commands for this to that. It's 90% the same anyway. (This means that
`pactl suspend ` will complete files instead of commands like `pactl
banana ` would, but neither is correct)
Diffstat (limited to 'share')
-rw-r--r-- | share/completions/pacmd.fish | 21 | ||||
-rw-r--r-- | share/completions/pactl.fish | 8 |
2 files changed, 27 insertions, 2 deletions
diff --git a/share/completions/pacmd.fish b/share/completions/pacmd.fish new file mode 100644 index 00000000..f5da595f --- /dev/null +++ b/share/completions/pacmd.fish @@ -0,0 +1,21 @@ +# Pulseaudio's pacmd +# This covers the most useful commands +set -l commands (pacmd help | string match -r '^ +[-\w]+' | string trim) +complete -f -e -c pacmd +complete -f -c pacmd -w pactl + +# These descriptions are a bit wordy and unnecessary +# Sample: set-source-port Change the port of a source (args: index|name, port-name) +# Or: list-source-outputs List source outputs +complete -f -c pacmd -n "not __fish_seen_subcommand_from $commands" -a "(pacmd help | string match ' *' | string trim | string replace -r '\s+' '\t')" + +# Since we wrapped pactl, we can also use functions defined there +complete -f -c pacmd -n "__fish_seen_subcommand_from describe-module" -a '(__fish_pa_complete_type modules)' +complete -f -c pacmd -n "__fish_seen_subcommand_from kill-client" -a '(__fish_pa_complete_type clients | string match -r "^[0-9].*")' # match because this only takes an index + +for t in client sink-input source-output + complete -f -c pacmd -n "__fish_seen_subcommand_from kill-$t" -a '(__fish_pa_complete_type '$t's | string match -r "^[0-9].*")' # match because this only takes an index +end + +complete -f -c pactl -n "__fish_seen_subcommand_from suspend" -a '0 false off' -d "Resume" +complete -f -c pactl -n "__fish_seen_subcommand_from suspend" -a '1 true on' -d "Suspend" diff --git a/share/completions/pactl.fish b/share/completions/pactl.fish index a2e3e5ef..5ac92e3f 100644 --- a/share/completions/pactl.fish +++ b/share/completions/pactl.fish @@ -5,7 +5,11 @@ # TODO: Moar commands # set-port-latency-offset set-sink-formats -set -l commands stat info list exit {upload,play,remove}-sample {load,unload}-module \ + +# HACK: This is the list of commands from pacmd - used so we can use complete -w there +set -l commands (pacmd help | string match -r '^ +[-\w]+' | string trim) +# These are the actual commands for pactl - we complete only these, and then the cmd commands in that completion +set -l ctlcommands stat info list exit {upload,play,remove}-sample {load,unload}-module \ move-{sink-input,source-output} suspend-{sink,source} set-{card-profile,default-sink,sink-port,source-port,port-latency-offset} \ set-{sink,source,sink-input,source-output}-{volume,mute} set-sink-formats subscribe @@ -44,7 +48,7 @@ function __fish_pa_complete_unloaded_modules end complete -f -e -c pactl -complete -f -c pactl -n "not __fish_seen_subcommand_from $commands" -a "$commands" +complete -f -c pactl -n "not __fish_seen_subcommand_from $commands" -a "$ctlcommands" complete -f -c pactl -n "not __fish_seen_subcommand_from $commands" -a stat -d 'Show statistics about memory usage' complete -f -c pactl -n "not __fish_seen_subcommand_from $commands" -a info -d 'Show info about the daemon' |