Template talk:X200 Tablet
How to make an automatic orientation with HDAPS
a simple python code. S is the threshold.
rotate.py
:
# !/usr/bin/python # -*- coding: utf-8 -*- # # This program is under GPLv3 license -- # http://www.gnu.org/licenses/gpl-3.0.html # # Francois guerin / H-Urban import os,time,re,sys,math; normal='xrandr --output LVDS1 --rotate normal&&xsetwacom set stylus Rotate 0' left='xrandr --output LVDS1 --rotate left&&xsetwacom set stylus Rotate 2' right='xrandr --output LVDS1 --rotate right&&xsetwacom set stylus Rotate 1' inverted='xrandr --output LVDS1 --rotate inverted&&xsetwacom set stylus Rotate 3' type=0 s=60 centre=497 while True: time.sleep(0.1); try: f=open('/sys/devices/platform/hdaps/position','r') line=f.readline() y1=re.search('.([0-9]*)',line) x1=re.search(',([0-9]*)',line) x=int(x1.group(1)) y=int(y1.group(1)) if (math.fabs(x-centre)>s) or (math.fabs(y-centre)>s): if (x>y): if (math.fabs(x-centre)>s): if type!= 1: os.system(left) time.sleep(1); type=1 else: if type!=-1: os.system(inverted) time.sleep(1); type=-1 else: if (math.fabs(y-centre)>s): if type!=0: os.system(normal) time.sleep(1); type=0 else: if type!=2: os.system(right) time.sleep(1); type=2 except: type=12