#!/usr/bin/env fish argparse h/help -- $argv if set -q _flag_h echo "Cycle between pactl sinks specified as arguments." return 0 end set -l sinks alsa_output.usb-FIIO_FiiO_USB_DAC-E10-01.analog-stereo alsa_output.usb-Burr-Brown_from_TI_USB_Audio_DAC-00.analog-stereo if test (count $argv) -ne 0 set sinks $argv end set -l current (pactl get-default-sink) set -l idx 0 for i in $sinks if test "$i" = "$current" break end set idx (math $idx + 1) end set -l next_idx (math "($idx + 1)" % (count $sinks)) pactl set-default-sink $sinks[(math $next_idx + 1)]