I have a touch screen laptop (Thinkpad X1 Yoga Gen 2, Ubuntu 20.04) connected to an external touch screen monitor. The touch screens' mapping don't work at plug-in so I followed this guide to map the input devices to the respective monitors. I've followed the guide and added a ~/.config/autostart/align_touchinput.desktop
file to allow the mapping to be executed everytime I log in.
Here's my setup:
xinput
...
↳ Wacom Pen and multitouch sensor Finger touch id=9 [slave pointer (2)]
↳ Wacom Pen and multitouch sensor Pen stylus id=10 [slave pointer (2)]
↳ Wacom Pen and multitouch sensor Pen eraser id=25 [slave pointer (2)]
↳ WingCoolTouch WingCoolTouch id=18 [slave pointer (2)]
↳ WingCoolTouch WingCoolTouch id=19 [slave pointer (2)]
....
xrandr
...
eDP-1 connected primary 2560x1440+3072+160 (normal left inverted right x axis y axis) 310mm x 174mm
HDMI-1 connected 3072x1728+0+0 (normal left inverted right x axis y axis) 344mm x 195mm
...
From the above, WingCoolTouch and HDMI-1 are from the external monitor. Thus I get my PC to run this script at startup:
xinput map-to-output 18 HDMI-1
xinput map-to-output 19 HDMI-1
xinput map-to-output 9 eDP-1
xinput map-to-output 10 eDP-1
xinput map-to-output 24 eDP-1
However, I'm facing two problems:
- Every time when I wake up my laptop from sleep/screen turning off, the mapping always resets. Is there a good solution to this issue?
- Because it's a laptop I often have to plug in the touch screen via a different USB port. This changes the
id
fromxinput
. From what I understand,xinput map-to-input
allows mapping by device name. But my OS has detected multiple devices with the same name so it doesn't work (I get "Warning: There are multiple devices matching 'WingCoolTouch WingCoolTouch'" and an error). Is there anyway to map everything namedWingCoolTouch
toHDMI-1
so the mapping will work regardless of the USB port I use?