Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

Command execution when HDMI or composite is detected



  • I have two script files, called hdmi and rca. They're basically doing a dirty job for preparing my setup for HDMI and composite (CRT TV).

    ./hdmidoes the following:

    #!/bin/bash
    mv /opt/retropie/configs/all/{videomodes.cfg,videomodes1.cfg}
    mv /opt/retropie/configs/all/retroarch/shaders/shaders/{crt-pi1.glsl,crt-pi.glsl}
    

    And ./rca is this:

    #!/bin/bash
    mv /opt/retropie/configs/all/{videomodes1.cfg,videomodes.cfg}
    mv /opt/retropie/configs/all/retroarch/shaders/shaders/{crt-pi.glsl,crt-pi1.glsl}
    

    Videomodes.cfg contains 240p signal settings which is a no-no for HDTVs while renaming crt-pi results in easily switching on/off my default shader that looks terrible on a CRT TV.

    I'm pretty happy with those but I have to run each script everytime I switch cables. Any solution for them to be executed on boot when each output is detected? Thanks in advance.


  • Global Moderator

    @matchaman Have you tried playing with the tvservice command to check if the HDMI is connected ? You could run the hdmi script if the HDMI is on, or the rca script otherwise.

    $ tvservice -s
    [HDMI CEA (16) RGB lim 16:9], 1920x1080 @ 60.00Hz, progressive
    


  • Thanks :)

    It seems that tvservice -s outputs the info to egrep so I simply addedthe following lines to rc.local before exit 0

    if (/usr/bin/tvservice -s | /bin/egrep 'HDMI|DVI') ; then
    /home/pi/hdmi
    else
    /home/pi/rca
    fi
    

    Simple and neat!



Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.