Download file rotate.py
1 #!/usr/bin/python
2 #
3 # This program is under GPLv3 license --
4 # http://www.gnu.org/licenses/gpl-3.0.html
5 #
6 # If you think, that this script is usefull, please send me a postcard to
7 # adress:
8 # Michal Nanasi
9 # Azalkova 1
10 # 82101 Bratislava
11 # Slovakia
12
13 import os,time,re,sys;
14
15 normal='xrandr --output LVDS --rotate normal'
16 left='xrandr --output LVDS --rotate left'
17 right='xrandr --output LVDS --rotate right'
18
19 type=0
20
21 while True:
22 time.sleep(0.1);
23 try:
24 f=open('/sys/devices/platform/hdaps/position','r')
25 line=f.readline()
26 m=re.search('.([0-9]*).*',line)
27 # print m.group(1)
28 trash=int(m.group(1))
29 if(trash <400):
30 if type!=-1:
31 os.system(right)
32 time.sleep(1);
33 type=-1
34 else:
35 if (trash >590):
36 if type != 1:
37 os.system(left)
38 time.sleep(1);
39 type=1
40 else:
41 if type!=0:
42 os.system(normal)
43 time.sleep(1);
44 type=0
45 except:
46 type=47
2 #
3 # This program is under GPLv3 license --
4 # http://www.gnu.org/licenses/gpl-3.0.html
5 #
6 # If you think, that this script is usefull, please send me a postcard to
7 # adress:
8 # Michal Nanasi
9 # Azalkova 1
10 # 82101 Bratislava
11 # Slovakia
12
13 import os,time,re,sys;
14
15 normal='xrandr --output LVDS --rotate normal'
16 left='xrandr --output LVDS --rotate left'
17 right='xrandr --output LVDS --rotate right'
18
19 type=0
20
21 while True:
22 time.sleep(0.1);
23 try:
24 f=open('/sys/devices/platform/hdaps/position','r')
25 line=f.readline()
26 m=re.search('.([0-9]*).*',line)
27 # print m.group(1)
28 trash=int(m.group(1))
29 if(trash <400):
30 if type!=-1:
31 os.system(right)
32 time.sleep(1);
33 type=-1
34 else:
35 if (trash >590):
36 if type != 1:
37 os.system(left)
38 time.sleep(1);
39 type=1
40 else:
41 if type!=0:
42 os.system(normal)
43 time.sleep(1);
44 type=0
45 except:
46 type=47






