You are not logged in.

#1 2022-04-23 01:51:52

Maddie
Member
Registered: 2022-02-19
Posts: 3

udev rule for running a command on mouse disconnect

Hello! My mouse (Razer Viper) has some sort of break in the mouse cable that causes it to randomly disconnect at times. After a disconnect, the sensitivity spikes to much higher and I have to switch it back manually. Right now I have a while loop that runs in a different desktop that will set the sensitivity every five seconds (I don't notice anything, it doesn't affect any performance or anything) but I have to manually start it every reboot which gets annoying. I was thinking of making a udev rule or something similar to automatically set the sensitivity back to normal after the mouse reconnects for me.

Currently, the rule is:
```
SUBSYSTEMS=="input", ATTRS{idVendor}=="1532", ATTRS{idProduct}=="0078", ENV{DISPLAY}=":0", ACTION=="add", RUN+="xinput set-prop $(xinput list --id-only 'pointer:Razer Razer Viper') 'libinput Accel Speed' -1"
```
(forgive me if this code block doesn't work, I'm new to the Wiki)

The idVendor and idProduct are correct, but the actual rule doesn't appear to be working and I don't see anything in logs even after running udevadm control --log-priority=info.

I don't have any prior experience with anything like this, and I'd appreciate any help to get this rule working!

Thanks in advance!

Offline

#2 2022-04-23 02:29:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: udev rule for running a command on mouse disconnect

That command would have to run as your user and in an active X11 session.  Udev rule executed code meets neither of these criteria.

But really I'd ditch that whole approach and use a *much* cleaner and simpler approach of an xorg.conf snippet for that setting:

https://wiki.archlinux.org/title/Mouse_ … figuration

Last edited by Trilby (2022-04-23 02:33:43)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2022-04-23 05:18:21

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,393

Re: udev rule for running a command on mouse disconnect

I've had your very same problem and tried the Xorg way suggested by Trilby, but for some reason I still ignore, it did not work.
So, just in case:
https://bbs.archlinux.org/viewtopic.php?id=274909
https://wiki.archlinux.org/title/Udev#S … mouse_plug

Last edited by kokoko3k (2022-04-23 05:23:16)


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

Board footer

Powered by FluxBB