I'm using the 7" official Raspberry Pi touchscreen, attached with a ribbon, on an RPi 3 Raspbian Jesse. This screen does not support displaying on both it and HDMI output simultaneously, so I can only view one or the other at a given time. I've learned that if I add:
to /boot/config.txt, then restart, it will boot up displaying on the HDMI output (if available). So far so good, but what I'm trying to figure out is if I can toggle one display or the other after boot, and if not, how would I at least detect if there is an HDMI connection on boot so I can default to that if available?
The closest I've found is Touchscreen w/ HDMI output only when a display is attached?, but I don't have an xorg.conf file and I've learned that it's been deprecated for a bit now.
I've also read that uncommenting
hdmi_force_hotplug=1 in boot/config.txt will default to the HDMI source if available, but that only seems to work 1/10 of the time. Usually the touchscreen takes preference.