Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- #
- # This program is under GPLv3 license --
- # http://www.gnu.org/licenses/gpl-3.0.html
- #
- # If you think, that this script is usefull, please send me a postcard to adress:
- # Michal Nanasi
- # Azalkova 1
- # 82101 Bratislava
- # Slovakia
- #
- # Edited by Marek Pikula (marek@pikula.co)
- #
- import os, time, re, sys;
- normal = 'gnome-flip-screen -o up'#; synclient Orientation=0'
- inverted = 'gnome-flip-screen -o bottom'#; synclient Orientation=2'
- left = 'gnome-flip-screen -o left'#; synclient Orientation=1'
- right = 'gnome-flip-screen -o right'#; synclient Orientation=3'
- tpname = 'TPPS/2 IBM TrackPoint' #TrackPoint xinput name
- mousename = 'A4Tech PS/2+USB Mouse' #mouse xinput name
- def turnPointingDev(devName, on):
- if on:
- os.system('xinput set-prop "' + devName + '" "Device Enabled" 1')
- else:
- os.system('xinput set-prop "' + devName + '" "Device Enabled" 0')
- def fixPointingDeviceAxes(devName):
- os.system('xinput set-prop "' + devName + ' "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1')
- os.system('xinput set-prop "' + devName + ' "Evdev Axes Swap" 0')
- os.system('xinput set-prop "' + devName + ' "Evdev Axis Inversion" 0 0')
- def isPointingDevPlugged(devName):
- if os.system('grep "' + devName + '" <(xinput)') != '':
- return True
- else:
- return False
- def fixWacom():
- os.system('xinput map-to-output 10 LVDS1');
- os.system('xinput map-to-output 11 LVDS1');
- os.system('xinput map-to-output 16 LVDS1');
- hdrange = 100;
- def HDDposInRange(pos):
- if pos > (500 - hdrange) and pos < (500 + hdrange):
- return True
- else:
- return False
- def getHDDtype():
- hd = re.search('.([0-9]*).*', open('/sys/devices/platform/hdaps/position','r').readline()) #hd position
- hd1 = int(hd.group(1)) #1st hd position param
- hd2 = int(hd.group(2)) #2nd hd position param
- #if
- def isTabletMode():
- tm = int(open('/sys/devices/platform/thinkpad_acpi/hotkey_tablet_mode','r').readline())
- if tm == 0:
- return False
- else:
- return True
- hdprev = 0 #0: normal 1: left 2: invert 3: right
- tmprev = not isTabletMode()
- while True:
- time.sleep(1);
- if tmprev != isTabletMode():
- if isTabletMode():
- os.system(inverted)
- turnPointingDev(tpname, False)
- tmprev = True
- # os.system('cellwriter --show-window')
- else:
- os.system(normal)
- turnPointingDev(tpname, True)
- tmprev = False
- # os.system('magick-rotation fix')
- # os.system('cellwriter --hide-window')
- fixWacom()
- '''
- try:
- if hd1 > (500 + hdrange):
- if type != 1:
- if tm == 0:
- os.system(left)
- else
- os.system(right)
- if type!=-1:
- if tm==0:
- os.system(right)
- else:
- os.system(left)
- time.sleep(1);
- type=-1
- else:
- if (hd >590):
- if type != 1:
- if tm==0:
- os.system(left)
- else:
- os.system(right)
- time.sleep(1);
- type=1
- else:
- if type!=0:
- os.system(normal)
- time.sleep(1);
- type=0
- except:
- type=47
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement