From f2a42498ec2fbf1daff5a3dc5b14cac00205a9d8 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 28 Feb 2017 20:55:05 +0100 Subject: [beamergui] TIL: <<<$A != <<<"$A" --- .../data/opt/openslx/scripts/beamergui-mode_setter | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (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 9859c6c2..2cfd0c2d 100755 --- a/core/modules/beamergui/data/opt/openslx/scripts/beamergui-mode_setter +++ b/core/modules/beamergui/data/opt/openslx/scripts/beamergui-mode_setter @@ -45,8 +45,8 @@ echo "$XRANDR" # This is a rigid approach to determine the connected outputs declare -a OUTPUTNAMES while read -r line || [[ -n "$line" ]]; do - OUTPUTNAMES+=("$( <<<$line awk '{print $1}' )") -done < <( <<<$XRANDR grep -E "[[:digit:]]+mm x [[:digit:]]+mm" ) + OUTPUTNAMES+=("$( <<<"$line" awk '{print $1}' )") +done < <( <<<"$XRANDR" grep -E "[[:digit:]]+mm x [[:digit:]]+mm" ) echo -e "Connected outputs: \e[32m${OUTPUTNAMES[@]}\e[0m" # The goal is to add more modelines to the X server. While this is done the @@ -64,8 +64,8 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then SMALL= for i in 0 1; do # See if we hard-coded the device as a beamer - EDID=$( <<<$XRANDRV grep -Pzo "\n${OUTPUTNAMES[$i]}\N*connected\N*\n(\s+\N*\n)+" | grep -Eao '[0-9a-f]{32}' tmp | sed -r ':a;N;$!ba;s/[^0-9a-f]//gI;s/([0-9a-f]{2})/\\\\x\1/gI' | xargs printf | parse-edid ) - MODEL_NAME=$( <<<$EDID awk '{if ($1 == "ModelName") { A=$2$3$4$5; print substr(A, 2, length(A) - 2)}}' ) + EDID=$( <<<"$XRANDRV" grep -Pzo "\n${OUTPUTNAMES[$i]}\N*connected\N*\n(\s+\N*\n)+" | grep -Eao '[0-9a-f]{32}' tmp | sed -r ':a;N;$!ba;s/[^0-9a-f]//gI;s/([0-9a-f]{2})/\\\\x\1/gI' | xargs printf | 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 if [ -n "$MODEL_NAME" ]; then @@ -88,7 +88,7 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then fi fi # Classic test by what X(randr) figured out - WIDTH=$( <<<$XRANDR grep -E "^${OUTPUTNAMES[$i]}.*[0-9]+mm x [0-9]+mm" | head -n 1 | grep -o -E ' [0-9]+mm x' | grep -o -E '[0-9]+' ) + WIDTH=$( <<<"$XRANDR" grep -E "^${OUTPUTNAMES[$i]}.*[0-9]+mm x [0-9]+mm" | head -n 1 | grep -o -E ' [0-9]+mm x' | grep -o -E '[0-9]+' ) if [ -z "$WIDTH" ] || [ "$WIDTH" -eq 0 ] || [ "$WIDTH" -gt 900 ]; then echo "Screen $i is beamer, width is '$WIDTH'" BEAMER=$i @@ -114,14 +114,14 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then # Add the modes to the outputs, this means that, if this action is # successful they can be applied to the screens. for i in "${MODES[@]}"; do - if xrandr --current --newmode "$i"; then # > /dev/null 2>&1 + if xrandr --current --newmode $i; then # No quotes around $i here! echo -e "Created mode ${i%% *}." else echo -e "\e[31mFailed to create mode ${i%% *}!\e[0m" fi for j in "${OUTPUTNAMES[@]}"; do - if xrandr --current --addmode "$j" "$( <<<$i awk '{print $1;}' )"; then + if xrandr --current --addmode "$j" "${i%% *}"; then echo -e "Added mode ${i%% *} to $j." else echo -e "\e[31mFailed to add mode ${i%% *} to $j!\e[0m" @@ -133,13 +133,13 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then # Finally, if the EDID is present, apply a proper resolution. # Find out whether the beamer transmits reliable EDID data. # The data in xrandr should be reliable if the EDID is present. - if <<<$XRANDRV grep -Pzo \ + if <<<"$XRANDRV" grep -Pzo \ "\n${OUTPUTNAMES[$BEAMER]}\N*\n((\ |\t)+\N*\n)+" \ | grep EDID > /dev/null ; then echo "${OUTPUTNAMES[$BEAMER]} [Beamer] provides EDID." # If the breamer transmits the EDID there shall be a preferred resolution. - OPTIMALRES=$( <<<$XRANDRV \ + OPTIMALRES=$( <<<"$XRANDRV" \ | grep -Pzo "\n${OUTPUTNAMES[$BEAMER]}\N*\n((\ |\t)+\N*\n)+" \ | grep preferred | awk '{print $1}' ) @@ -162,7 +162,7 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then . /opt/openslx/config # Try to get a probed mode - PROBEDMODE=$( <<<$CONFIGFILE grep "^\s*$SLX_PXE_CLIENT_IP" | cut -d '=' -f2 ) + PROBEDMODE=$( <<<"$CONFIGFILE" grep "^\s*$SLX_PXE_CLIENT_IP" | cut -d '=' -f2 ) # If a probed mode was found, .. if [[ -n "$PROBEDMODE" ]]; then -- cgit v1.2.3-55-g7522