I am making an attempt to show the quantity icon and share of my exterior monitor (Dell U4025QW) audio output in SketchyBar on my MacBook Professional (M1). The aim is to indicate correct quantity and mute standing within the bar.
What I need to obtain:
- Present present quantity % and mute icon for my exterior monitor in SketchyBar.
- Have quantity replace stay because it adjustments.
- Fall again gracefully when utilizing the built-in show (i.e. show quantity of built-in audio system).
I am utilizing the next snippet in my SketchyBar plugin:
VOLUME=$(osascript -e "output quantity of (get quantity settings)")
MUTED=$(osascript -e "output muted of (get quantity settings)")
supply "$CONFIG_DIR/env.sh"
supply "$CONFIG_DIR/icons.sh"
if [ "$MUTED" != "false" ]; then
ICON="${ICONS_VOLUME[0]}"
VOLUME=0
else
case ${VOLUME} in
100) ICON="${ICONS_VOLUME[3]}" ;;
[5-9]*) ICON="${ICONS_VOLUME[2]}" ;;
[0-9]*) ICON="${ICONS_VOLUME[1]}" ;;
*) ICON="${ICONS_VOLUME[2]}" ;;
esac
fi
sketchybar -m
--set "$NAME" icon=$ICON
--set "$NAME" label="$VOLUME%"
When utilizing the built-in MacBook Professional show, this works completely. When utilizing the exterior Dell monitor, osascript
at all times returns lacking worth for quantity
or 0
, regardless of the quantity HUD displaying the proper quantity and the keyboard quantity keys working.
From analysis and testing, it appears that evidently:
- Exterior screens utilizing Thunderbolt/USB audio output usually don’t expose their quantity controls by way of macOS scripting APIs (like AppleScript).
- macOS appears to “faux” or cache the quantity adjustments for these gadgets within the UI however doesn’t expose the precise quantity programmatically.
- The mute standing is uncovered and scriptable, however quantity share shouldn’t be.
Is there any identified method, device, or API to programmatically get the actual quantity degree of an exterior Thunderbolt or USB audio system (corresponding to a monitor) on macOS?