From 1198487b96b7f008cdbec2c74a7229cf63fa86f2 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 23 Mar 2017 15:47:45 +0100 Subject: [beamergui] Use temp-file when passing data to parse-edid: Pipe can lead to partial reads, which parse-edid doesn't handle --- .../beamergui/data/opt/openslx/scripts/beamergui-mode_setter | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'core/modules/beamergui') diff --git a/core/modules/beamergui/data/opt/openslx/scripts/beamergui-mode_setter b/core/modules/beamergui/data/opt/openslx/scripts/beamergui-mode_setter index b7d6f04f..6a8c5e97 100755 --- a/core/modules/beamergui/data/opt/openslx/scripts/beamergui-mode_setter +++ b/core/modules/beamergui/data/opt/openslx/scripts/beamergui-mode_setter @@ -70,11 +70,14 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then BEAMER= MAYBEAMER= SMALL= + TF=$(mktemp) + [ -z "$TF" ] && TF="/tmp/${RANDOM}-$$" for i in 0 1; do # See if we hard-coded the device as a beamer # Use echo -e -n "" instead of piping the sed output into xargs printf, as xargs # handles backslashes differently depending on the version. - EDID=$( echo -e -n "$( <<<"$XRANDRV" grep -Pzo "\n${OUTPUTNAMES[$i]}\N*connected\N*\n(\s+\N*\n)+" | grep -Eao '[0-9a-f]{32}' | sed -r ':a;N;$!ba;s/[^0-9a-f]//gI;s/([0-9a-f]{2})/\\x\1/gI' )" | parse-edid ) + echo -e -n "$( <<<"$XRANDRV" grep -Pzo "\n${OUTPUTNAMES[$i]}\N*connected\N*\n(\s+\N*\n)+" | grep -Eao '[0-9a-f]{32}' | sed -r ':a;N;$!ba;s/[^0-9a-f]//gI;s/([0-9a-f]{2})/\\x\1/gI' )" > "$TF" + EDID=$( < "$TF" parse-edid ) MODEL_NAME=$( <<<"$EDID" awk '{if ($1 == "ModelName") { A=$2$3$4$5; print substr(A, 2, length(A) - 2)}}' ) echo "'${OUTPUTNAMES[$i]}' is connected to device '$MODEL_NAME'" # Have a name, do the checks @@ -110,6 +113,7 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then SMALL=yes fi done + rm -f -- "$TF" if [ -z "$BEAMER" ] && [ -n "$MAYBEAMER" ] && [ -n "$SMALL" ]; then # This is a hack on top of the other hack; we already treat outputs reporting a sufficiently large width # as beamers, as we have encountered such devices in the wild. However, we might have just a large TV connected -- cgit v1.2.3-55-g7522