Skip to content

Instantly share code, notes, and snippets.

@dontdieych
Last active April 12, 2020 14:54
Show Gist options
  • Save dontdieych/bd534db04d2cf99c5681967a6d60577a to your computer and use it in GitHub Desktop.
Save dontdieych/bd534db04d2cf99c5681967a6d60577a to your computer and use it in GitHub Desktop.
#!/usr/bin/env fish
function active-port
pacmd list-sinks |\
rg 'active port:' |\
tr -s ' ' |\
cut -d: -f2 |\
string trim
end
set -l _active_port (active-port)
echo "Active:$_active_port"
switch $_active_port
case '<analog-output-speaker>'
pacmd set-sink-port 0 analog-output-headphones
case '<analog-output-headphones>'
pacmd set-sink-port 0 analog-output-speaker
case '*'
exit 1
end
echo
echo "Changed:"(active-port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment