Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. #!/usr/bin/env python3
  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 adress:
  7. # Michal Nanasi
  8. # Azalkova 1
  9. # 82101 Bratislava
  10. # Slovakia
  11. #
  12. # Edited by Marek Pikula (marek@pikula.co)
  13. #
  14.  
  15. import os, time, re, sys;
  16.  
  17. normal = 'gnome-flip-screen -o up'#; synclient Orientation=0'
  18. inverted = 'gnome-flip-screen -o bottom'#; synclient Orientation=2'
  19. left = 'gnome-flip-screen -o left'#; synclient Orientation=1'
  20. right = 'gnome-flip-screen -o right'#; synclient Orientation=3'
  21.  
  22. tpname = 'TPPS/2 IBM TrackPoint' #TrackPoint xinput name
  23. mousename = 'A4Tech PS/2+USB Mouse' #mouse xinput name
  24.  
  25. def turnPointingDev(devName, on):
  26. if on:
  27. os.system('xinput set-prop "' + devName + '" "Device Enabled" 1')
  28. else:
  29. os.system('xinput set-prop "' + devName + '" "Device Enabled" 0')
  30.  
  31. def fixPointingDeviceAxes(devName):
  32. os.system('xinput set-prop "' + devName + ' "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1')
  33. os.system('xinput set-prop "' + devName + ' "Evdev Axes Swap" 0')
  34. os.system('xinput set-prop "' + devName + ' "Evdev Axis Inversion" 0 0')
  35.  
  36. def isPointingDevPlugged(devName):
  37. if os.system('grep "' + devName + '" <(xinput)') != '':
  38. return True
  39. else:
  40. return False
  41.  
  42. def fixWacom():
  43. os.system('xinput map-to-output 10 LVDS1');
  44. os.system('xinput map-to-output 11 LVDS1');
  45. os.system('xinput map-to-output 16 LVDS1');
  46.  
  47. hdrange = 100;
  48.  
  49. def HDDposInRange(pos):
  50. if pos > (500 - hdrange) and pos < (500 + hdrange):
  51. return True
  52. else:
  53. return False
  54.  
  55. def getHDDtype():
  56. hd = re.search('.([0-9]*).*', open('/sys/devices/platform/hdaps/position','r').readline()) #hd position
  57. hd1 = int(hd.group(1)) #1st hd position param
  58. hd2 = int(hd.group(2)) #2nd hd position param
  59.  
  60. #if
  61.  
  62. def isTabletMode():
  63. tm = int(open('/sys/devices/platform/thinkpad_acpi/hotkey_tablet_mode','r').readline())
  64. if tm == 0:
  65. return False
  66. else:
  67. return True
  68.  
  69. hdprev = 0 #0: normal 1: left 2: invert 3: right
  70. tmprev = not isTabletMode()
  71.  
  72. while True:
  73. time.sleep(1);
  74. if tmprev != isTabletMode():
  75. if isTabletMode():
  76. os.system(inverted)
  77. turnPointingDev(tpname, False)
  78. tmprev = True
  79. # os.system('cellwriter --show-window')
  80. else:
  81. os.system(normal)
  82. turnPointingDev(tpname, True)
  83. tmprev = False
  84. # os.system('magick-rotation fix')
  85. # os.system('cellwriter --hide-window')
  86. fixWacom()
  87. '''
  88. try:
  89.  
  90. if hd1 > (500 + hdrange):
  91. if type != 1:
  92. if tm == 0:
  93. os.system(left)
  94. else
  95. os.system(right)
  96.  
  97. if type!=-1:
  98. if tm==0:
  99. os.system(right)
  100. else:
  101. os.system(left)
  102. time.sleep(1);
  103. type=-1
  104. else:
  105. if (hd >590):
  106. if type != 1:
  107. if tm==0:
  108. os.system(left)
  109. else:
  110. os.system(right)
  111. time.sleep(1);
  112. type=1
  113. else:
  114. if type!=0:
  115. os.system(normal)
  116. time.sleep(1);
  117. type=0
  118. except:
  119. type=47
  120. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement