AirControl
AirControl copied to clipboard
Here's what works for me on Sequoia
This is working for me on Sequoia 15.4.1
This script which can be executed from the command line using osascript airplay.scpt
Will open the preferences pane, select the display pane, then click the '+' button and select the listing with "[LG]" in it, since in my case the listing is "[LG] webOS TV OLED65C1LB"
Which activates airplay on my tv, it can be run again to de-activate it.
do shell script "open x-apple.systempreferences:com.apple.preference.displays"
tell application "System Events"
# Wait for System Settings to be available
repeat until (exists process "System Settings")
delay 0.5
end repeat
tell process "System Settings"
# Wait for the window to load
repeat until (exists window "Displays")
delay 0.5
end repeat
# Wait a bit more for the UI to fully load
delay 1
tell window "Displays"
# Click the "+" button in the top right corner
set plusButton to button "Add display" of group 1
click plusButton
# Wait for the dropdown/popup menu to appear
delay 1
# Look for the LG TV option and click it
# This might need adjustment depending on exactly how the menu appears
# and what the exact text of the menu item is
click menu item "[LG] webOS TV OLED65C1LB" of menu 1 of plusButton
# If the above doesn't work, we can try using keyboard navigation
# keystroke "[LG]" # Type the first few characters to jump to the option
# delay 0.5
# key code 36 # Return key to select
end tell
end tell
end tell