Rpi4 - switching between different resolution HDMI outputs with one click

  • Hi all,

    This here is not so much a genius invention, as it just is a solution to a problem I was facing for a while now. Since now I have a simple & easy solution, I thought I'd share. There simply isn't much documentation yet for dual screen setups on the new Rpi4.

    My wish

    I run a small media player that during the day plays music, and displays tracks on a small 7 inch display connected to hdmi port 1 & is built into a case. In the evenings, if I'd like to watch Netflix or a movie, it is connected to a projector on hdmi port 0. So far, I always had difficulty switching displays without physically changing ports and resolutions in the config.txt.

    My solution (given that my system's built in display already worked)

    1. SSH in and make sure your config file can be edited using the following command:

    1. mount -o remount,rw /flash

    2. make a copy of the config file using:

    1. cp config.txt config1.txt

    3. open the config1.txt like so:

    1. nano /flash/config.txt

    4. edit the config1 file so that it works with the projector. Obviously test this yourself to confirm it working. For me I added the following:

    5. config.txt is already confirmed working with the built-in display and looks like this:

    6. finally rename config1.txt to config.dat to render it "inactive":

    1. mv config1.txt config.dat

    Now we need something to switch the config files automatically. I used plink to switch config files by simply renaming them config.dat <> config.txt. If i move the naming back and forth, the display is switched after a reboot.

    1. On the PC i created a .bat file with the following command:

    1. plink [email protected] -pw password -m C:\Users\"my username"\configswitch.txt

    2. The configswitch.txt is a file saved at the patch described in step 1. It contains instructions to rename the files as follows:

    1. mount -o remount,rw /flash
    2. cd ..
    3. cd /flash
    4. mv config.txt config1.dat
    5. mv config.dat config.txt
    6. mv config1.dat config.dat
    7. cd ..
    8. mount -o remount,ro /flash
    9. reboot

    It changes the file permissions to allow writing. Then navigates to the folder and renames the files so they end up switched around. Afterwards I make the files read-only again. Finally the system reboots.

    3. Save the .txt and .bat file & use the .bat to switch & reboot whenever you want.

    Et voila! a simple and crude way to switch displays at the click of one button! I know this is not how LibreELEC is supposed to work, but because I was lacking means to find another solutions, this works pretty well!

    EDIT: some errors in the config upon creating this post

    Edited once, last by Revers3 ().