#!/bin/env sh DEFAULT_HEADPHONES='alsa_output.usb-Audeze_LLC_Audeze_Maxwell_Dongle_0000000000000000-01.analog-stereo' DEFAULT_SPEAKERS='alsa_output.usb-Generic_USB_Audio-00.HiFi__Headphones__sink' DEFAULT_HEADPHONE_MIC='alsa_input.usb-Audeze_LLC_Audeze_Maxwell_Dongle_0000000000000000-01.mono-fallback' DEFAULT_BLUE_MIC='alsa_input.usb-Generic_Blue_Microphones_LT_2007151539505F39045F_111000-00.analog-stereo' get_or_default() { pactl -f json list "$1" short | jq -Mcr "map(select(.name | test(\"$2\")))[0]?.name? // \"$3\"" } case "$1" in "headphones") echo "$DEFAULT_HEADPHONES" # TODO: Figure out generic regex string to match headphones ;; "speakers") get_or_default 'sinks' 'HiFi__Headphones__sink' "$DEFAULT_SPEAKERS" ;; "headphone_mic") echo "$DEFAULT_HEADPHONE_MIC" # TODO: Figure out generic regex string to match headphone mic ;; "blue_mic") get_or_default 'sources' 'Generic_Blue_Microphones[a-zA-Z0-9_.\\-]+\\.analog-stereo$' "$DEFAULT_BLUE_MIC" ;; *) echo "Device name '$1' not recognized"; exit 1 ;; esac