summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2014-09-29 20:27:56 +0200
committerroot2014-09-29 20:27:56 +0200
commit3f94643ca6777833bea865f84d88c43e3c8a6884 (patch)
tree583b6081d2f69529ddd7cea6625dd5802fae4888
parentMerge branch 'master' of git://git.openslx.org/openslx-ng/tm-scripts (diff)
downloadtm-scripts-3f94643ca6777833bea865f84d88c43e3c8a6884.tar.gz
tm-scripts-3f94643ca6777833bea865f84d88c43e3c8a6884.tar.xz
tm-scripts-3f94643ca6777833bea865f84d88c43e3c8a6884.zip
[beamergui] Detect screens with geometry width > 90cm as beamer
-rwxr-xr-xremote/modules/beamergui/data/opt/openslx/scripts/beamergui-mode_setter37
1 files changed, 19 insertions, 18 deletions
diff --git a/remote/modules/beamergui/data/opt/openslx/scripts/beamergui-mode_setter b/remote/modules/beamergui/data/opt/openslx/scripts/beamergui-mode_setter
index 0ee6e274..503e44fa 100755
--- a/remote/modules/beamergui/data/opt/openslx/scripts/beamergui-mode_setter
+++ b/remote/modules/beamergui/data/opt/openslx/scripts/beamergui-mode_setter
@@ -36,15 +36,15 @@ XRANDRV=$( xrandr --verbose )
echo "$XRANDR"
#echo "$XRANDRV"
-# Get the names of the connected outputs
+# Get the names of the connected outputs
# This is a rigid approach to determine the connected outputs
declare -a OUTPUTNAMES
while read line; do
- OUTPUTNAMES+=("$(echo "$line" | grep -o "^\S*" )")
-done < <( echo "$XRANDR" | grep -E ".*[[:digit:]]{1,}mm x [[:digit:]]{1,}mm" )
+ OUTPUTNAMES+=("$(awk '{print $1}' <<<"$line" )")
+done < <( echo "$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
+# The goal is to add more modelines to the X server. While this is done the
# screen is flickering. Hence this is just necessary if there is a beamer. Do
# the flickering magic only if there are two outputs and one is a projector.
@@ -54,15 +54,15 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then
echo "Two outputs detected."
# Either of them a projector?
- if ( echo "$XRANDR" | grep -E "^${OUTPUTNAMES[0]}.*0mm x 0mm" > /dev/null \
- || echo "$XRANDR" | grep -E "^${OUTPUTNAMES[1]}.*0mm x 0mm" > /dev/null )
- then
-
- # Check which of the outputs is the beamer.
- if [ -n "$(echo "$XRANDR" | grep -E "^${OUTPUTNAMES[0]}.*0mm x 0mm")" ]
- then BEAMER=0;
- else BEAMER=1;
- fi
+ BEAMER=
+ for i in 0 1; do
+ WIDTH=$(grep -E "^${OUTPUTNAMES[$i]}.*[0-9]+mm x [0-9]+mm" <<<"$XRANDR" | 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
+ fi
+ done
+ if [ -n "$BEAMER" ]; then
echo "${OUTPUTNAMES[$BEAMER]} is a beamer. "
# Create all modes, so that X knows them by name "<width>x<height>"
@@ -75,7 +75,7 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then
echo -e "\e[31mFailed to create mode ${i%% *}!\e[0m"
fi
- for j in "${OUTPUTNAMES[@]}"; do
+ for j in "${OUTPUTNAMES[@]}"; do
if xrandr --current --addmode $j $(echo $i| awk '{print $1;}'); then
echo -e "Added mode ${i%% *} to $j."
else
@@ -111,17 +111,17 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then
elif [[ -f "$CONFIGFILE" ]]; then
- echo "Config file found."
+ echo "Config file found."
# Get local ip
. /opt/openslx/config
# Try to get a probed mode
PROBEDMODE=$(cat $CONFIGFILE | grep $SLX_PXE_CLIENT_IP | cut -d '=' -f2)
-
+
# If a probed mode was found, ..
if [[ -n "$PROBEDMODE" ]]; then
- echo "Probed mode found in config file."
+ echo "Probed mode found in config file."
# Apply the probed mode from the config file
if xrandr \
--output ${OUTPUTNAMES[$((1-$BEAMER))]} --mode $PROBEDMODE \
@@ -143,7 +143,7 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then
--output ${OUTPUTNAMES[$BEAMER]} --mode 1024x768 \
--same-as ${OUTPUTNAMES[$((1-$BEAMER))]}
fi
- else
+ else
# In case of two monitors just sort the outputs lexicographically and apply
# the preffered resolution
echo "Dualhead setup deteced. Sorting outputs lexicographically."
@@ -162,3 +162,4 @@ if [ ${#OUTPUTNAMES[@]} -eq 2 ]; then
else
echo "\e[32mOther than two outputs.\e[0m"
fi
+