Udev rule to map touchscreen

Kernels & Hardware, configuring network, installing services

Udev rule to map touchscreen

Postby workoft » 2018-03-17 07:19

Hi,

I recently switched from GNOME to KDE. While GNOME maps touchscreens to the correct devices automatically, KDE does not. I basically have to re-map manually every time I connect or disconnect a screen.

The commands are:
Code: Select all
xinput --map-to-output $(xinput --list --id-only "Wacom Pen and multitouch sensor Finger touch") eDP-1
xinput --map-to-output $(xinput --list --id-only "Wacom Pen and multitouch sensor Pen stylus") eDP-1
xinput --map-to-output $(xinput --list --id-only "Wacom Pen and multitouch sensor Pen eraser") eDP-1


The most viable solution I've found online was to write a udev rule.
So I created a file /etc/udev/rules.d/99-map-touchscreen.rules
Code: Select all
SUBSYSTEM=="drm", ACTION=="change", RUN+="xinput --map-to-output $(xinput --list --id-only "Wacom Pen and multitouch sensor Finger touch") eDP-1"
SUBSYSTEM=="drm", ACTION=="change", RUN+="xinput --map-to-output $(xinput --list --id-only "Wacom Pen and multitouch sensor Pen stylus") eDP-1"
SUBSYSTEM=="drm", ACTION=="change", RUN+="xinput --map-to-output $(xinput --list --id-only "Wacom Pen and multitouch sensor Pen eraser") eDP-1"


which does nothing at all. The permissions are set to 0644 and I have restarted udev. I've tried other versions, like writing a script and executing that instead (the script itself does what it's supposed to do).
Output of udevadm monitor --environment --udev while disconnecting and connecting the screen:
Code: Select all
UDEV  [1996.738365] change   /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)
ACTION=change
DEVLINKS=/dev/dri/by-path/pci-0000:00:02.0-card
DEVNAME=/dev/dri/card0
DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0
DEVTYPE=drm_minor
HOTPLUG=1
ID_FOR_SEAT=drm-pci-0000_00_02_0
ID_PATH=pci-0000:00:02.0
ID_PATH_TAG=pci-0000_00_02_0
MAJOR=226
MINOR=0
SEQNUM=3229
SUBSYSTEM=drm
TAGS=:uaccess:seat:master-of-seat:
USEC_INITIALIZED=6498190

UDEV  [1999.787795] change   /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)
ACTION=change
DEVLINKS=/dev/dri/by-path/pci-0000:00:02.0-card
DEVNAME=/dev/dri/card0
DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0
DEVTYPE=drm_minor
HOTPLUG=1
ID_FOR_SEAT=drm-pci-0000_00_02_0
ID_PATH=pci-0000:00:02.0
ID_PATH_TAG=pci-0000_00_02_0
MAJOR=226
MINOR=0
SEQNUM=3230
SUBSYSTEM=drm
TAGS=:uaccess:seat:master-of-seat:
USEC_INITIALIZED=6498190


I'm happy with any solution that solves the problem, it doesn't have to be udev.

Thanks in advance,
Malte
workoft
 
Posts: 4
Joined: 2017-03-03 16:02

Re: Udev rule to map touchscreen

Postby debiman » 2018-03-17 08:49

is it necessary to do that via udev?

anyhow, the xrandr command requires the DISPLAY variable to be set and that's probably why your rule fails. you usually need to run xrandr from a running X session as a normal user.
you have to call a custom script from udev, have a look here: http://dt.iki.fi/udev/
User avatar
debiman
 
Posts: 3064
Joined: 2013-03-12 07:18

Re: Udev rule to map touchscreen

Postby workoft » 2018-03-18 13:34

No, I would use any other convenient way. As long as it's automatic and doesn't cause any issues.

Being the wrong user and not having the DISPLAY variable set were indeed two problems. I have now created a script that changes the user and sets the DISPLAY variable to the correct value. I can run it from another terminal (which didn't work as root or as my user without the variable) and it does what it's supposed to do, but it doesn't work when run by udev, so I doubt the rule is actually triggered. Any other ideas?
workoft
 
Posts: 4
Joined: 2017-03-03 16:02


Return to System configuration

Who is online

Users browsing this forum: No registered users and 15 guests

fashionable