[systemd-devel] udev event to trigger xinput/xmodmap
Mantas Mikulėnas
grawity at gmail.com
Mon Jan 2 06:36:39 UTC 2017
On Jan 2, 2017 08:19, "Weiwu Zhang" <a at colourful.land> wrote:
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?
Yes, AFAIK, Xorg itself adds devices when it receives a udev event – which
is only broadcast after processing all rules.
* For xinput settings, the simplest method would be to use Xorg.conf.d (see
e.g. the evdev or libinput manpages for possible options). Libinput already
has a built-in option to disable touchpads when mice are connected! I'm
sure the button map can be configured the same way.
* Generally, the standard approach is to 1) handle this from inside the
session and 2) react to X11's own input device events rather than udev
events.
(For that matter, ENV{XAUTHORITY} is already very much a "silly fix". Just
because it's technically possible doesn't mean it should be done.)
Unfortunately I don't think there is anything scriptable for Xinput yet,
although I've seen display event daemons for Xrandr.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20170102/1e094b11/attachment.html>
More information about the systemd-devel
mailing list