applescript to switch default audio/video input/out for LG display

Discussion in 'Mac Accessories' started by garyleecn, Jan 13, 2017.

  1. garyleecn macrumors 6502a

    Jul 25, 2014
    so since we finally received our LG displays, problem/challenges comes up

    one that I noticed right away is that even if connected to LG 5k display, sometimes the audio input/output source is still set to be the internal mic/speaker.

    so is it possible to write an AppleScript or automator to switch those to LG, if the script/automator can be triggered automatically by the connection, it would be even better.

    as for disconnecting, I have a script/alfred workflow that quits all applications that is accessing data on external hard drives (those connected on the display, not computer), and eject all external drives for a safer disconnect. if you want I can share it
  2. Outrigger macrumors 68000


    Dec 22, 2008
    that would be great if you can share. I also have 3 hard drives connected to the monitor, but I haven't come across switching to the internal speakers by itself. However, I do notice that when I do facetime, the camera always defaults back to the internal which isn't a big deal but when I have it in clamshell mode, it is a big deal.
  3. garyleecn thread starter macrumors 6502a

    Jul 25, 2014
    looks like the forum doesn't allow file upload, so if you are using Alfred, there is a workflow called ejectall you can download from their forum.
    if not, you can create a automator application, with only two steps.

    1. run shell script, with the following

    # unmount all external drives from your osx
    killall -9 Photos
    for disk in $(diskutil list|grep external|sed -e 's/^\([^ ]*\) .*$/\1/g'); do diskutil unmountDisk force $disk; done

    the second line is to force quit photos app, because I run my photo library on the external drive. you can modify it as fit your situation.

    2. Display notification
    and put down what every text you want. this is just to let you know the workflow is finished, and it's safe to unplug now.
    so I just wrote 'safe to disconnect now'

    hope it helps

  4. Outrigger macrumors 68000


    Dec 22, 2008
    appreciate it!
  5. satcomer macrumors 603


    Feb 19, 2008
    The Finger Lakes Region
    What I do is hold down the Option key while clicking the Finder menu Sound icon then I can quickly choose where to send audio.
  6. priitv8 macrumors 68030

    Jan 13, 2011
    Some time ago I tried to do the same to toggle Bluetooth power whenever I connect the external display.
    AFAIK in AppleScript there is no event triggered by connecting new display, so this was a no-go.
    I use Mountain for that exact purpose.

Share This Page