Linux/Xubuntu: Solve HDMI disconnection caused by non-supported resolution

PHOTO EMBED

Mon Aug 29 2022 13:53:13 GMT+0000 (UTC)

Saved by @marcopinero #bash

##sudo nano /etc/udev/rules.d/95-monitor-hotplug.rules

SUBSYSTEM=="drm", RUN+="/usr/local/bin/fix_tv_state.sh"

##---------------------



##sudo nano /usr/local/bin/fix_tv_state.sh

#!/bin/sh
#Fix TV state when HDMI link is lost.

export XAUTHORITY=/home/marco/.Xauthority

OUTPUT="HDMI1"
BAD_MODE="1280x720"
GOOD_MODE="1920x1080"

for MODE in $BAD_MODE $GOOD_MODE; do
 sleep 2
 DISPLAY=:0 xrandr --output $OUTPUT --mode $MODE
 sleep 2
done

##--------------------

sudo chmod +x /usr/local/bin/fix_tv_state.sh
sudo udevadm control --reload-rules

content_copyCOPY

Change from HDMI back to TV, then back again. Screen comes on after a couple of seconds. Change the sleep times to suit.