Sample Header Ad - 728x90

Toggle Airplay Receiver server with the command line on MacOS Monteray+

1 vote
2 answers
4142 views
The new macOS Airplay Receiver service uses port 5000. I'd like to temporarily disable it during the running of a script. This service is manually toggled by an option under *System Preferences > Sharing > Services > Airplay Receiver*. The process that seems to run the service is /System/Library/CoreServices/ControlCenter.app/Contents/MacOS/ControlCenter. I've looked into the defaults command and some osascript options but been unable to find the right incantations. The ideal solution resembles:
#!/bin/bash
toggle_airplay_receiver off
echo "Running my script and doing stuff on port 5000..."
toggle_airplay_receiver on
echo "All done, AirPlay Receiver works again :)"
Ideally there's a direct way to do start and stop the service, but a janky method of scripting the System Preferences gui is also acceptable.
Asked by AJ Slater (43 rep)
Dec 3, 2021, 05:44 AM
Last activity: Aug 9, 2022, 07:31 PM