Over VNC, configure the system to not use a second monitor while it's physically connected

I have two monitors set up at work, with the external one set to a portrait configuration. When I attempt to VNC in to work remotely, this results in a HUGE (something like 1600x3000) because the virtual screen is the compositing of the two (with black bars where there is no monitor space).

As a result, the VNC connection is non-responsive.

I'd like to be able to login via ssh and disable the second monitor via some command-line command or script. What commands might accomplish this?

Again, I am remote, so disconnecting the screen is not an option, and mirroring results in a screen that is about 1440x1440 (so it will fit onto both monitors with no stretching), so that is also a non-optimal strategy.

Output from xrandr:

themachine% xrandr -q
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 640 x 480, current 2970 x 1680, maximum 2970 x 1702
default connected 2970x1680+0+0 0mm x 0mm
   1920x1080      60.0  
   640x480        60.0  
   800x600        60.0  
   1024x768       60.0  
   1280x1024      60.0  
   1280x720       60.0  
   1344x756       60.0  
   1600x900       60.0  
   1680x1050      60.0  
   2970x1680       1.0* 
   2970x1702       2.0  

Solution 1:

Depending on what type of Apple machine you are connecting to, you can try these commands and see if they work for you. I know they are used with X11..This is the command to disable dual screens (Assuming it's a laptop).

xrandr --output VGA --off

And if you want to this is a command to enable the dual screens (but might aid you in troubleshooting getting the secondary one off). LVDS is the liquid display and VGA is the secondary monitor.

xrandr --output VGA --mode 1024x768
xrandr --output VGA --right-of LVDS

Solution 2:

From @scottishwildcat's comment:

You can fire up the Screen Sharing app various ways, but easiest way for a machine whose IP or fully qualified domain name you know is to type vnc://w.x.y.z into Safari address bar, or "open vnc://w.x.y.z" into a Terminal. (You might need to add a colon followed by the port number, depending on how your server is set up--default is 5900). If you want to start it manually, you'll find it in /System/Library/CoreServices. For machines on your LAN, you can start it by selecting the machine in the Finder sidebar, then clicking Share Screen in the Finder toolbar.