Last active
September 18, 2020 19:26
-
-
Save jwmann/46f57cedfb5bcc0ff7d87e84abc3b306 to your computer and use it in GitHub Desktop.
Revisions
-
jwmann revised this gist
Sep 18, 2020 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,18 @@ #! /bin/bash # Author: James W Mann (jwmann) # Dependencies: homebrew, SwitchAudioSource (https://github.com/deweller/switchaudio-osx) # Notes: If SwitchAudioSource, the script will install it automatically # See all audio devices: $> SwitchAudioSource -a # Manually switch with: $> SwitchAudioSource -s device_name toggle_audio() { brew=/usr/local/bin/brew if [ -f $brew ]; then switchAudioSource=$($brew --prefix)/bin/SwitchAudioSource if [ -f $switchAudioSource ]; then currentOutput="$($switchAudioSource -c)" audioOutputA="Vanatoo T0" audioOutputB="Built-in Digital Output" case $currentOutput in $audioOutputA ) switchTo=$audioOutputB @@ -31,4 +34,4 @@ toggle_audio() { return 1 fi } toggle_audio -
jwmann revised this gist
Jan 7, 2020 . No changes.There are no files selected for viewing
-
jwmann revised this gist
Jan 7, 2020 . No changes.There are no files selected for viewing
-
jwmann created this gist
Jan 7, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ #! /bin/bash # Author: James W Mann (jwmann) # Dependencies: homebrew, SwitchAudioSource # Notes: If SwitchAudioSource, the script will install it automatically toggle_audio() { brew=/usr/local/bin/brew if [ -f $brew ]; then switchAudioSource=$($brew --prefix)/bin/SwitchAudioSource if [ -f $switchAudioSource ]; then currentOutput="$($switchAudioSource -c)" audioOutputA="All Speakers" audioOutputB="Yeti Stereo Microphone" case $currentOutput in $audioOutputA ) switchTo=$audioOutputB ;; $audioOutputB ) switchTo=$audioOutputA ;; esac $switchAudioSource -s "$switchTo" > /dev/null 2>&1 osascript -e 'display notification "'"${switchTo//\"/\\\"}"'" with title "Audio Output"' return 0 else osascript -e 'display notification "SwitchAudioSource binary not found. Installing now." with title "Error Switching Audio"' $brew install switchaudio-osx && osascript -e 'display notification "SwitchAudioSource binary successfully installed." with title "Audio Output"' && toggle_audio return 0 fi else osascript -e 'display notification "Homebrew not found. Please install homebrew." with title "Error Switching Audio"' return 1 fi } toggle_audio