Purpose: Use the iPad as the only main display for the Mac mini
Operation Document#
Created January 21, 2025
Creator Xiao Yu Share
Principle Analysis#
↓ Mind Map
- Explanation:
- Here I made a sketch
- Briefly explain the principle
- The iPad and Mac mini need to be connected to the same Wi-Fi
- The iPad uses the ssh command to find the Mac mini and start the Sidecar script code
- The Mac mini will first check if there are available displays
- Since there is no display, the iPad cannot enable Sidecar
- Therefore, we need to create a virtual screen to pass the Mac mini's self-check
- This way, the Mac mini can transmit the video image to the iPad
System Requirements for Enabling Sidecar#
Mac mini Operation Section#
↓ The detailed operation steps for Mac mini M4 are as follows
- Search → Automator → Click New Document → Select Application → Search AppleScript
-
Copy the code into AppleScript
-
Sidecar Code
- Change “This is the name of your iPad” to the iPad name
- Followship connected ⇒ Sidecar connected
- Not found ⇒ Not found
on findLastTargetIndex(targetItem, itemList) set lastIndex to 0 repeat with i from (count of itemList) to 1 by -1 if item i of itemList is targetItem then set lastIndex to i exit repeat end if end repeat return lastIndex end findLastTargetIndex beep 1 beep 1 tell application "System Settings" activate delay 1 tell application "System Events" tell process "System Settings" -- Click the "Display" menu item in the menu bar click menu item "显示器" of menu "显示" of menu bar item "显示" of menu bar 1 delay 0.3 tell group 1 of group 2 of splitter group 1 of group 1 of window "显示器" try -- The system settings need time to load the right side interface after a cold start delay 1 click pop up button "添加" -- Get the names of all menu items in the "Add" menu set menuItems to name of menu items of menu "添加" of pop up button "添加" -- Find the index of the last matching item by name set targetIndex to (my findLastTargetIndex("这里是自己iPad名称", menuItems)) -- Click the target menu item delay 0.3 click menu item targetIndex of menu "添加" of pop up button "添加" say "Sidecar connected" on error delay 0.5 say "Not found" end try end tell end tell end tell end tell delay 1 beep 1 -- Optional: Exit System Settings -- tell application "System Settings" to quit
-
iPad Name
-
- Run the code
-
Permissions need to be enabled before running
-
System Settings → Privacy & Security → Accessibility → Turn on (Enable Sidecar, Automator)
-
-
Run the code and check if it takes effect
-
- Save the code
- Name: Enable Sidecar
- Run Error
-
AppleScript “Enable Sidecar” does not allow accessibility access
-
Solution
- Allow Accessibility Apps to Access Your Mac
- There is a point to note here: Privacy & Security → Accessibility → Enable Sidecar (After deleting, re-add and enable)
-
iPad Operation Section#
↓ The detailed operation steps for iPad 9 are as follows
-
Click → Shortcuts → Click Add → Click Search on the right → ssh → Select Run Script Over SSH
-
View the host IP address, enter the command
open -a Enable Sidecar
, -
Host IP
-
Rename: Enable Sidecar
-
Add to Home Screen
-
-
Error when running ssh script
🔔: Unable to connect to ssh remote server?
-
System Settings → General → Sharing → Turn on Remote Login
-
System Settings → Search: Shortcuts → Click: Advanced → Turn on: Allow Running Scripts
-
MacOS Create Virtual Screen#
🔔: When we unplug the display cable, we cannot enable Sidecar.
🔔: We trick the MacOS system by creating a virtual screen.
-
Download the software Better Display
-
If you cannot download BetterDisplay normally, you can obtain it through a cloud disk
The file shared via cloud disk: BetterDisplay-3.5.6.zip
Link: https://pan.baidu.com/s/1zRfTNNyPqz64Q-n5kx4A5g Extraction code: xyfx Copy this content and open the Baidu Cloud Disk mobile app for easier operation -
Create a virtual screen → Random selection
-
Set Better Display to start automatically on boot
-
Set the virtual screen as Manage Display (Main Display)
Effect Display#
- Mac mini starts up, blindly typing the startup password, iPad one-click to enable Sidecar function