From 0da45161507ce0f944834483972234ab41c3ea2d Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 16 Apr 2024 16:26:12 +0200 Subject: [PATCH] edid-drm: Handle monitors in stand-by mode --- edid-drm | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/edid-drm b/edid-drm index abe755d..5e1bb90 100755 --- a/edid-drm +++ b/edid-drm @@ -1,10 +1,24 @@ #!/bin/sh +# Scan all output of all video cards known to Linux Direct Rendering Manager +# and identify connected displays. + set -e +exit_code=0 for a in /sys/class/drm/card*-* ; do - if [ -f $a/edid -a "$(cat 2>/dev/null $a/enabled)" = enabled ] ; then - echo "### $(basename $a) ###" - echo - $(dirname $0)/edid <$a/edid - echo + if [ -f $a/edid ] ; then + # This is tricky: for disconnected outputs, the edid file exists, + # but it is empty. Monitors in stand-by mode have the "enabled" + # attribute set to "disabled", but the edid file is still valid. + # Since the file is purely virtual, we need to copy it first. + x=$(mktemp) + cp $a/edid $x + if [ -s $x ] ; then + echo "### $(basename $a) ###" + echo + edid <$x || exit_code=1 + echo + fi + rm -f $x fi done +exit $exit_code -- 2.39.2