MulitMonitor bug

Quick and dirty fix... Script now looks for an external display before trying to rotate the screen. If one is present it will automatically deactivate autorotation of the internal screen.
This commit is contained in:
AykoPoel 2015-02-20 12:09:47 +01:00
parent 01f4afddcf
commit bd6eaf1fb0
1 changed files with 30 additions and 16 deletions

View File

@ -27,6 +27,13 @@ def refreshtouch():
os.system('xinput disable "NTRG0001:01 1B96:1B05"') os.system('xinput disable "NTRG0001:01 1B96:1B05"')
os.system('xinput enable "NTRG0001:01 1B96:1B05"') os.system('xinput enable "NTRG0001:01 1B96:1B05"')
def checkdisplays():
check_displays = "xrandr | grep -w 'connected'"
str_displays = str(subprocess.check_output(check_displays, shell=True).lower().rstrip())
list_displays = str_displays.splitlines()
int_displays = len(list_displays)
return int_displays
#PARAMETERS #PARAMETERS
count = 0 count = 0
path = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) path = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
@ -57,16 +64,21 @@ firstrun = True
with open(dpath + 'in_accel_scale') as f: with open(dpath + 'in_accel_scale') as f:
scale = float(f.readline()) scale = float(f.readline())
while True: while True:
multimonitor = False
int_displays = checkdisplays()
if int_displays > 1:
multimonitor = True
time.sleep(1.0/freq) time.sleep(1.0/freq)
previous_state = current_state previous_state = current_state
status = readFile(os.path.join(path, 'status.txt')) status = readFile(os.path.join(path, 'status.txt'))
if str(status[0]) == "on": if str(status[0]) == "on" and multimonitor == False:
with open(dpath + 'in_accel_x_raw', 'r') as fx: with open(dpath + 'in_accel_x_raw', 'r') as fx:
with open(dpath + 'in_accel_y_raw', 'r') as fy: with open(dpath + 'in_accel_y_raw', 'r') as fy:
with open(dpath + 'in_accel_z_raw', 'r') as fz: with open(dpath + 'in_accel_z_raw', 'r') as fz:
thex = float(fx.readline()) thex = float(fx.readline())
they = float(fy.readline()) they = float(fy.readline())
thez = float(fz.readline()) thez = float(fz.readline())
if checkdisplays() == 1:
if (thex >= 65000 or thex <=650): if (thex >= 65000 or thex <=650):
if (they <= 65000 and they >= 64000): if (they <= 65000 and they >= 64000):
os.system(normal) os.system(normal)
@ -83,13 +95,15 @@ while True:
current_state = 3 current_state = 3
os.system('clear') os.system('clear')
print("ExtDi: " + str(multimonitor))
print("A-ROT: " + status[0]) print("A-ROT: " + status[0])
print(" x: " + str(thex)) print(" x: " + str(thex))
print(" y: " + str(they)) print(" y: " + str(they))
print(" z: " + str(thez)) print(" z: " + str(thez))
print(" POS: " + state_dict[current_state]) print(" POS: " + state_dict[current_state])
if status[0] == "off": if status[0] == "off" or multimonitor == True:
os.system('clear') os.system('clear')
print("ExtDi: " + str(multimonitor))
print("A-ROT: " + status[0]) print("A-ROT: " + status[0])
print(" x: " + status[0]) print(" x: " + status[0])
print(" y: " + status[0]) print(" y: " + status[0])