123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- #!/bin/bash
- export TEXTDOMAIN=xgamma-gui
- export OUTPUT_CHARSET=UTF-8
- TITLE="$(gettext 'Monitor Gamma calibration')"
- BACKTITLE="$(gettext 'Set value for each colour, or adjust equally if only want to adjust brightness of screen.')
- $(gettext 'The spinboxes are adjustable in the range -100 to +100, where -100 is darkest, 0 is default, and +100 is brightest.')"
- if [ "`which xgamma`" = "" ]; then
- Xdialog --title "${TITLE}" --msgbox "$(gettext 'xgamma not found.')" 0 0
- exit
- fi
- YGAMMA="$(xgamma 2>&1 | tr -s ' ' | sed -e 's%[^0-9. ]%%g' | tr -s ' ')"
- YRED="$(echo "$YGAMMA" | cut -f 2 -d ' ')"
- YGREEN="$(echo "$YGAMMA" | cut -f 3 -d ' ')"
- YBLUE="$(echo "$YGAMMA" | cut -f 4 -d ' ')"
- inYRED="$YRED"
- inYGREEN="$YGREEN"
- inYBLUE="$YBLUE"
- echo $YGAMMA
- echo $YRED $YGREEN $YBLUE
- XRED=$(echo "scale=3; 100 * l("$YRED") / l(10)" | bc -l)
- XRED=$(echo "scale=0; "$XRED"/1" | bc -l)
- XGREEN=$(echo "scale=3; 100 * l("$YGREEN") / l(10)" | bc -l)
- XGREEN=$(echo "scale=0; "$XGREEN"/1" | bc -l)
- XBLUE=$(echo "scale=3; 100 * l("$YBLUE") / l(10)" | bc -l)
- XBLUE=$(echo "scale=0; "$XBLUE"/1" | bc -l)
- EXCODE="0"
- REDLABEL="$(gettext 'Red')"
- GREENLABEL="$(gettext 'Green')"
- BLUELABEL="$(gettext 'Blue')"
- APPLIEDFLAG='no'
- while [ "${EXCODE}" = "0" ]; do
- XDGOUT=`Xdialog --wrap --left --backtitle "${BACKTITLE}" --title "${TITLE}" --stdout --buttons-style "text" --icon "/usr/share/images/xgamma-gui.xpm" --ok-label "$(gettext 'Apply')" --cancel-label "$(gettext 'Exit')" \
- --3spinsbox "" 356x0 "-100" "100" "$XRED" "${REDLABEL}" "-100" "100" "$XGREEN" "${GREENLABEL}" "-100" "100" "$XBLUE" "${BLUELABEL}"`
-
-
- EXCODE=${?}
-
- XGAMMA=$XDGOUT
-
- XGAMMA=$(echo $XGAMMA| sed 's:/: :g')
- [ "${EXCODE}" != "0" ] && break
- APPLIEDFLAG='yes'
-
-
- set -- ${XGAMMA// / }
- XRED=$1
- XGREEN=$2
- XBLUE=$3
-
-
- YRED=$(echo "scale=3; e( "$XRED"/100 * l(10))" | bc -l)
- YGREEN=$(echo "scale=3; e( "$XGREEN"/100 * l(10))" | bc -l)
- YBLUE=$(echo "scale=3; e( "$XBLUE"/100 * l(10))" | bc -l)
-
-
- xgamma -rgamma ${YRED} -ggamma ${YGREEN} -bgamma ${YBLUE}
-
- done
- if [ "$XGAMMA" = "0 0 0" ]; then
- rm -f $HOME/.xgamma-gamma
- exit
- fi
- if [ "$inYRED" = "$YRED" ];then
- if [ "$inYGREEN" = "$YGREEN" ];then
- if [ "$inYBLUE" = "$YBLUE" ];then
- exit
- fi
- fi
- fi
- [ "$APPLIEDFLAG" = "no" ] && exit
- Xdialog --yesno "$(gettext 'Save current configuration?')" 0 0
- if [ ${?} -eq 0 ]; then
- echo -n "xgamma -rgamma $YRED -ggamma $YGREEN -bgamma $YBLUE"' &' > $HOME/.xgamma-gamma
-
- echo "Saved"
- fi
|