LoginSignup
15
14

More than 5 years have passed since last update.

超簡単に Mac のオーディオ入出力を切り替える方法

Last updated at Posted at 2014-08-16

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

めちゃ簡単に Mac のオーディオ入出力を切り替える方法 -元ネタ

15
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
14