Sunday, July 27, 2025

applescript – Methods to get/show actual quantity degree of exterior monitor (in SketchyBar, shell script) on macOS?

I am making an attempt to show the amount icon and proportion 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 wish to obtain:

  • Present present quantity % and mute icon for my exterior monitor in SketchyBar.
  • Have quantity replace dwell because it modifications.
  • 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 amount HUD displaying the right quantity and the keyboard quantity keys working.

From analysis and testing, plainly:

  • Exterior screens utilizing Thunderbolt/USB audio output typically don’t expose their quantity controls through macOS scripting APIs (like AppleScript).
  • macOS appears to “pretend” or cache the amount modifications for these gadgets within the UI however doesn’t expose the precise quantity programmatically.
  • The mute standing is uncovered and scriptable, however quantity proportion is just not.

Is there any identified means, device, or API to programmatically get the actual quantity degree of an exterior Thunderbolt or USB audio gadget (resembling a monitor) on macOS?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles