Skip to content

Instantly share code, notes, and snippets.

@LinuxIsCool
Last active October 5, 2020 04:43
Show Gist options
  • Save LinuxIsCool/2253a8e6e35de0766454c69a19cfb06b to your computer and use it in GitHub Desktop.
Save LinuxIsCool/2253a8e6e35de0766454c69a19cfb06b to your computer and use it in GitHub Desktop.
Interactively loop audio with fzf and fish shell. I use this function to play audio on my headphones and bluetooth speakers at the same time. I do this by selecting my system output to be the speakers, and then looping the speaker output into my headphones.
function pacmd-loopback --description 'Loop a pacmd source into a pacmd sink interactively.'
if test (set source (pacmd list-sources | grep name: | awk '{ print $2 }' | cut -d'<' -f2 | cut -d'>' -f1 | fzf-tmux --header="Select a source" --phony); set sink (pacmd list-sinks | grep name: | awk '{ print $2 }' | cut -d'<' -f2 | cut -d'>' -f1 | fzf-tmux --header="Select a sink:"); printf "No\nYes" | fzf-tmux --header="CONFIRM: <$source> -> <$sink>") = "Yes"
pacmd load-module module-loopback source=$source sink=$sink
else
echo "Aborted."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment