> so playing with Audio Hijack, it seems my "Airplay" audio output is only present in the interface if I'm currently choosing "Airplay" as my default audio output from the system
Airfoil will maintain a connection with your Airplay device even after resetting your system audio device.
Though not perfect, but you can use applescript to force Airfoil's discovery of your airplay device by way of control center:
tell application "System Events" to tell process "Control Center"
repeat with menuBarItem in every menu bar item of menu bar 1
if description of menuBarItem as text is "Sound" then
set soundMenuBarItem to menuBarItem
exit repeat
end if
end repeat
click soundMenuBarItem
repeat with currentCheckbox in every checkbox of scroll area 1 of group 1 of window "Control Center"
set deviceId to value of attribute "AXIdentifier" of currentCheckbox
set deviceName to text 14 thru -1 of deviceId
if deviceName as string is equal to "DEVICE NAME" then -- DEVICE_NAME is the name of your airplay audio device in control center.
click currentCheckbox
click soundMenuBarItem
exit repeat
end if
end repeat
end tell
Airfoil supports scripting[0] so you can connect an application to the airplay speaker using this AppleScript:
tell application "Airfoil"
set safariSource to make new application source
set application file of safariSource to "/Applications/Safari.app"
set current audio source to safariSource
set aSpeaker to (first speaker whose name is "INSTANCE_NAME") -- Paste the Airplay speaker's instance name here
if not (connected of aSpeaker) then
connect to aSpeaker
else
disconnect from aSpeaker
end if
end tell
You can run this command in the command line to get the instance name of your airplay device:
dns-sd -B _airplay._tcp
You can make some combination of this to form a workflow that suits you.
[0] https://rogueamoeba.com/support/knowledgebase/?showArticle=A...