fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
6fec5ab32
master
1set -l commands status get-volume inspect set-default set-volume set-mute set-profile clear-default 2 3if wpctl settings&> /dev/null 4set --append commands settings 5end 6 7function __wpctl_get_nodes -a section -a type 8set -l havesection 9set -l havetype 10wpctl status| while read -l line 11if set -q havesection[ 1 ] 12test -z " $line " ;and break 13if set -q havetype[ 1 ] 14string match -rq'^\s*\│\s*$' --$line ;and break 15printf '%s\t%s\n' ( string match -r'\d+' $line ) ( string match -rg'\d+\. ([^\[]*)' $line ) 16else 17string match -q"* $type *" --$line 18and set havetype1 19end 20else 21string match -q" $section *" --$line 22and set havesection1 23end 24end 25end 26 27function __wpctl_command_shape 28set -l shape$argv 29set -l command( commandline -pxc) 30set -e command[ 1 ] # Remove command name 31 32# Remove flags as we won't count them with the shape 33set -l command( string match -v --'-*' $command ) 34 35if test ( count $command ) != ( count $shape ) 36return 1 37end 38 39while set -q command[ 1 ] 40string match -q --$shape [ 1 ] $command [ 1 ] ;or return 1 41set -e shape[ 1 ] command[ 1 ] 42end 43end 44 45function __wpctl_get_settings 46set -l wpctl_settings( wpctl settings2> /dev/null| string collect) 47or return 48 49string match --regex --all --quiet'\- Name: (?<wpctl_settings_name>.*)\n Desc: (?<wpctl_settings_desc>.*)' $wpctl_settings 50 51for iin ( seq ( count $wpctl_settings_name )) 52set -l name$wpctl_settings_name [ $i ] 53set -l desc( string shorten --max60 $wpctl_settings_desc [ $i ]) 54echo $name \t $desc 55end 56end 57 58complete -c wpctl -f 59 60complete -c wpctl -s h -l help -d"Show help options" 61complete -c wpctl -n"__fish_seen_subcommand_from status" -s k -l nick -d"Display device and node nicknames instead of descriptions" 62complete -c wpctl -n"__fish_seen_subcommand_from status" -s n -l name -d"Display device and node names instead of descriptions" 63complete -c wpctl -n"__fish_seen_subcommand_from inspect" -s r -l referenced -d"Show objects that are referenced in properties" 64complete -c wpctl -n"__fish_seen_subcommand_from inspect" -s a -l associated -d"Show associated objects" 65complete -c wpctl -n"__fish_seen_subcommand_from set-volume" -s p -l pid -d"Selects all nodes associated to the given PID" 66complete -c wpctl -n"__fish_seen_subcommand_from set-volume" -s l -l limit -d"Limit volume to below this value" 67complete -c wpctl -n"__fish_seen_subcommand_from set-mute" -s p -l pid -d"Selects all nodes associated to the given PID" 68complete -c wpctl -n"__fish_seen_subcommand_from settings" -s d -l delete -d"Deletes the saved setting value" 69complete -c wpctl -n"__fish_seen_subcommand_from settings" -s s -l save -d"Saves the setting value" 70complete -c wpctl -n"__fish_seen_subcommand_from settings" -s r -l reset -d"Resets the saved setting to its default value" 71 72complete -c wpctl -n __wpctl_command_shape -a" $commands " 73complete -c wpctl -n'__wpctl_command_shape "*"' -n"__fish_seen_subcommand_from get-volume inspect set-volume set-mute set-profile" -a"@DEFAULT_AUDIO_SOURCE@" -d"Default Microphone" 74complete -c wpctl -n'__wpctl_command_shape "*"' -n"__fish_seen_subcommand_from get-volume inspect set-volume set-mute set-profile" -a"@DEFAULT_AUDIO_SINK@" -d"Default Speakers" 75complete -c wpctl -n'__wpctl_command_shape "*"' -n"__fish_seen_subcommand_from inspect set-profile" -a"@DEFAULT_VIDEO_SOURCE@" -d"Default Camera" 76complete -c wpctl -n'__wpctl_command_shape "*"' -n"__fish_seen_subcommand_from get-volume inspect set-volume set-mute set-profile" -a"(__wpctl_get_nodes Audio Sources) (__wpctl_get_nodes Audio Sinks)" 77complete -c wpctl -n'__wpctl_command_shape "*"' -n"__fish_seen_subcommand_from inspect set-profile" -a"(__wpctl_get_nodes Audio Sources) (__wpctl_get_nodes Audio Sinks) (__wpctl_get_nodes Video Source)" 78complete -c wpctl -n'__wpctl_command_shape set-mute "*"' -a"0 1 toggle" 79complete -c wpctl -n'__wpctl_command_shape settings' -a"(__wpctl_get_settings)"