Script for auto-switching between gpio LCD and HDMI doesn't work on my Raspberry Pi 3.

Software-related questions that don't fit into any of the specialized software categories go here.
Post Reply
greger
Posts: 1
Joined: Mon Feb 22, 2021 5:24 pm

Script for auto-switching between gpio LCD and HDMI doesn't work on my Raspberry Pi 3.

Post by greger » Mon Feb 22, 2021 5:31 pm

Hi. I'm want to auto-switch between a gpio LCD and HDMI-Out on a Raspberry Pi 3.
I found this guide that I'm trying to follow: https://www.reddit.com/r/raspberry_pi/c ... d_hdmiout/

So I made two different config files, config_lcd.txt and config_hdmi.txt
And now I'm trying to run this script in "/recalbox/share/system/custom.sh", but it doesn't work correctly.
It just says: "device_name=RTK-32V3H-H6A" when I have the both the LCD and HDMI connected. But it never reboots and change the output to the HDMI.


What have I done wrong?

Code: Select all

#!/bin/bash

#HDMI connection?
rm -f hdmi.name
tvservice -n 2>hdmi.name
HDMI_NAME=$(cat hdmi.name)
#echo $HDMI_NAME
if [ "$HDMI_NAME" == "[E] No device present" ]; then
	LCD_ON=$(grep "hdmi_drive=2" /boot/config.txt)
#	echo $LCD_ON
#	echo "LCD On"
	if [ "$LCD_ON" == "hdmi_drive=2" ]; then
#		echo "reboot to LCD"
		sudo rm -f /boot/config.txt
		sudo cp /boot/config_lcd.txt /boot/config.txt
		sudo reboot -n
	fi
else
	HDMI_ON=$(grep "lcd_rotate=2" /boot/config.txt)
#	echo $HDMI_ON
#	echo "HDMI ON"
	if [ "$HDMI_ON" == "lcd_rotate=2" ]; then
#		echo "reboot to HDMI"
		sudo rm -f /boot/config.txt
		sudo cp /boot/config_hdmi.txt /boot/config.txt
		sudo reboot -n
	fi
fi

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests