38 lines
1.5 KiB
Diff
38 lines
1.5 KiB
Diff
|
diff -Nru surface-tools-20180914git.orig/penmon/penmon surface-tools-20180914git/penmon/penmon
|
||
|
--- surface-tools-20180914git.orig/penmon/penmon 2018-09-14 10:02:55.000000000 +0200
|
||
|
+++ surface-tools-20180914git/penmon/penmon 2018-09-15 13:25:03.688691667 +0200
|
||
|
@@ -3,7 +3,8 @@
|
||
|
#####CONFIGURATION#####
|
||
|
screen="eDP1"
|
||
|
inputnames=[
|
||
|
- "NTRG0001:01 1B96:1B05 Pen"
|
||
|
+ "NTRG0001:01 1B96:1B05 Pen",
|
||
|
+ "TOUCHPAD"
|
||
|
]
|
||
|
|
||
|
#####PROGRAM CODE#####
|
||
|
@@ -23,10 +24,22 @@
|
||
|
state = subprocess.check_output([xrandr, "-q"])
|
||
|
if state != oldstate:
|
||
|
for input_ in inputnames:
|
||
|
- pattern = re.compile(input_ + " *\tid=([0-9]+)\t")
|
||
|
+ pattern = re.compile(".*" + input_ + ".* *\tid=([0-9]+)\t.* pointer .*")
|
||
|
output = subprocess.check_output([xinput, "list"]).decode("unicode_escape")
|
||
|
matches = re.findall(pattern, output)
|
||
|
|
||
|
+ # Find the display we are interested to move (= the laptop panel)
|
||
|
+ POSSIBLE_OUTPUT = [ "DSI1", "eDP1", "LVDS", "LVDS1" ]
|
||
|
+ for out in POSSIBLE_OUTPUT:
|
||
|
+ match = re.search("^" + out + r" connected .* \(.*\) (?P<rotation>.*) .*",
|
||
|
+ state,
|
||
|
+ re.MULTILINE
|
||
|
+ )
|
||
|
+ if match:
|
||
|
+ screen = out
|
||
|
+ break
|
||
|
+
|
||
|
for id in matches:
|
||
|
subprocess.call([xinput, "map-to-output", id, screen])
|
||
|
+
|
||
|
sleep(1)
|