summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/xinput-calibrator/xinput-calibrator/Allow-xinput_calibrator_pointercal.sh-to-be-run-as-n.patch
blob: 86982924a81a7c931f5cf40f136c50b391d90121 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Upstream-Status: Pending

From 14734a93bd3fc323325459e24b04795422e395e6 Mon Sep 17 00:00:00 2001
From: Laurentiu Palcu <laurentiu.palcu@intel.com>
Date: Mon, 1 Jul 2013 15:38:02 +0300
Subject: [PATCH] Allow xinput_calibrator_pointercal.sh to be run as normal
 user

Allow normal user to create their own pointercal.xinput files that
override the system pointercal file in /etc.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
---
 scripts/xinput_calibrator_pointercal.sh |   33 +++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/scripts/xinput_calibrator_pointercal.sh b/scripts/xinput_calibrator_pointercal.sh
index fccb197..0ada7da 100755
--- a/scripts/xinput_calibrator_pointercal.sh
+++ b/scripts/xinput_calibrator_pointercal.sh
@@ -11,19 +11,32 @@
 PATH="/usr/bin:$PATH"
 
 BINARY="xinput_calibrator"
-CALFILE="/etc/pointercal.xinput"
-LOGFILE="/var/log/xinput_calibrator.pointercal.log"
+SYS_CALFILE="/etc/pointercal.xinput"
+USER_CALFILE="$HOME/.pointercal/pointercal.xinput"
 
-if [ -e $CALFILE ] ; then
-  if grep replace $CALFILE ; then
-    echo "Empty calibration file found, removing it"
-    rm $CALFILE
-  else
-    echo "Using calibration data stored in $CALFILE"
-    . $CALFILE && exit 0
-  fi
+if [ "$USER" = "root" ]; then
+  LOGFILE="/var/log/xinput_calibrator.pointercal.log"
+  CALFILES="$SYS_CALFILE"
+else
+  LOGFILE="$HOME/.pointercal/xinput_calibrator.pointercal.log"
+  CALFILES="$USER_CALFILE $SYS_CALFILE"
+  mkdir -p "$HOME/.pointercal"
 fi
 
+for CALFILE in $CALFILES; do
+  if [ -e $CALFILE ]; then
+    if grep replace $CALFILE ; then
+      echo "Empty calibration file found, removing it"
+      rm $CALFILE 2>/dev/null || true
+    else
+      echo "Using calibration data stored in $CALFILE"
+      . $CALFILE && exit 0
+    fi
+  fi
+done
+
+[ "$USER" != "root" ] && CALFILE=$USER_CALFILE
+
 CALDATA=`$BINARY --output-type xinput -v | tee $LOGFILE | grep '    xinput set' | sed 's/^    //g; s/$/;/g'`
 if [ ! -z "$CALDATA" ] ; then
   echo $CALDATA > $CALFILE
-- 
1.7.9.5