Catalina Sidecar toggle

You can check the following:

  • You can specific the iPad name in the first line of the script (set iPadName to …). Otherwise the first entry with contains "iPad" will bee used
  • Maybe it does not work if the iPad name contains a character like ", because this is the string separator
  • The menu "Display" (̶c̶̶h̶̶e̶̶c̶̶k̶̶b̶̶o̶̶x̶̶ ̶"̶s̶̶h̶̶o̶̶w̶̶ ̶̶m̶̶i̶̶r̶̶r̶̶o̶̶r̶̶i̶̶n̶̶g̶̶ ̶̶o̶̶p̶̶t̶̶i̶̶o̶̶n̶̶s̶̶ ̶̶i̶̶n̶̶ ̶̶t̶̶h̶̶e̶̶ ̶̶m̶̶e̶̶n̶̶u̶̶ ̶̶b̶̶a̶̶r̶̶ ̶̶w̶̶h̶̶e̶̶n̶̶ ̶̶a̶̶v̶̶a̶̶i̶̶l̶̶a̶̶b̶̶l̶̶e̶"̶ ̶̶i̶̶n̶̶ ̶̶s̶̶e̶̶t̶̶t̶̶i̶̶n̶̶g̶̶s̶̶ ̶-->̶ ̶̶d̶̶i̶̶s̶̶p̶̶l̶̶a̶̶y̶̶s̶ Edit: Settings -> Dock & Menu bar -> Display) must be always visible in the menu bar

Edit:

You can trial this:

set iPadName to "olo's 12\" iPad."

or leave default value to:

set iPadName to "iPad"

Thanks I changed my iPad name to make it easier without any special characters. Still doesn't work. For some reason even with the box checked to always show mirroring options the icon is not in the menu bar unless I go to settings and turn on the mirroring or Sidecar.

Try this:

  • Open settings -> Dock & Menu bar
  • Click Display on the left site
  • Enable Checkbox "Show in menu bar"
  • Select "always" in the Drop Down field

Then the script must be work.

Guys, some major updates today. It's now language independent, and will select your iPad by default. No need to input your iPad name.

tell application "System Events"
	tell process "ControlCenter"
		try
			perform action "AXPress" of menu bar item "Control Center" of menu bar 1
		on error
			display dialog "Please make sure you are using macOS Big Sur and have Control Center showing on your menu bar"
		end try
		try
			tell checkbox 6 of group 1 of group 1 of window 1
				perform action "AXPress"
			end tell
			delay 1
		on error
			display dialog "Cannot find Displays in your control center"
		end try
		try
			tell checkbox 4 of group 1 of group 1 of window 1
				perform action "AXPress"
			end tell
		on error
			display dialog "Cannot find your ipad"
		end try
	end tell
end tell

For those are also using Alfred, this is my preset

1 Like

Seems to not be working again in MacOS 12.0.1

Everything seems to work as before, but will not select the iPad from the menu.

The Control Center no longer responds to click events from any script. But the version with the menu bar should still work with a small change.

Try this (I couldn't test it as I don't currently have an iPad):

set iPadName to "iPad"

tell application "System Events"
	tell application process "ControlCenter"
		repeat with tElement in menu bar items of menu bar 1
			if (exists attribute "AXTitle" of tElement) then
				if value of attribute "AXTitle" of tElement contains "Display" then
					set theBar to tElement
					tell theBar
						click
					end tell
					set tElements to entire contents of window 1
					set tElements to entire contents of window 1 -- bug in 12.x
					repeat with i from 1 to count of tElements
						set tElement to item i of tElements
						if (title of tElement contains iPadName) then
							tell tElement
								click
							end tell
							exit repeat
						end if
					end repeat
					tell theBar
						click
					end tell
					exit repeat
				end if
			end if
		end repeat
	end tell
end tell

Note: The menu "Display" (Settings -> Dock & Menu bar -> Display) must be always visible in the menu bar. See: Catalina Sidecar toggle - #23 by Dirk

1 Like

Can confirm that this does work. Wanted to follow up so that any others can know the answer is here.

Thanks!

Unfortunately this doesn't work on Monterey. Would be nice to have, and a toggle to enable/disable Universal Controls.