Files
RDtop/bin/hdmi-fallback.sh
Deploy Bot 4d4b04d7bb feat: RDtop RustDesk headless fallback for Intel iGPU
- Adds VIRTUAL1 as permanent primary output via modesetting driver
- HDMI1 set as clone (--same-as) of VIRTUAL1
- hdmi-fallback.sh script monitors drm connector status
- systemd user unit auto-creates VIRTUAL1 and switches on hotplug loss
- Xorg fallback guarantees 1920x1080 framebuffer without HDMI
- Includes xserver-xorg-video-dummy as backup driver
2026-05-13 23:49:15 +01:00

55 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
LOG="$HOME/.local/logs/drm-hotplug.log"
mkdir -p "$HOME/.local/logs"
export DISPLAY=:0
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') $1" | tee -a "$LOG" 2>&1
}
log "Start monitor (user=$USER, display=$DISPLAY)"
CONNECTOR=""
for p in /sys/class/drm/card1-HDMI-A-1 /sys/class/drm/card0-HDMI-A-1; do
[ -e "$p/status" ] && { CONNECTOR="$p"; break; }
done
[ -z "$CONNECTOR" ] && CONNECTOR=$(find /sys/class/drm -maxdepth 1 -name "*HDMI-A-1" -type d | head -1)
if [ -z "$CONNECTOR" ] || [ ! -e "$CONNECTOR/status" ]; then
log "ERROR: No HDMI-A-1 found"
exit 1
fi
MODE_NAME="1920x1080_60.00"
if ! xrandr 2>/dev/null | grep -q "$MODE_NAME"; then
xrandr --newmode "$MODE_NAME" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 2>/dev/null || true
fi
xrandr --addmode VIRTUAL1 "$MODE_NAME" 2>/dev/null || true
LAST_STATE=$(cat "$CONNECTOR/status" 2>/dev/null || echo unknown)
log "Initial: $LAST_STATE"
if [ "$LAST_STATE" != "connected" ]; then
log "Initially disconnected, activate VIRTUAL1"
xrandr --output HDMI1 --off 2>/dev/null || true
xrandr --output VIRTUAL1 --mode "$MODE_NAME" --primary 2>/dev/null || true
fi
while true; do
CURRENT=$(cat "$CONNECTOR/status" 2>/dev/null || echo unknown)
if [ "$CURRENT" != "$LAST_STATE" ]; then
log "Change: $LAST_STATE -> $CURRENT"
if [ "$CURRENT" = "connected" ]; then
xrandr --output VIRTUAL1 --off 2>/dev/null || true
xrandr --output HDMI1 --auto --primary 2>/dev/null || true
log "HDMI1 primary"
else
xrandr --output HDMI1 --off 2>/dev/null || true
xrandr --output VIRTUAL1 --mode "$MODE_NAME" --primary 2>/dev/null || true
log "VIRTUAL1 primary"
fi
LAST_STATE="$CURRENT"
fi
sleep 2
done