M HYPE SPLASH
// general

Mapping multiple touch screens persistently (Current it resets after session locked or when plugged to a different USB port)

By Sarah Scott

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:

  1. 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?
  2. Because it's a laptop I often have to plug in the touch screen via a different USB port. This changes the id from xinput. 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 named WingCoolTouch to HDMI-1 so the mapping will work regardless of the USB port I use?

1 Answer

had the same issue, wrote a script:

#! /bin/bash
one=$(xinput --list | grep -F 'WingCoolTouch' | grep -Po '(?<=id=)\d\d?' | head -n 1)
two=$(xinput --list | grep -F 'WingCoolTouch' | grep -Po '(?<=id=)\d\d?' | tail -n 1)
xinput map-to-output $one HDMI-1
xinput map-to-output $two HDMI-1
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy