diff options
author | Manuel Schneider | 2013-10-18 11:40:51 +0200 |
---|---|---|
committer | Manuel Schneider | 2013-10-18 11:40:51 +0200 |
commit | e870ff0ebdff769278ba4db259f3493908b323f6 (patch) | |
tree | 2ffc45922e134d6433ef78155f0deec98fce7dcb /remote/modules/beamergui | |
parent | [beamer] Changed build from prototype to qt binary (diff) | |
download | tm-scripts-e870ff0ebdff769278ba4db259f3493908b323f6.tar.gz tm-scripts-e870ff0ebdff769278ba4db259f3493908b323f6.tar.xz tm-scripts-e870ff0ebdff769278ba4db259f3493908b323f6.zip |
[beamergui] Renamed module.
Diffstat (limited to 'remote/modules/beamergui')
-rw-r--r-- | remote/modules/beamergui/TODO | 2 | ||||
-rw-r--r-- | remote/modules/beamergui/beamergui.build | 18 | ||||
-rw-r--r-- | remote/modules/beamergui/beamergui.conf | 7 | ||||
-rw-r--r-- | remote/modules/beamergui/beamergui.conf.debian | 7 | ||||
-rw-r--r-- | remote/modules/beamergui/beamergui.conf.ubuntu | 7 | ||||
-rwxr-xr-x | remote/modules/beamergui/data/opt/openslx/bin/screenRecognizer.sh | 418 |
6 files changed, 459 insertions, 0 deletions
diff --git a/remote/modules/beamergui/TODO b/remote/modules/beamergui/TODO new file mode 100644 index 00000000..651759eb --- /dev/null +++ b/remote/modules/beamergui/TODO @@ -0,0 +1,2 @@ +Zenity durch eigen QT app ersetzen + diff --git a/remote/modules/beamergui/beamergui.build b/remote/modules/beamergui/beamergui.build new file mode 100644 index 00000000..49fcfe1d --- /dev/null +++ b/remote/modules/beamergui/beamergui.build @@ -0,0 +1,18 @@ +#!/bin/bash + +fetch_source() { + git clone "${REQUIRED_GIT}" src +} + +build() { + local SRCDIR="${MODULE_DIR}/src/" + + mkdir -p "$MODULE_BUILD_DIR/opt/openslx/bin" + cd "${MODULE_BUILD_DIR}/opt/openslx/bin" || perror "Could not cd!" + pinfo "Running qmake" + qmake-qt4 "$SRCDIR/src/beamergui.pro" -r -spec linux-g++ || perror "'qmake' failed." + pinfo "Running make" + make || perror "'make' failed." +} +post_copy() { +} diff --git a/remote/modules/beamergui/beamergui.conf b/remote/modules/beamergui/beamergui.conf new file mode 100644 index 00000000..4d497389 --- /dev/null +++ b/remote/modules/beamergui/beamergui.conf @@ -0,0 +1,7 @@ +REQUIRED_GIT="git://git.openslx.org/openslx-ng/beamergui.git" +REQUIRED_BINARIES=" + beamergui +" +REQUIRED_SYSTEM_FILES=" +" + diff --git a/remote/modules/beamergui/beamergui.conf.debian b/remote/modules/beamergui/beamergui.conf.debian new file mode 100644 index 00000000..525245fb --- /dev/null +++ b/remote/modules/beamergui/beamergui.conf.debian @@ -0,0 +1,7 @@ +REQUIRED_INSTALLED_PACKAGES=" +libqt4-dev +libxrandr-dev +" +REQUIRED_CONTENT_PACKAGES=" +libxrandr2 +" diff --git a/remote/modules/beamergui/beamergui.conf.ubuntu b/remote/modules/beamergui/beamergui.conf.ubuntu new file mode 100644 index 00000000..525245fb --- /dev/null +++ b/remote/modules/beamergui/beamergui.conf.ubuntu @@ -0,0 +1,7 @@ +REQUIRED_INSTALLED_PACKAGES=" +libqt4-dev +libxrandr-dev +" +REQUIRED_CONTENT_PACKAGES=" +libxrandr2 +" diff --git a/remote/modules/beamergui/data/opt/openslx/bin/screenRecognizer.sh b/remote/modules/beamergui/data/opt/openslx/bin/screenRecognizer.sh new file mode 100755 index 00000000..feabe7ee --- /dev/null +++ b/remote/modules/beamergui/data/opt/openslx/bin/screenRecognizer.sh @@ -0,0 +1,418 @@ +#! /bin/bash + +RES1610=(1920x1200 1680x1050 1440x900 1280x800 ) +RES169=(1920x1080 1600x900 1280x720 ) +RES54=(1280x1024 ) +RES43=(1280x960 1152x864 1024x768 ) +ALLRES=( ${RES1610[@]} ${RES169[@]} ${RES54[@]} ${RES43[@]} ) + +echo -e "\e[32mSupported resolutions\e[0m" +for i in ${ALLRES[@]} +do + echo -n "$i - " + echo "scale=2; $i" | tr "x" "/" | bc -l +done + +# Get initial data +XRANDR=$( xrandr ) +XRANDRV=$( xrandr --verbose ) + +# Get the connected outputs +declare -a OUTPUTNAMES +while read line; do + OUTPUTNAMES+=("$(echo "$line" | grep -o "^\S*" )") +done < <( echo "$XRANDR" | grep -i " connected" ) +echo -e "Connected outputs: \e[32m${OUTPUTNAMES[@]}\e[0m" + + +if [ ${#OUTPUTNAMES[@]} -eq 1 ]; then + + + # In case of one connected output + xrandr --auto + exit + + +elif [ ${#OUTPUTNAMES[@]} -eq 2 ]; then + + + # In case of two connected outputs + # If one of the two connected outputs is a beamer, based on the assumption + # that a beamer can not output a reasonable dimension. + if ! ( echo "$XRANDR" | egrep "^${OUTPUTNAMES[0]}.*[[:digit:]]{2,}mm x [[:digit:]]{2,}mm" > /dev/null \ + && echo "$XRANDR" | egrep "^${OUTPUTNAMES[1]}.*[[:digit:]]{2,}mm x [[:digit:]]{2,}mm" > /dev/null ); then + + + # If one scree is a beamer. First check which one is the BEAMER + if [[ -z "$(echo "$XRANDR" | egrep "^${OUTPUTNAMES[0]}.*[[:digit:]]{2,}mm x [[:digit:]]{2,}mm")" ]] + then BEAMER=0; else BEAMER=1; fi + echo -ne "${OUTPUTNAMES[$BEAMER]} is a beamer. " + + + # Get the supported modes of the outputs + # Get resolutions of output #0 + for RES in $( echo "$XRANDR" | grep -Pzo \ + "(?s)^${OUTPUTNAMES[0]} connected\N*\n(\t+\N*\n)*(\ +\N*\n)*" \ + | egrep -o "\ \ [[:digit:]]+x[[:digit:]]+" ); do + OUTPUT0+=("$RES"); + done + echo -e "\e[31mOUTPUT0:\e[0m" + for i in ${OUTPUT0[@]}; do echo "$i";done + + # Get resolutions of output #1 + for RES in $( echo "$XRANDR" | grep -Pzo \ + "(?s)^${OUTPUTNAMES[1]} connected\N*\n(\t+\N*\n)*(\ +\N*\n)*" \ + | egrep -o "\ \ [[:digit:]]+x[[:digit:]]+" ); do + OUTPUT1+=("$RES"); + done + echo -e "\e[31mOUTPUT1:\e[0m" + for i in ${OUTPUT1[@]}; do echo "$i";done + + + # Find out, if the beamer transmits reliable EDID data. The data in xrandr + # should be reliable if the EDID is present. + if echo "$XRANDRV" | grep -Pzo \ + "^${OUTPUTNAMES[$BEAMER]}\N*\n((\ |\t)+\N*\n)+" \ + | grep EDID > /dev/null ; then + + + echo "EDID present" + + # If the beamer transmits reliable EDID data, get the perfect match + # Presumed the preferred resolution is the native one, get both native + # resolutions + BEAMERPREF=$(echo "$XRANDRV" \ + | grep -Pzo "^${OUTPUTNAMES[$BEAMER]}\N*\n((\ |\t)+\N*\n)+" \ + | grep preferred | awk '{print $1}') + echo -e "\e[32mBEAMERPREF\e[0m=$BEAMERPREF" + MONITORPREF=$(echo "$XRANDRV" \ + | grep -Pzo "^${OUTPUTNAMES[$((1-$BEAMER))]}\N*\n((\ |\t)+\N*\n)+" \ + | grep preferred | awk '{print $1}') + echo -e "\e[32mMONITORPREF\e[0m=$MONITORPREF" + + # Compute the optimal resolution for presentations + # which is min( 1280, M.X, B.X ) + OPTIMALRESX=$(( ${MONITORPREF%x*} <= ${BEAMERPREF%x*} ? \ + ${MONITORPREF%x*} : ${BEAMERPREF%x*} )) + OPTIMALRESX=$(( $OPTIMALRESX <= 1280 ? $OPTIMALRESX : 1280 )) + AR=$(echo "$BEAMERPREF" | tr "x" "/" | bc -l) # "scale=2; 5/4" + OPTIMALRESY=$(echo "scale=0; $OPTIMALRESX / $(echo "$AR" | bc -l)" | bc -l) + OPTIMALRES="$OPTIMALRESX"x"$OPTIMALRESY" + echo -e "\e[32mOPTIMALRESX\e[0m=$OPTIMALRESX" + echo -e "\e[32mOPTIMALRESY\e[0m=$OPTIMALRESY" + echo -e "\e[32mOPTIMALRES\e[0m=$OPTIMALRES" + echo -e "\e[32mAR\e[0m=$AR" + + # Generate a list of common resolutions (Greedy fun) + for RES1 in ${OUTPUT0[@]}; do + for RES2 in ${OUTPUT1[@]}; do + if [ $RES1 = $RES2 ]; then + COMMONMATCHES+=("$RES1") + fi + done + done + echo -e "\e[31mCOMMONMATCHES:\e[0m" + for i in "${COMMONMATCHES[@]}" + do echo "$i - $( echo "scale=2; $i" | tr "x" "/" | bc -l)" + done + + # Compute the additional resolutions + for i in ${ALLRES[@]}; do + if (( $( echo "$i == $AR" | tr "x" "/" | bc -l ) )); then + if echo ${COMMONMATCHES[@]} | grep "$i" > /dev/null; then + if [ "$OPTIMALRES" = "$i" ]; then continue; fi + ADDITIONALRES+=("$i") + else + xrandr \ + --addmode ${OUTPUTNAMES[$((1-$BEAMER))]} "$i" \ + --addmode ${OUTPUTNAMES[$BEAMER]} "$i" \ + && ADDITIONALRES+=("$i") + fi + fi + done + echo -e "\e[31mADDITIONALRES:\e[0m" + for i in "${ADDITIONALRES[@]}" + do echo "$i - $( echo "scale=2; ${i% *}" | tr "x" "/" | bc -l)" + done + + # Apply the optimal resolution + xrandr \ + --addmode ${OUTPUTNAMES[$((1-$BEAMER))]} $OPTIMALRES \ + --addmode ${OUTPUTNAMES[$BEAMER]} $OPTIMALRES; + xrandr \ + --output ${OUTPUTNAMES[$((1-$BEAMER))]} --mode $OPTIMALRES \ + --primary \ + --output ${OUTPUTNAMES[$BEAMER]} --mode $OPTIMALRES \ + --same-as ${OUTPUTNAMES[$((1-$BEAMER))]} + + # Ask for a resolution + CHOSENRES=$( zenity --list \ + --title="Resolution Chooser" \ + --ok-label="Apply" \ + --cancel-label="Cancel" \ + --text "Choose a resolution\nor press cancel." \ + --width=300 --height=400 \ + --column="Resolution" "$OPTIMALRES (optimal)" "${ADDITIONALRES[@]}" \ + --print-column=1 \ + --hide-header ) || exit + echo "Chosen resolution $CHOSENRES" + + + + # Apply resolution + xrandr \ + --output ${OUTPUTNAMES[0]} --mode ${CHOSENRES%% *} \ + --output ${OUTPUTNAMES[1]} --mode ${CHOSENRES%% *} \ + --same-as ${OUTPUTNAMES[0]} + + + # If beamer DOES NOT transmit reliable EDID data + else + + echo "EDID is not present" + + # Compute the additional resolutions + for i in ${ALLRES[@]}; do + if ! xrandr \ + --addmode ${OUTPUTNAMES[$((1-$BEAMER))]} "$i" \ + --addmode ${OUTPUTNAMES[$BEAMER]} "$i"; then + if xrandr --newmode \ + "$i" $( cvt $(echo "$i" | tr "x" " " ) \ + | grep Modeline | cut -d " " -f3-); then + if ! xrandr --dryrun \ + --addmode ${OUTPUTNAMES[$((1-$BEAMER))]} "$i" \ + --addmode ${OUTPUTNAMES[$BEAMER]} "$i"; then + continue; + fi + else + continue + fi + fi + AR=$(echo "scale=2; $i" | tr "x" "/" | bc -l ) + case $AR in + "1.60") + ADDITIONALRES+=("$i (16:10)") + ;; + "1.77") + ADDITIONALRES+=("$i (16:9)") + ;; + "1.25") + ADDITIONALRES+=("$i (5:4)") + ;; + "1.33") + ADDITIONALRES+=("$i (4:3)") + ;; + *) + esac + done + echo -e "\e[31mADDITIONALRES:\e[0m" + for i in "${ADDITIONALRES[@]}" + do echo "$i - $( echo "scale=2; ${i% *}" | tr "x" "/" | bc -l)" + done + + TEXT="The connected beamer did not transmit reliable configuration\n" \ + TEXT+="data. To avoid clipping or streching, it is recommended to\n" \ + TEXT+="choose a resolution equal to the aspect ratio of the native\n" \ + TEXT+="resolution of the beamer." \ + + # Ask for a resolution + CHOSENRES=$( zenity --list \ + --title="Resolution Chooser" \ + --ok-label="Apply" \ + --cancel-label="Cancel" \ + --text "$TEXT" \ + --width=300 --height=400 \ + --column="Resolution" "${ADDITIONALRES[@]}" \ + --print-column=1 \ + --hide-header ) || exit + echo "Chosen resolution ${CHOSENRES%% *}" + + # Apply resolution + xrandr \ + --addmode ${OUTPUTNAMES[0]} ${CHOSENRES%% *} \ + --addmode ${OUTPUTNAMES[1]} ${CHOSENRES%% *}; + xrandr \ + --output ${OUTPUTNAMES[$((1-$BEAMER))]} --mode ${CHOSENRES%% *} \ + --primary \ + --output ${OUTPUTNAMES[$BEAMER]} --mode ${CHOSENRES%% *} \ + --same-as ${OUTPUTNAMES[$((1-$BEAMER))]} + + fi + else + + + # If neiter of the outputs is a beamer (likely dualscreen + # setup) just apply preferred settings + echo "no beamer" + xrandr \ + --output ${OUTPUTNAMES[0]} --preferred \ + --output ${OUTPUTNAMES[1]} --preferred \ + --right-of ${OUTPUTNAMES[0]} + + + fi + +else + # If there are more than 3 outputs + # its up to the user. Quit. + exit; +fi + + + + # OLD APPROACH + # Find out, if the beamer transmits reliable EDID data. + # For the first assumption the beamer transmits reliable data, if in + # Xorg.log '*EDID for output $BEAMER*' is succeded by '*Manufacturer*' + # and '*Year*'. + # BEAMERELIABILITY=1 + # while read line + # do + # if echo $line | grep "EDID for output ${OUTPUTNAMES[$BEAMER]}" > /dev/null + # then + # read line + # if echo $line | grep "Manufacturer" > /dev/null + # then + # BEAMERELIABILITY=0 + # break + # fi + # fi + # done < "/var/log/Xorg.0.log" + + + + + + +# # if one of the outputs is a beamer, offer a choice +# declare -a OUTPUT1 +# declare -a OUTPUT2 +# + +# # Make sure the desired resolutions are existent +# # FULLHD +# #for in +# +# +# ####################################DEBUG################################### +# echo ${NATIVEMATCHES[@]} +# echo -e "\e[31m--------------------------------\e[0m" +# ############################################################################ +# +# # Add some experimental standard resolutions, which the outputs should be +# # able to display via interpolation. +# declare -a EXPERIMENTALMATCHES=("1920x1080 (16:9)" "1366x768 (16:9)" "1280x960 (4:3)" "1280x720 (16:9)") +# +# ## Form an interactive dialog to suit the users preferred resolution +# #zenity --question \ +# # --timeout=10 \ +# # --text="Do you want to change the resolution?" \ +# # --ok-label "Yes" \ +# # --cancel-label "No" +# +#OfferChoice() +#{ +# false; while [ "$?" != 0 ] #bash do{...}while(...) imitation +# do +# +# +# CHOSENRES=$( zenity --list \ +# --title="Resolution Chooser" \ +# --ok-label="Apply" \ +# --cancel-label="Cancel" \ +# --text "Choose a resolution\nor press cancel." \ +# --width=300 --height=400 \ +# --column="Resolution" 1920x1080 1366x768 1280x720 1024x768 \ +# --print-column=1 \ +# --hide-header ) +# +# ####################################DEBUG################################# +# echo "Chosen resolution $CHOSENRES" +# echo -e "\e[31m--------------------------------\e[0m" +# ########################################################################## +# +# if [ $? != 0 ] +# then +# break +# fi +# +# xrandr \ +# --output ${OUTPUTNAMES[0]} --mode ${CHOSENRES%% *} \ +# --output ${OUTPUTNAMES[1]} --mode ${CHOSENRES%% *} \ +# --same-as ${OUTPUTNAMES[0]} +# +# # in case the mode is unknown +# if [ $? != 0 ] +# then +# xrandr \ +# --addmode ${OUTPUTNAMES[0]} ${CHOSENRES%% *} \ +# --addmode ${OUTPUTNAMES[1]} ${CHOSENRES%% *} +# xrandr \ +# --output ${OUTPUTNAMES[0]} --mode ${CHOSENRES%% *} --primary \ +# --output ${OUTPUTNAMES[1]} --mode ${CHOSENRES%% *} --same-as ${OUTPUTNAMES[0]} +# +# #CVT="$(cvt $(echo ${CHOSENRES%% *} | cut -d " " -f1 | tr "x" " ") | grep Modeline)" +# #MODENAME=echo $CVT | cut -d " " -f2) +# #MODELINE=echo $CVT | cut -d " " -f3-) +# fi +# +# zenity --question \ +# --text="Do you want to stay with this resolution?" \ +# --ok-label "Yes" \ +# --cancel-label "No" +# +# # In case of timeout +# #if [ $? -eq 5]; then ;fi +# +# done +#} +# # If the beamer fits in the monitor, teach the monitor the preferred +# # mode of the beamer +# xrandr --addmode ${OUTPUTNAMES[$((1-$BEAMER))]} $BEAMERPREF +# xrandr --output ${OUTPUTNAMES[$((1-$BEAMER))]} \ +# --mode $BEAMERPREF \ +# --primary \ +# --output ${OUTPUTNAMES[$BEAMER]} \ +# --mode $BEAMERPREF \ +# --same-as ${OUTPUTNAMES[$((1-$BEAMER))]} +# echo -e "\e[32mPERFECTMATCH\e[0m=$BEAMERPREF" +# +# # If the monitor fits in the beamer, teach the beamer the preferred +# # mode of the monitor +# xrandr --addmode ${OUTPUTNAMES[$BEAMER]} $MONITORPREF +# xrandr --output ${OUTPUTNAMES[$((1-$BEAMER))]} \ +# --mode $MONITORPREF \ +# --primary \ +# --output ${OUTPUTNAMES[$BEAMER]} \ +# --mode $MONITORPREF \ +# --same-as ${OUTPUTNAMES[$((1-$BEAMER))]} +# +# +# +# +# +# Offer a mode selection +# 1920x1080, 1366x768, 1280x800 and 1024x800 have to be available. +# Check if the TFT supports the resolution +# if echo "$XRANDRV" \ +# | grep -Pzo "^${OUTPUTNAMES[$((1-$BEAMER))]}\N*\n((\ |\t)+\N*\n)+" \ +# | grep $MODE > /dev/null +# then +# +# # If so, just assign the beamers preferred resolution to the TFT +# xrandr \ +# --output ${OUTPUTNAMES[0]} --mode $MODE \ +# --output ${OUTPUTNAMES[1]} --mode $MODE \ +# --same-as ${OUTPUTNAMES[0]} +# else +# +# # If not, teach the TFT the mode +# xrandr \ +# --addmode ${OUTPUTNAMES[$((1-$BEAMER))]} $MODE +# --output ${OUTPUTNAMES[0]} --mode $MODE \ +# --output ${OUTPUTNAMES[1]} --mode $MODE \ +# --same-as ${OUTPUTNAMES[0]} +# fi +# +# #OfferChoice +# #echo "Offered choice" |