14

I have an older iMac which I am retiring as a display. It works well enough in target display mode, but I have keep the keyboard around just to switch it to display mode.

Is there a way to

  • boot the iMac into target display mode
  • start target display mode remotely, such as from the console?
2
  • were you able to solve this? Commented Nov 23, 2021 at 2:48
  • @simplegamer Not reliably. I did try VirtualKVM, and it sometimes worked. I now keep an old keyboard in the draw. All of this will soon be moot, as current model Macs don’t support target display, so I’m looking at alternmative solutions such as Luna Display from Astropad.
    – Manngo
    Commented Nov 23, 2021 at 2:58

5 Answers 5

9

There are two options that I'm aware of which may meet your needs:

  1. Use the 1Keyboard app. This allows you to pair your computers via bluetooth and then use 1Keyboard to send the CommandF2 keyboard shortcut. It basically allows you to use one keyboard with multiple devices.
  2. Use VirtualKVM. This was designed specifically for people wanting to use their iMacs in target display mode, and works especially well in situations where you want to connect a MacBook to the iMac. For example, if you plug your MacBook into your iMac via Thunderbolt, this extention will automatically switch the iMac to Target Display Mode, allowing you to use your iMac as a monitor. It also switches off the Bluetooth on the iMac, freeing up your mouse and keyboard to pair with your MacBook (assuming you're using a bluetooth keyboard and mouse). When you unplug the MacBook, the iMac's Bluetooth will be powered back up and the monitor restored.

The above options should work fine. If you're a more advanced user, you could also check out this Super User question.

2
  • 2
    Option 1 did not work for me using macOS Mojave 10.14.5 and 1Keyboard version 2.6.
    – Johan
    Commented Jul 22, 2019 at 10:09
  • 1
    None of the options work. 1Keyboard doesn't work when the Target Display Mode is on, once the Target Display Mode is disabled, 1Keyboard starts to work again. And Virtual KVM needs a keyboard connected to switch to Target Display Mode, if no keyboard is connected, it just turns off the Bluetooth on the iMac but doesn't trigger the Target Display Mode change.
    – ElChiniNet
    Commented Apr 26, 2020 at 16:26
1

You can start Target Display Mode via SSH from other macs in the local network.

1
  • 1
    That is a modified version of this one, and as it states: As far as I know you need an official Apple keyboard connected when you’re running these scripts, even if you’re emulating the keyboard commands with code.
    – ElChiniNet
    Commented Apr 26, 2020 at 16:37
1

I was actually researching the same problem today and found a solution to the remote switching issue.

Apple Keyboard Emulator to switch remotely switch Target Display Mode of an iMac without a physically connected keyboard Problem What you need Step 1:

Download and install the Arduino IDE (I did this with version 1.8.12)

Step 2:

Modify the Arduino Leonardo board description in /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/boards.txt in the Arduino IDE app package to include the necessary USB descriptor to match the following:

leonardo.name=Arduino Leonardo
leonardo.vid.0=0x2341
leonardo.pid.0=0x0036
leonardo.vid.1=0x2341
leonardo.pid.1=0x8036
leonardo.vid.2=0x2A03
leonardo.pid.2=0x0036
leonardo.vid.3=0x2A03
leonardo.pid.3=0x8036

leonardo.upload.tool=avrdude
leonardo.upload.protocol=avr109
leonardo.upload.maximum_size=28672
leonardo.upload.maximum_data_size=2560
leonardo.upload.speed=57600
leonardo.upload.disable_flushing=true
leonardo.upload.use_1200bps_touch=true
leonardo.upload.wait_for_upload_port=true

leonardo.bootloader.tool=avrdude
leonardo.bootloader.low_fuses=0xff
leonardo.bootloader.high_fuses=0xd8
leonardo.bootloader.extended_fuses=0xcb
leonardo.bootloader.file=caterina/Caterina-Leonardo.hex
leonardo.bootloader.unlock_bits=0x3F
leonardo.bootloader.lock_bits=0x2F

leonardo.build.mcu=atmega32u4
leonardo.build.f_cpu=16000000L
leonardo.build.vid=0x05ac
leonardo.build.pid=0x0221
leonardo.build.usb_product="Apple Keyboard"
leonardo.build.usb_manufacturer="Apple Computer, Inc."
leonardo.build.board=AVR_LEONARDO
leonardo.build.core=arduino
leonardo.build.variant=leonardo
leonardo.build.extra_flags={build.usb_flags}
Step 3:

Start/restart the Arduino IDE, open an example sketch for the keyboard library (I used the Keyboard Message Send example). Plug in the Arduino Leonardo compatible board and upload the sketch. Plug the Arduino into the iMac to be used in Target Display Mode

Step 4:

Create a script (here I named it switchTDM.sh) to send the CMD+F2 keyboard command telling the iMac to switch in or out of Target Display Mode. Put this script in the user directory (/users/<USERNAME>).

#!/bin/sh
# switchTDM.sh script
osascript -e 'tell application "System Events" to key code 144 using command down'
echo 'Sent TDM switch signal.'

Modify the script to be executable:

chmod +x switchTDM.sh
Step 5:

Enable SSH access to the TDM iMac by enabling "Remote Login" in the sharing options of the System Preferences. And test whether you can login from a remote machine using:

ssh <USERNAME>:<PASSWORD>@<IP or hostname of iMac>
Step 6:

Bind the call to the remote script to a keyboard shortcut. I use BetterTouchTool: Add a new keyboard shortcut and execute the following terminal command:

ssh <USERNAME>:<PASSWORD>@<IP or hostname of iMac> ~/switchTDM.sh
That's it

Use your defined keyboard shortcut to switch your iMac in and out of Target Display Mode.

0

I was able to switch it with just a mouse connected. Source

  1. Go to System Preferences > Keyboard.
  2. Check the box that says "Show keyboard and emoji viewers in menu bar."
  3. Click the icon in the Menu Bar with the Command () symbol in it, and choose "Show Keyboard Viewer."
  4. The keyboard will show up on your screen. You can click on letters to insert them in documents, or watch them become highlighted when you type on the actual keyboard.
  5. Double click on Cmd and then click on F2.

Blockquote

2
  • the double click does not seem to engage a key combination, F2 or otherwise. For example, I can't even CMD + C to copy some text with the clickable keyboard. This really worked for you?
    – Esten
    Commented Nov 18, 2020 at 18:01
  • Same comment as Esten Commented Nov 23, 2021 at 2:18
-2

forget it! you can't enter target display mode without a physical keyboard connected on your iMac

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .