How To Initiate Sidecar From iOS

Sidecar is wonderful and adds a huge amount of functionality to an already awesome iPad Pro 12.9” - but let’s say that I want to connect to a headless Macbook Pro (or Mac Mini) in the future. How can I initiate Sidecar from the iPad end of the equation?

After much searching I concluded that Sidecar does not have a CLI, or at least not one I can find discussed at all.

The Solution - AppleScript & SSH

While old and not overly well maintained, AppleScript has a huge amount to offer with regards to MacOS automation. Simply create a file initiateSidecar.scpt wherever suits you.

activate application "SystemUIServer"
tell application "System Events"
    tell process "SystemUIServer"
        set displayMenu to (menu bar item 1 of menu bar 1 whose description contains "Displays")
        tell displayMenu
            delay 1
            tell (menu item "iPad" of menu 1)
            end tell
        end tell
    end tell
end tell

You can call AppleScript on the commandline with osascript yourScriptName.scpt. Just be aware that the first time you run it you will need to grant some extra permissions, so it will not work on first-run.

Then, from your iPad end, create a Shortcut that runs a SSH command on your Mac and add it to your homescreen widget - download it here! Easy!

Shortcut to initiate Sidecar from iOS
(📷: Finn LeSueur) Shortcut to initiate Sidecar from iOS

This has already been a huge improvement for me. Enjoy!