completions: fix pacmd completions when using pipewire-pulse.

In such cases, `pacmd help` prints

  No PulseAudio daemon running, or not running as session daemon.

to stderr, which ends up printed to the user terminal.
This commit is contained in:
Érico Nogueira 2021-05-14 16:02:40 -03:00 committed by Fabian Homborg
parent aeabc76b2e
commit 3ac2242c68
2 changed files with 3 additions and 3 deletions

View File

@ -1,13 +1,13 @@
# Pulseaudio's pacmd
# This covers the most useful commands
set -l commands (pacmd help | string match -r '^ +[-\w]+' | string trim)
set -l commands (pacmd help 2>/dev/null | string match -r '^ +[-\w]+' | string trim)
complete -f -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')"
complete -f -c pacmd -n "not __fish_seen_subcommand_from $commands" -a "(pacmd help 2>/dev/null | 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)'

View File

@ -12,7 +12,7 @@ set -l ctlcommands stat info list exit {upload,play,remove}-sample {load,unload}
# HACK: This is the list of commands from pacmd - used so we can use complete -w there
if command -sq pacmd
set commands (pacmd help | string match -r '^ +[-\w]+' | string trim)
set commands (pacmd help 2>/dev/null | string match -r '^ +[-\w]+' | string trim)
else
set commands $ctlcommands
end