Skip to content

Instantly share code, notes, and snippets.

@popeyelau
Last active March 19, 2020 05:23
Show Gist options
  • Save popeyelau/5c2165b850069047819ddd1a79f65c3c to your computer and use it in GitHub Desktop.
Save popeyelau/5c2165b850069047819ddd1a79f65c3c to your computer and use it in GitHub Desktop.
iMac Target Display Mode|-|{"files":{"TDM.md":{"env":"plain"}},"tag":"Gists"}

start.sh

# start.sh
osascript -e 'tell application "System Events" to key code 144 using command down'
echo "  🖥   Target Display Mode Started..."
blueutil off
echo "  🔵   iMac Bluetooth off..."
exit

end.sh (You need turn off your macbook bluetooth first.)

# end.sh
sleep 5
blueutil on
echo "  🔵   iMac Bluetooth on..."
sleep 5
echo "  🖥   Target Display Mode command..."
osascript -e 'tell application "System Events" to key code 144 using command down'
echo "  ✅   Target Display Mode Ended..."
exit

Put start.sh & end.sh in your iMac. SSH into your iMac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment