Initial commit
[profile/ivi/xinput_calibrator.git] / scripts / xinput_calibrator_pointercal.sh
1 #!/bin/sh
2 # script to make the changes permanent (xinput is called with every Xorg start)
3 #
4 # can be used from Xsession.d
5 # script needs tee and sed (busybox variants are enough)
6 #
7 # original script: Martin Jansa <Martin.Jansa@gmail.com>, 2010-01-31
8 # updated by Tias Guns <tias@ulyssis.org>, 2010-02-15
9 # updated by Koen Kooi <koen@dominion.thruhere.net>, 2012-02-28
10
11 PATH="/usr/bin:$PATH"
12
13 BINARY="xinput_calibrator"
14 CALFILE="/etc/pointercal.xinput"
15 LOGFILE="/var/log/xinput_calibrator.pointercal.log"
16
17 if [ -e $CALFILE ] ; then
18   if grep replace $CALFILE ; then
19     echo "Empty calibration file found, removing it"
20     rm $CALFILE
21   else
22     echo "Using calibration data stored in $CALFILE"
23     . $CALFILE && exit 0
24   fi
25 fi
26
27 CALDATA=`$BINARY --output-type xinput -v | tee $LOGFILE | grep '    xinput set' | sed 's/^    //g; s/$/;/g'`
28 if [ ! -z "$CALDATA" ] ; then
29   echo $CALDATA > $CALFILE
30   echo "Calibration data stored in $CALFILE (log in $LOGFILE)"
31 fi