For example, I want to output a 320x240 resolution to a composite monitor if no HDMI connection is found. Otherwise, output to HDMI as usual.

Is this possible? Can I edit something in config.txt or somewhere else? Can you use if-statements in config.txt?

  • If you are using the X server for a GUI, I'm pretty sure the answer is yes. You can dynamically adjust the resolution w/ xset at any point; for what you want to do, you'd have to write some kind of short script to detect which output is in play.
    – goldilocks
    Commented Jun 4, 2015 at 19:49
  • I do not have an answer to your question. My Pi detects if hdmi is connected at boot and if not defaults to PAL. tvservice -s will show state e.g. state 0x80001 [PAL 4:3], 720x576 @ 50.00Hz, interlaced. I do not know if the default size can be changed.
    – Milliways
    Commented Jun 5, 2015 at 0:33

3 Answers 3


I don't think that is possible, config.txt is read by the bootloader with very limited resources. But please look at this posting - it gives you a good suggestion on how to do this using a GPIO-based VGA adapter: Multiple Display Screens

  • Unfortunately, using the GPIO pins isn't an option for me. Also, I don't need to use these screens simultaneously--it's an either/or situation.
    – quinten
    Commented Jun 4, 2015 at 18:06

Unfortunately, there's no way you could do this with built in functionality. The bootloader loads config.txt when the system starts, and once the system is up, that's it.

You could write a python/bash/ruby/whatever script that will swap out your config.txt config for a different one and restart the system. This of course assumes that restarting the system is an acceptable solution.


well... if you use either the composite or hdmi monitor (with useful tvservice -n-output) and the right one is already connected at the boot time (hotplugging won't change anything because the config.txt is read once at boot) you can probably use the [EDID=*]-filter in the config.txt!

please have a look at the real good Raspberry Pi documentation for the config.txt:
at the end there is a section about the filters (also the [EDID=*]-filter), and then you have to sort out your desired configurations for your hdmi monitor... the [all]-settings will be for the composite.

if you are not using always he same hdmi monitor you have to try multiple [EDID=*]-filters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.