I have a razer deathadder mouse connected to my ubuntu 15.10 laptop. This mouse uses 3500 DPI per default which his way to fast. Using razercfg I'm able to set this to 1800 DPI, so no problem here. Unfortunately, this options is not preserved over reboots or even suspend-to-ram/disk (laptop closed). My first thought was to call razercfg on login, but as I said this does not work if with suspend-to-ram/disk. Therefore I thought about using udev rules:

lsusb tells me:

Bus 003 Device 003: ID 058f:9540 Alcor Micro Corp. AU9540 Smartcard Reader
Bus 003 Device 002: ID 8087:8000 Intel Corp. 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 17ef:1010 Lenovo 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 007: ID 04f2:b39a Chicony Electronics Co., Ltd 
Bus 001 Device 003: ID 138a:0017 Validity Sensors, Inc. Fingerprint Reader
Bus 001 Device 011: ID 1532:0016 Razer USA, Ltd DeathAdder Mouse
Bus 001 Device 008: ID 17ef:100f Lenovo 
Bus 001 Device 006: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 004: ID 04b4:0101 Cypress Semiconductor Corp. Keyboard/Hub
Bus 001 Device 002: ID 17ef:1010 Lenovo 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Using the vendor and product ID, I created a file /etc/udev/rules.d/100-razer-deathadder.rules containing:

ACTION=="add", ATTRS{idVendor}=="1532", ATTRS{idProduct}=="0016", RUN+="razercfg -p 1 -r 1:1800"

which should set the appropriate DPI for the mouse when added to the system. The command razercfg -p 1 -r 1:1800is tested and works. I reloaded the rules with sudo udevadm control --reload-rules && udevadm trigger.

However, it does not work. Indeed, udevadm monitor confirms, that this rule does not seem to fire.

Any idea whats the mistake here?


1) Go into /dev/input/ and query the input devices that are most likely to correspond to your mouse, with the terminal cmd:

 $ udevadm info --query=all --name=/dev/input/yr-device-file-name

You will be able to identify it using the two environment variables (env-var)

  • ID_VENDOR_ID=1532

  • MODEL_ID=0016

per your question (depending on yr device, the 2nd env-var may not show).

2) Identify the value of the env-var SUBSYSTEM and add it to yr udev rule.

3) Add the absolute path for the executable razercfg.

So yr udev rule should read something like:

SUBSYSTEM=="___", ACTION=="add", ATTRS{idVendor}=="1532", ATTRS{idProduct}=="0016", RUN+="/path/to/razercfg -p 1 -r 1:1800"

Remember that udev does not execute in a shell environment, so it may not know (mostly does not know) of PATHS and other environment settings you may have come to depend on as a login user. That includes printing to stdout (FD1), unless you make provisions for that by correctly setting DISPLAY and exporting it from within the udev rule, i.e. from within a wrapper script that executes razercfg... (See this AU answer for a redacted summary on that particular aspect and read about udevadm on man udevadm if you have not done so already).


  • Thanks for the reply. Did what you suggested, but still no luck. I found my mouse under /dev/input/mouse2 with E: SUBSYSTEM=input, so I have now the following rule: SUBSYSTEM="input", ACTION=="add", ATTRS{idVendor}=="1532", ATTRS{idProduct}=="0016", RUN+="/usr/local/bin/razercfg -p 1 -r 1:1800". Still not working – user1228633 Feb 8 '16 at 15:01
  • @user1228633: Careful, yr udev rule should read SUBSYSTEM=="input", ... with 2 "=" ! When you run razercfg from terminal (not from udev), does it open a GUI for you ? Is it interactive in any way ? or does it exit quietly ? – Cbhihe Feb 8 '16 at 21:05
  • Ah, yeha sure! That typo fixed the problem. However, another occurred. Apparently razercfg causes to add/remove the device for configuration, which results in udev firing an add rule. Which again executes razercfg.... So I basically get an infinity loop. Is there a way to make my original rule maybe more strictly or something like that? – user1228633 Feb 9 '16 at 18:15
  • Okay, I solved the problem. Just wrote a simple script saving the last time razercfg run in a file in /tmp. If razercfg did not run in the last two seconds, than run it executes razercfg and save the time. – user1228633 Feb 9 '16 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.