[systemd-devel] udev event to trigger xinput/xmodmap

Weiwu Zhang a at colourful.land
Mon Jan 2 06:18:43 UTC 2017


Dear all.

Probably a FAQ but I didn't find an answer of. I just learned to disable 
touchpad when a bluetooth mouse is attached, with such a single-line udev 
rule:

SUBSYSTEM=="input", SUBSYSTEMS=="input", ATTRS{name}=="Lenovo Mice N700", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/weiwu/.Xauthority", RUN+="/usr/bin/xinput --disable 'ALP000D:00 044E:120C'"

It proves two things:

- the matching rule works.
- one can run X commands.

But if I wish to extend the usage a bit further, to use xinput/xmodmap 
command to manipulate the very device being matched, then it doesn't work.
For example, this rule intends to switch the mouse-button of the very device
being matched.

SUBSYSTEM=="input", SUBSYSTEMS=="input", ATTRS{name}=="Lenovo Mice N700", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/weiwu/.Xauthority", RUN+="/usr/bin/xinput set-button-map 'Lenovo Mice N700' 3 2 1"

It's easy to guess why - udev must have operated before X being aware of 
the device at all.

The reconfiguration - like remapping mouse buttons with xinput, remapping 
keyboard keys with xmodmap, has to happen in a much later stage. Before 
endeavouring silly fixes like setting off a background process with a 
timed event, is there a more standard approach to those requests?

Thanks in advance!


More information about the systemd-devel mailing list