Skip to content

Instantly share code, notes, and snippets.

@michaelmrose
Created October 23, 2019 20:49
Show Gist options
  • Save michaelmrose/d65bce8049875e6faa0952483c2f4c14 to your computer and use it in GitHub Desktop.
Save michaelmrose/d65bce8049875e6faa0952483c2f4c14 to your computer and use it in GitHub Desktop.
switch audio
#!/bin/fish
# pass nothing to move everything to the next valid sink and set it as default
# you may pass instead an index or a string that uniquely identifies a sink
# example headset/headphones if your headphones includes that name
set data (pactl list short sinks)
set sinks (p $data | awk '{print $1}')
set current (p $data |head -1|cut -c1)
set streams (pactl list short sink-inputs | cut -f1)
if test -n "$argv"
if string match -r '^[.0-9]+$' $argv
set next $argv
else
set next (ponymix -t sink list --short | grep -i $argv| head -1 |awk '{print $2}')
if not exists $next
echo no target found
end
end
else
set next (next-valid-index $current $sinks)
end
for s in $streams
pactl move-sink-input $s $next
end
pactl set-default-sink $next
ponymix unmute
signal-i3blocks output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment