#!/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