switchaudio-osx -github
switchaudio-osx -download
$ SwitchAudioSource -a
PLT_BBTGO (input)
Built-in Microphone (input)
PLT_BBTGO (output)
Built-in Output (output)
$ SwitchAudioSource -t input -s PLT_BBTGO
現在設定されているものは、-c
で取得します。使用するものが決まっている場合、これを元に、Switchするスクリプト書いても良いかもですね。ただし、デバイス名は、スペース開いてる場合、"
とかで囲います。
pecoを使った入力デバイスの切り替え例
$ SwitchAudioSource -a | grep input | cut -d '(' -f 1 | peco | xargs -J % SwitchAudioSource -t input -s %
pecoを使った出力デバイスの切り替え例
スペース開いてる場合
$ SwitchAudioSource -a | grep output | cut -d '(' -f 1 | sed -e 's/ *$//' -e 's/$/"/g' -e 's/^/"/g' | peco | xargs -J % SwitchAudioSource -s %
zshでの切り替え例
au
コマンドに設定しました。キーは、^^
です。入力デバイスは、au -i
です。
~/.zshrc
function au(){
case $1 in
-o|*)
SwitchAudioSource -a | grep output | cut -d '(' -f 1 | sed -e 's/ *$//' -e 's/$/"/g' -e 's/^/"/g' | peco | xargs -J % SwitchAudioSource -s %
;;
-i)
SwitchAudioSource -a | grep input | cut -d '(' -f 1 | sed -e 's/ *$//' -e 's/$/"/g' -e 's/^/"/g' | peco | xargs -J % SwitchAudioSource -t input -s %
;;
esac
}
zle -N au
bindkey '\^^' au
出力必要ない場合は、zle reset-prompt
とか設定してください。 > bindkey