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:

    Code
    mount -o remount,rw /flash

    2. make a copy of the config file using:

    Code
    cp config.txt config1.txt

    3. open the config1.txt like so:

    Code
    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":

    Code
    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:

    Code
    plink root@ipaddress -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:

    Code
    mount -o remount,rw /flash
    cd ..
    cd /flash
    mv config.txt config1.dat
    mv config.dat config.txt
    mv config1.dat config.dat
    cd ..
    mount -o remount,ro /flash
    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 (January 10, 2020 at 11:19 AM).

  • Hi, sorry, but was not able to make it work on rpi4 and 19.4 matrix.

    Have beamer with low res and 1280 res TV.

    When I have plugged both devices to connectors on rpi4, every time Kodi detects HDMI0 = TV, it switches from beamer on HDMI1 to TV.

    The only thing your solution makes for me is the start up.

    From the start of rpi when switched to HDMI1, it sends splash screen with LIBREELEC logo to beamer but..

    When initial theme should appear, Kodi detects TV and send the screen again to HDMI0. Beamer has nothing.

    I have ignored CEC for both 0 and 1 in config.txx but was not succesful.

    The only solution working for me is to unplug HDMI0 from rpi (manually) and Kodi auto switches to beamer on HDMI1.

    It seems like Kodi detects both HDMIs and when there is nothing on 0, it uses 1. That would be enough.. but.. switching TV off does not solve detection of TV, it still "is there"..

    Really frustrating to disconnect it all the time. I have spend 3 days playing with it using different distros, but every one has some issue (no DVB support, no source codes, no repo for this, not working CEC and so and so.. On the other hand, what every other distro compared to Libre can do and Libre not is to mirror HDMI outputs.. mission impossible..)

    If duplicating output is nightmare, I thought switching them might be a solution.. Well.. might :) Plugin for this would be VERY WELCOME

    Roman

  • LE 10 / Kodi Matrix has moved from firmware display driver (fkms - controlled with config.txt) to a standard kernel display driver (kms controlled with cmdline.txt).

    I think what you are asking to do is to have both hdmi ports connected, but be able to switch which one is disabled.

    Have a look here.

    I think if you add to cmdline.txt (end of existing line):

    Code
    video=HDMI-A-1:D video=HDMI-A-2:d

    Then the first hdmi port will be enabled, and the second will be disabled. If instead you do:

    Code
    video=HDMI-A-1:d video=HDMI-A-2:D

    Then the first hdmi port will be disabled, and the second will be enabled.

    Note that CEC only works (with LE) on the first hdmi port, so if you use that with one display, then make sure it is first.