Sidecar to a headless Mac from iPad

Sidecar is a tent-pole feature of MacOS Catalina, giving users the ability to use an iPad as a second-screen in a pinch with flawless performance locally—wired or wirelessly. However, the typical process to initiate Sidecar involves having your Mac in front of you.

What if you want to Sidecar remotely—for example a headless Mac Mini running in my locker? Let’s find out.

Using Sidecar to code on iPad Pro
Using Sidecar to code on iPad Pro

AppleScript and Shortcuts

First, we need to create a script on our Mac to initiate Sidecar. Open Script Editor, create a new script and enter the code below, replacing Edward’s iPad Pro with the name of your iPad. Make sure to use the correct type of apostrophe—this originally caught me out. Save the script in a suitable place—I named it Sidecar.scpt and put it in Documents.

property iPadName : "Edward’s iPad Pro"

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
			click
			delay 0.1
			tell (menu item iPadName of menu 1)
				click
			end tell
		end tell
	end tell
end tell

Second, go to System Preferences / Displays and make sure to check ‘Show mirroring options in the menu bar when available.’

Third, go to System Preferences / Sharing and enable ‘Screen Sharing’ and ‘Remote Login’. Take note of the address below your Computer Name on this page. This will be important for our next step.

On our iPad, create a new Shortcut and add the ‘Run script over SSH’ action. Click ‘Show more’, and add the following:

  • Host: Use the address that was below the Computer Name in System Preferences / Sharing in the previous step. Mine is Edwards-MacBook-Pro.local
  • Port: 22 (Default)
  • User: Your user account’s name on the Mac
  • Authentication: Password (Default)
  • Password: Your user account’s password on the Mac
  • Input: Choose variable (Default)
  • Script: osascript ~/Documents/Sidecar.scpt (If you used a different file name or or saved the script to a different location, update the script accordingly)
Run Script over SSH' action
‘Run Script over SSH’ action

🎉 And that’s it! Trigger your new Shortcut and watch Sidecar magically and remotely launch on your iPad.

Tips

  • Go to System Preferences / Displays and check ‘Optimise for Sidecar Display’.
  • The experience is greatly improved when using a keyboard—especially with the Smart Keyboard Folio. Almost all keyboard shortcuts work correctly.
  • The Touchbar shows on the bottom (by default) and provides an extra row of features for apps.
  • The Sidebar shows on the left with helpful shortcuts.

Caveats

  • You can’t use cmd + tab to switch between windows on the Mac—it instead brings up the App Switcher for the iPad.
  • You can scroll with a two-finger drag, but you can’t click with a tap using your finger—only with the Apple Pencil.

Conclusion

Sidecar is a fantastic option to control your local Mac. There are plenty of alternative apps—for example Screens or Luna Display—but something about the built-in approach that Sidecar provides makes me drawn to this solution, at least for my Mac Mini at home.