Touchscreen and additional external monitor
Solution 1:
There is a specific command for mapping input to a display in xsetwacom
called MapToOutput
. Here is what you do:
Start by figuring out the name of the display you want to map to. This can be done by running xrandr
:
phnomic@phnomic-jobb:~$ xrandr
Screen 0: minimum 320 x 200, current 3200 x 1597, maximum 8192 x 8192
LVDS1 connected 1280x800+1920+797 (normal left inverted right x axis y axis) 286mm x 179mm
1280x800 60.0*+
1024x768 60.0
800x600 60.3 56.2
640x480 59.9
VGA1 connected 1920x1200+0+0 (normal left inverted right x axis y axis) 518mm x 324mm
1920x1200 59.9*+
1920x1080 60.0
1600x1200 60.0
1680x1050 60.0
1280x1024 60.0
1440x900 59.9
1280x960 60.0
1024x768 60.0
800x600 60.3
640x480 60.0
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
HDMI3 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)
In my case I want to use LVDS1.
Next, figure out what your devices are called. This is done using xsetwacom --list
:
phnomic@phnomic-jobb:~$ xsetwacom --list
Wacom ISDv4 E6 Pen stylus id: 20 type: STYLUS
Wacom ISDv4 E6 Pen eraser id: 21 type: ERASER
Wacom ISDv4 E6 Finger touch id: 22 type: TOUCH
Finally run the command xsetwacom set "[device name]" MapToOutput [screen name]
for all devices that you wish to assign. In my case, this becomes:
phnomic@phnomic-jobb:~$ xsetwacom set "Wacom ISDv4 E6 Pen stylus" MapToOutput LVDS1
phnomic@phnomic-jobb:~$ xsetwacom set "Wacom ISDv4 E6 Pen eraser" MapToOutput LVDS1
phnomic@phnomic-jobb:~$ xsetwacom set "Wacom ISDv4 E6 Finger touch" MapToOutput LVDS1
And then you are all good to use your fancy touch screen regardless of what monitors you connect it to and what orientation you use for your monitors.
If you want to know more, I recommend this sourceforge post.
Solution 2:
I had the same problem on my Surface Pro 2 with Ubuntu 12.04 64 bit. I have a dual-monitor setup with a MiniDisplay to HDMI cable, my second monitor isn't touch enabled. What worked for me was to find device names by:
xinput --list
This returned:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ HOLTEK Wireless USB Device id=10 [slave pointer (2)]
⎜ ↳ Atmel Atmel maXTouch Digitizer id=13 [slave pointer (2)]
⎜ ↳ MICROSOFT SAM id=11 [slave pointer (2)]
⎜ ↳ MICROSOFT SAM id=12 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ HOLTEK Wireless USB Device id=9 [slave keyboard (3)]
↳ Front LifeCam id=14 [slave keyboard (3)]
↳ Rear LifeCam
"xsetwacom --list" mentioned by @phnomic wouldn't return anything.
We then map devices to screens like @phnomic suggested:
xsetwacom set "Atmel Atmel maXTouch Digitizer" MapToOutput eDP1
xsetwacom set 11 MapToOutput eDP1
xsetwacom set 12 MapToOutput eDP1
note that 11 and 12 are device IDs for the two devices both named "MICROSOFT SAM"
Solution 3:
I wrote a simple script that will fix things using udev. First create /etc/udev/rules.d/99-monitor-hotplug.rules
It is just this line:
ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="/usr/share/X11/touchscreen.sh"
Now the /usr/share/X11/touchscreen.sh file (mark it +x !!) :
#!/bin/sh
#
# This is designed to be run by hotplug. See hotplug docs ...
#
# Make sure PATH is sane
export PATH="/bin:/usr/bin"
# Now the rest of the ENV to hook into X
# This should probably be run by Dbus, but I don't know how.
# Instead I see who's running Dbus, and get that user's .Xauthority
# So, its kind of a hack!
export USER=`ps -ef | grep dbus-daemon | grep session | cut -d ' ' -f 1`
export DISPLAY=":0"
export XAUTHORITY=/home/$USER/.Xauthority
export ICON=/usr/share/icons/Humanity/devices/48/monitor.svg
# Find Touchscreen id number -- sets id
export id=`xinput | grep Touch | cut -d '=' -f 2 | cut -f 1`
# Find the primary screen!
export screen=`xrandr | grep primary | cut -d ' ' -f 1`
# Use xinput to map them
xinput --map-to-output $id $screen
su $USER -c "notify-send -i $ICON \"TouchScreen\"\
\"Mapping Device $id to your $screen screen\""
The last line just pops up a nice message telling you what it did. When from a terminal, on any user-id, it works great, but won't work from udev! The script itself works fine - its just the notification that fails from udev. Yet nother dbus issue I think. If anyone can fix that - let me know!!