mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-01 05:53:49 +08:00
Add profiles and ports completion to pactl
This is now on par with the official bash completions.
This commit is contained in:
parent
daafe4ef37
commit
b7d98fa873
|
@ -3,8 +3,7 @@
|
||||||
# Note: Streams are called "sink-input" (for playback) and "source-output" (for recording)
|
# Note: Streams are called "sink-input" (for playback) and "source-output" (for recording)
|
||||||
|
|
||||||
# TODO: Moar commands
|
# TODO: Moar commands
|
||||||
# load-module set-card-profile set-{sink,source}-port set-port-latency-offset set-sink-formats
|
# set-port-latency-offset set-sink-formats
|
||||||
# TODO: Figure out how to get available card profiles and ports
|
|
||||||
|
|
||||||
set -l commands stat info list exit {upload,play,remove}-sample {load,unload}-module \
|
set -l commands 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} \
|
move-{sink-input,source-output} suspend-{sink,source} set-{card-profile,default-sink,sink-port,source-port,port-latency-offset} \
|
||||||
|
@ -21,6 +20,16 @@ function __fish_pa_print_type
|
||||||
# Pa allows both a numerical index and a name
|
# Pa allows both a numerical index and a name
|
||||||
pactl list short $argv | string replace -r '(\w+)\t.*' '$1'
|
pactl list short $argv | string replace -r '(\w+)\t.*' '$1'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function __fish_pa_list_ports
|
||||||
|
# Yes, this is localized
|
||||||
|
env LC_ALL=C pactl list cards ^/dev/null | sed -n -e '/Ports:/,$p' | string match -r '^\t\t\w.*$' | string replace -r '\s+([-+\w:]+): (\w.+)' '$1\t$2'
|
||||||
|
end
|
||||||
|
|
||||||
|
function __fish_pa_list_profiles
|
||||||
|
env LC_ALL=C pactl list cards ^/dev/null | sed -n -e '/Profiles:/,/Active Profile/p' | string match -r '\t\t.*' | string replace -r '\s+([-+\w:]+): (\w.+)' '$1\t$2'
|
||||||
|
end
|
||||||
|
|
||||||
complete -f -e -c pactl
|
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 "$commands"
|
||||||
|
|
||||||
|
@ -36,8 +45,9 @@ complete -f -c pactl -n "not __fish_seen_subcommand_from $commands" -a play-samp
|
||||||
complete -f -c pactl -n "not __fish_seen_subcommand_from $commands" -a remove-sample -d 'Remove a sample from the cache'
|
complete -f -c pactl -n "not __fish_seen_subcommand_from $commands" -a remove-sample -d 'Remove a sample from the cache'
|
||||||
complete -f -c pactl -n "__fish_seen_subcommand_from play-sample remove-sample" -a '(__fish_pa_complete_type samples)'
|
complete -f -c pactl -n "__fish_seen_subcommand_from play-sample remove-sample" -a '(__fish_pa_complete_type samples)'
|
||||||
|
|
||||||
# TODO: "list short modules" only shows _loaded_ modules - figure out how to find unloaded ones for load-module
|
|
||||||
complete -f -c pactl -n "__fish_seen_subcommand_from unload-module" -a '(__fish_pa_complete_type modules)'
|
complete -f -c pactl -n "__fish_seen_subcommand_from unload-module" -a '(__fish_pa_complete_type modules)'
|
||||||
|
# TODO: This shows _all_ modules
|
||||||
|
complete -f -c pactl -n "__fish_seen_subcommand_from load-module" -a '(pulseaudio --dump-modules | string replace -r " +" "\t")'
|
||||||
|
|
||||||
complete -f -c pactl -n "__fish_seen_subcommand_from move-sink-input; and not __fish_seen_subcommand_from (__fish_pa_print_type sink-inputs)" \
|
complete -f -c pactl -n "__fish_seen_subcommand_from move-sink-input; and not __fish_seen_subcommand_from (__fish_pa_print_type sink-inputs)" \
|
||||||
-a '(__fish_pa_complete_type sink-inputs)'
|
-a '(__fish_pa_complete_type sink-inputs)'
|
||||||
|
@ -56,6 +66,10 @@ for t in source sink
|
||||||
-a '0' -d "Resume"
|
-a '0' -d "Resume"
|
||||||
complete -f -c pactl -n "__fish_seen_subcommand_from suspend-$t; and __fish_seen_subcommand_from (__fish_pa_print_type "$t"s)" \
|
complete -f -c pactl -n "__fish_seen_subcommand_from suspend-$t; and __fish_seen_subcommand_from (__fish_pa_print_type "$t"s)" \
|
||||||
-a '1' -d "Suspend"
|
-a '1' -d "Suspend"
|
||||||
|
complete -f -c pactl -n "__fish_seen_subcommand_from set-$t-port; and not __fish_seen_subcommand_from (__fish_pa_print_type "$t"s)" \
|
||||||
|
-a "(__fish_pa_complete_type "$t"s)"
|
||||||
|
complete -f -c pactl -n "__fish_seen_subcommand_from set-$t-port; and __fish_seen_subcommand_from (__fish_pa_print_type "$t"s)" \
|
||||||
|
-a "(__fish_pa_list_ports)"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Volume and mute
|
# Volume and mute
|
||||||
|
@ -74,6 +88,11 @@ for t in source sink source-output sink-input
|
||||||
-a "toggle"
|
-a "toggle"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
complete -f -c pactl -n "__fish_seen_subcommand_from set-card-profile; and not __fish_seen_subcommand_from (__fish_pa_print_type cards)" \
|
||||||
|
-a "(__fish_pa_complete_type cards)"
|
||||||
|
complete -f -c pactl -n "__fish_seen_subcommand_from set-card-profile; and __fish_seen_subcommand_from (__fish_pa_print_type cards)" \
|
||||||
|
-a "(__fish_pa_list_profiles)"
|
||||||
|
|
||||||
complete -f -c pactl -n "__fish_seen_subcommand_from set-default-sink" -a "(__fish_pa_complete_type sinks)"
|
complete -f -c pactl -n "__fish_seen_subcommand_from set-default-sink" -a "(__fish_pa_complete_type sinks)"
|
||||||
|
|
||||||
complete -f -c pactl -l version -d 'Print a short version and exit'
|
complete -f -c pactl -l version -d 'Print a short version and exit'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user