How do I disable/enable an external monitor from terminal

I run two external monitors + my MBP display in OSX Yosemite. My middle external monitor is also connected to my PC.

The monitor will automatically switch to an active input, so for example if my mac is running all three monitors and my PC is on, I Can sleep my mac and the monitor will switch to my PC. Same thing fro switching from PC back to mac.

However, the mac will still consider the middle monitor as active, so items and the mouse disappear when on the middle monitor.

I'd like to have a terminal command or shell script I can quickly fire with finder to enable/disable either the external monitor or the HDMI port.

Plugging/unplugging the monitor every time (several times a day) is not an option. I know about SwitchResX but have no need for 95% of it and don't think it should be necessary to pay to disable a piece of hardware.


Solution 1:

Lunar can do this since version 4.8.0.

Press Ctrl+Cmd+6 while the cursor is on the display you want to turn off and Lunar will mirror another visible screen to the one you want to turn off and turn its brightness and gamma to 0: https://lunar.fyi/#blackout

Press Ctrl+Cmd+6 again to turn on the display.

Disclaimer: I’m the developer of Lunar