<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On Jan 2, 2017 08:19, "Weiwu Zhang" <a@colourful.land> wrote:<br type="attribution"><blockquote class="m_325990890337738680quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear all.<br>
<br>
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:<br>
<br>
SUBSYSTEM=="input", SUBSYSTEMS=="input", ATTRS{name}=="Lenovo Mice N700", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/weiwu/.<wbr>Xauthority", RUN+="/usr/bin/xinput --disable 'ALP000D:00 044E:120C'"<br>
<br>
It proves two things:<br>
<br>
- the matching rule works.<br>
- one can run X commands.<br>
<br>
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.<br>
For example, this rule intends to switch the mouse-button of the very device<br>
being matched.<br>
<br>
SUBSYSTEM=="input", SUBSYSTEMS=="input", ATTRS{name}=="Lenovo Mice N700", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/weiwu/.<wbr>Xauthority", RUN+="/usr/bin/xinput set-button-map 'Lenovo Mice N700' 3 2 1"<br>
<br>
It's easy to guess why - udev must have operated before X being aware of the device at all.<br>
<br>
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?</blockquote></div></div></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="m_325990890337738680quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Yes, AFAIK, Xorg itself adds devices when it receives a udev event – which is only broadcast after processing all rules.</div><div dir="auto"><br></div><div dir="auto">* 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.</div><div dir="auto"><br></div><div dir="auto"></div><div class="gmail_extra" dir="auto">* 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.</div><div class="gmail_extra" dir="auto"><br></div><div class="gmail_extra" dir="auto">(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.)</div><div class="gmail_extra" dir="auto"><br></div><div class="gmail_extra" dir="auto">Unfortunately I don't think there is anything scriptable for Xinput yet, although I've seen display event daemons for Xrandr.</div></div>