Hey, any tips on adjusting my MacBook Pro speakers (which is System Sounds/Alert Device) to 100% without changing current audio output (dropping my AirPods Pro)?
Is there native way without installing 3rd party utilities?
Here is my current ugly way to solve this:
# Capture the current output device name
current_device=$("/opt/homebrew/bin/SwitchAudioSource" -c -t output)
# Switch to built-in speakers and set volume to 100%
"/opt/homebrew/bin/SwitchAudioSource" -u BuiltInSpeakerDevice
osascript -e 'set volume output volume 100' -e 'set volume alert volume 100'
# Sleep for a delay to ensure the commands execute properly
sleep 1
# Switch back to the previous output device by name
"/opt/homebrew/bin/SwitchAudioSource" -s "$current_device"
# Switch System to built-in speakers
"/opt/homebrew/bin/SwitchAudioSource" -t system -u BuiltInSpeakerDevice
- I found a utility that can be used to fix this, it is called GitHub - luckman212/volctl: Commandline tool to get or set volume levels on macOS
Here is my updated script that utilizes it:
#!/usr/bin/env bash
set -euo pipefail
SAS=/opt/homebrew/bin/SwitchAudioSource
VC=/usr/local/bin/volctl
# send UI alerts to your MBP speakers
$SAS -t system -u BuiltInSpeakerDevice
# make sure the input device is the built-in mic
$SAS -t input -u BuiltInMicrophoneDevice
# (optional) give CoreAudio a quick moment
sleep 1
# max out the hardware sliders
if ! $SAS -c -t output | grep -q "MacBook Pro Speakers"; then
$VC set "MacBook Pro Speakers" 1.0 output
fi
$VC set "MacBook Pro Microphone" 1.0 input
# (optional) give CoreAudio a quick moment
sleep 1
# crank only the input & alert sliders—leaving your AirPods’ output alone
osascript -e 'set volume input volume 100 alert volume 100'