How check if the HDMI is plugged in Shell Script ?



  • How check if the HDMI is plugged in Shell Script ?


  • Moderator
    Team

    @israel-neves Check the tvservice command



  • i build a 3.5 tft with recalbox, the thing is, the tvservice -s with HDMI plugged and not, gives the same answer



  • Here the script that i want to run with S99custom

    #!/bin/bash
    
    
    IFS='  ' read -r -a array <<< "$(tvservice -s)"   # THIS LINE ! tvservice -s give the same answer with or without HDMI plug
    echo "${array[1]}"
    if [ "${array[1]}" == "0x12000a" ]; then
    	echo "Sem HDMI"
    	if [ "$(cat /boot/tela.txt)" == "hdmi" ]; then
    		echo "Sem HDMI e setado como HDMI, setando como LCD"
    		mount -o remount, rw /boot
    		mount -o remount, rw /
    		cp /boot/configLcd.txt /boot/config.txt
    		echo "lcd" > /boot/tela.txt
    		sh ./recalbox/scripts/recalbox-save-overlay.sh
    		reboot
    	else
    		echo "Sem HDMI, tela setada como LCD"
    		start-stop-daemon -S -q -m -b -p /var/run/fbcp.pid --exec /usr/bin/fbcp -- -n
    	fi
    	else
    		echo "HDMI Conectado"
    		if [ "$(cat /boot/tela.txt)" == "lcd" ]; then
    			echo "Sem HDMI e setado como HDMI, setando como LCD"
    		mount -o remount, rw /boot
    		mount -o remount, rw /
    		cp /boot/configHdmi.txt /boot/config.txt
    		echo "hdmi" > /boot/tela.txt
    		sh ./recalbox/scripts/recalbox-save-overlay.sh
    		reboot
    		fi
    fi
    
    test -e "/recalbox/share/system/custom.sh" && /recalbox/share/system/custom.sh $1
    

Log in to reply
 

Want to support us ?

Join us on :

318
Online

28162
Users

14423
Topics

109153
Posts

Looks like your connection to Recalbox Forum was lost, please wait while we try to reconnect.