]> mj.ucw.cz Git - edid.git/commitdiff
edid-drm: Handle monitors in stand-by mode
authorMartin Mares <mj@ucw.cz>
Tue, 16 Apr 2024 14:26:12 +0000 (16:26 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 16 Apr 2024 14:26:12 +0000 (16:26 +0200)
edid-drm

index abe755d3397f02bd8fbdf68ef63488f0b88e5484..5e1bb90a9ede322f5ff5ff3ceee2827d2c4e037c 100755 (executable)
--- 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