Created | Author | GitHub | Contact |
---|---|---|---|
2023/10/12 |
Naty S @eclecticpassions |
I wanted a shortcut to quickly access the AirPlay Receiver buried in System Settings > General > AirDrop & Handoff
as I often turn this off when I'm done using it. I have a gut feeling leaving it on causes issues with my M1 Mac Mini's USB-A ports' power management and sleep / wake problems.
This AppleScript is tested to work on macOS 14.0 Sonoma.
- Open
Shortcuts
, createNew Shortcut
. - On the right
Action Library
sidebar, search for `Run AppleScript". - Drag it to the left to start creating shortcut workflow.
- Delete the template in textbox, and paste in the script from below.
- Press the hammer icon to highlight syntax.
- Click
Run
(play icon) to test the workflow. - Select
Shortcut Details
(i icon) and under details, select where you want to access this shortcut. I selectedPin in Menu Bar
for quick access. - Save the shortcut by closing the window. The newly created shortcut should be at the top.
- Rename to your liking (e.g. Airplay Receiver Switch)
- Remember to turn on accessibility permissions for
Control Center
andShortcuts
in thePrivacy & Security
page ofSystem Settings
for the shortcut to work. - If this helped you,
tell application "System Settings"
activate
reveal pane id "com.apple.systempreferences.GeneralSettings"
delay 0.2
end tell
tell application "System Events"
tell process "System Settings"
click button 4 of group 1 of scroll area 1 of group 1 of list 2 of splitter group 1 of list 1 of window "General"
delay 0.2
end tell
end tell
tell application "System Events"
tell process "System Settings"
set airDropWindow to first window whose name contains "AirDrop & Handoff"
delay 0.2
tell airDropWindow
set switchGroup to checkbox 1 of group 3 of scroll area 1 of group 1 of list 2 of splitter group 1 of list 1
if exists switchGroup then
click switchGroup
else
display dialog "Switch control not found."
end if
end tell
end tell
end tell