Last active
November 14, 2022 10:46
-
-
Save yuki777/99e6ff70202ccb04ae982ad72d158376 to your computer and use it in GitHub Desktop.
reset-sound-device.app
This file contains 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 characters
# https://apple.stackexchange.com/questions/190319/display-notification-works-from-applescript-editor-but-not-when-exported-as-ap | |
tell application "Finder" to activate | |
# 入力デバイスを指定する | |
do shell script " | |
/opt/homebrew/bin/SwitchAudioSource -f json -t input -s 'HyperX QuadCast S' || | |
/opt/homebrew/bin/SwitchAudioSource -f json -t input -s 'Yeti Nano' || | |
/opt/homebrew/bin/SwitchAudioSource -f json -t input -s 'MacBook Pro Microphone' | |
" | |
# 入力音量を75%に設定する | |
set volume input volume 75 | |
# 出力デバイスを指定する | |
do shell script " | |
/opt/homebrew/bin/SwitchAudioSource -f json -t output -s 'Bose Mini II SoundLink' || | |
/opt/homebrew/bin/SwitchAudioSource -f json -t output -s 'YukiAirPods' || | |
/opt/homebrew/bin/SwitchAudioSource -f json -t output -s 'Soundcore Liberty 3 Pro' || | |
/opt/homebrew/bin/SwitchAudioSource -f json -t output -s 'Soundcore Life P2-L' || | |
/opt/homebrew/bin/SwitchAudioSource -f json -t output -s 'External Headphones' || | |
/opt/homebrew/bin/SwitchAudioSource -f json -t output -s 'MacBook Pro Speakers' | |
" | |
# 現在の出力デバイスを取得する | |
set currentOutputDevice to do shell script "/opt/homebrew/bin/SwitchAudioSource -c -t output" | |
# 出力音量を設定する | |
if currentOutputDevice = "External Headphones" then | |
set volume output volume 50 | |
else if currentOutputDevice = "Bose Mini II SoundLink" then | |
set volume output volume 30 | |
else if currentOutputDevice = "Soundcore Liberty 3 Pro" then | |
set volume output volume 65 | |
else if currentOutputDevice = "MacBook Pro Speakers" then | |
set volume output volume 50 | |
else | |
set volume output volume 75 | |
end if | |
# 現在の入力デバイスを取得する | |
set currentInputDevice to do shell script "/opt/homebrew/bin/SwitchAudioSource -c -t input" | |
# 入出力デバイスを表示する | |
display notification "Input : " & currentInputDevice & " | |
Output : " & currentOutputDevice with title "reset-sound-device.app" sound name "Glass" | |
# フィードバックサウンドを再生する | |
do shell script "/usr/bin/afplay /System/Library/Sounds/Glass.aiff" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment