Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | Upstream-Status: Pending |
| 2 | |
| 3 | From 14734a93bd3fc323325459e24b04795422e395e6 Mon Sep 17 00:00:00 2001 |
| 4 | From: Laurentiu Palcu <laurentiu.palcu@intel.com> |
| 5 | Date: Mon, 1 Jul 2013 15:38:02 +0300 |
| 6 | Subject: [PATCH] Allow xinput_calibrator_pointercal.sh to be run as normal |
| 7 | user |
| 8 | |
| 9 | Allow normal user to create their own pointercal.xinput files that |
| 10 | override the system pointercal file in /etc. |
| 11 | |
| 12 | Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> |
| 13 | --- |
| 14 | scripts/xinput_calibrator_pointercal.sh | 33 +++++++++++++++++++++---------- |
| 15 | 1 file changed, 23 insertions(+), 10 deletions(-) |
| 16 | |
| 17 | diff --git a/scripts/xinput_calibrator_pointercal.sh b/scripts/xinput_calibrator_pointercal.sh |
| 18 | index fccb197..0ada7da 100755 |
| 19 | --- a/scripts/xinput_calibrator_pointercal.sh |
| 20 | +++ b/scripts/xinput_calibrator_pointercal.sh |
| 21 | @@ -11,19 +11,32 @@ |
| 22 | PATH="/usr/bin:$PATH" |
| 23 | |
| 24 | BINARY="xinput_calibrator" |
| 25 | -CALFILE="/etc/pointercal.xinput" |
| 26 | -LOGFILE="/var/log/xinput_calibrator.pointercal.log" |
| 27 | +SYS_CALFILE="/etc/pointercal.xinput" |
| 28 | +USER_CALFILE="$HOME/.pointercal/pointercal.xinput" |
| 29 | |
| 30 | -if [ -e $CALFILE ] ; then |
| 31 | - if grep replace $CALFILE ; then |
| 32 | - echo "Empty calibration file found, removing it" |
| 33 | - rm $CALFILE |
| 34 | - else |
| 35 | - echo "Using calibration data stored in $CALFILE" |
| 36 | - . $CALFILE && exit 0 |
| 37 | - fi |
| 38 | +if [ "$USER" = "root" ]; then |
| 39 | + LOGFILE="/var/log/xinput_calibrator.pointercal.log" |
| 40 | + CALFILES="$SYS_CALFILE" |
| 41 | +else |
| 42 | + LOGFILE="$HOME/.pointercal/xinput_calibrator.pointercal.log" |
| 43 | + CALFILES="$USER_CALFILE $SYS_CALFILE" |
| 44 | + mkdir -p "$HOME/.pointercal" |
| 45 | fi |
| 46 | |
| 47 | +for CALFILE in $CALFILES; do |
| 48 | + if [ -e $CALFILE ]; then |
| 49 | + if grep replace $CALFILE ; then |
| 50 | + echo "Empty calibration file found, removing it" |
| 51 | + rm $CALFILE 2>/dev/null || true |
| 52 | + else |
| 53 | + echo "Using calibration data stored in $CALFILE" |
| 54 | + . $CALFILE && exit 0 |
| 55 | + fi |
| 56 | + fi |
| 57 | +done |
| 58 | + |
| 59 | +[ "$USER" != "root" ] && CALFILE=$USER_CALFILE |
| 60 | + |
| 61 | CALDATA=`$BINARY --output-type xinput -v | tee $LOGFILE | grep ' xinput set' | sed 's/^ //g; s/$/;/g'` |
| 62 | if [ ! -z "$CALDATA" ] ; then |
| 63 | echo $CALDATA > $CALFILE |
| 64 | -- |
| 65 | 1.7.9.5 |
| 66 | |