How to get/display real volume level of external monitor (in SketchyBar, shell script) on macOS?
1
vote
0
answers
17
views
I'm trying to display the volume icon and percentage of my external monitor (Dell U4025QW) audio output in SketchyBar on my MacBook Pro (M1). The goal is to show accurate volume and mute status in the bar.
What I want to achieve:
- Show current volume % and mute icon for my external monitor in SketchyBar.
- Have volume update live as it changes.
- Fall back gracefully when using the built-in display (i.e. display volume of built-in speakers).
I'm using the following snippet in my SketchyBar plugin:
VOLUME=$(osascript -e "output volume of (get volume settings)")
MUTED=$(osascript -e "output muted of (get volume settings)")
source "$CONFIG_DIR/env.sh"
source "$CONFIG_DIR/icons.sh"
if [ "$MUTED" != "false" ]; then
ICON="${ICONS_VOLUME}"
VOLUME=0
else
case ${VOLUME} in
100) ICON="${ICONS_VOLUME}" ;;
[5-9]*) ICON="${ICONS_VOLUME}" ;;
[0-9]*) ICON="${ICONS_VOLUME}" ;;
*) ICON="${ICONS_VOLUME}" ;;
esac
fi
sketchybar -m \
--set "$NAME" icon=$ICON \
--set "$NAME" label="$VOLUME%"
When using the built-in MacBook Pro display, this works perfectly. When using the external Dell monitor, osascript
always returns missing value for volume
or 0
, despite the volume HUD showing the correct volume and the keyboard volume keys working.
From research and testing, it seems that:
- External monitors using Thunderbolt/USB audio output often do not expose their volume controls via macOS scripting APIs (like AppleScript).
- macOS seems to "fake" or cache the volume changes for these devices in the UI but does not expose the actual volume programmatically.
- The mute status is exposed and scriptable, but volume percentage is not.
Is there any known way, tool, or API to programmatically get the real volume level of an external Thunderbolt or USB audio device (such as a monitor) on macOS?
Asked by Jusi
(161 rep)
Jul 26, 2025, 01:13 PM
Last activity: Jul 26, 2025, 05:49 PM
Last activity: Jul 26, 2025, 05:49 PM