Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #January 2015
- #path="/sys/bus/iio/devices/iio:device0" #Path is not fixed! So use workaround below, which is correct
- path="/sys/devices/pci0000:00/0000:00:14.0/usb2/2-4/2-4:1.0/*0483:91D1*/HID-SENSOR-200073.1.auto/iio:device?"
- margin=500000
- current_case=0
- counter=0
- num_iterations=2
- function increase_counter
- {
- c=$1
- if [[ $c -eq $current_case ]]; then
- counter=$((counter + 1))
- else
- current_case=$c
- counter=1
- fi
- }
- sleep 1
- while true; do
- y=`cat $path/in_accel_y_raw`
- z=`cat $path/in_accel_z_raw`
- x=`cat $path/in_accel_x_raw`
- # echo $x $y $z
- if [[ $x -gt -$margin ]] && [[ $x -lt $margin ]]; then
- if [[ "$y" -gt "$margin" ]]; then
- increase_counter 2
- if [[ $counter -gt $num_iterations ]]; then
- xrandr -o inverted
- xinput set-prop 'ELAN Touchscreen' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
- fi
- elif [[ "$y" -lt "-$margin" ]]; then
- increase_counter 0
- if [[ $counter -gt $num_iterations ]]; then
- xrandr -o normal
- xinput set-prop 'ELAN Touchscreen' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
- fi
- # else, x e y intorno a 0, quindi lascia l'orientazione corrente
- fi
- elif [[ "$x" -gt "0" ]]; then
- increase_counter 3
- if [[ $counter -gt $num_iterations ]]; then
- xrandr -o left
- xinput set-prop 'ELAN Touchscreen' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1
- fi
- else
- increase_counter 1
- if [[ $counter -gt $num_iterations ]]; then
- xrandr -o right
- xinput set-prop 'ELAN Touchscreen' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
- fi
- fi
- sleep 0.02
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement