Stop mouse from waking up the computer

Is it possible to stop my wifi mouse from waking up my pc from sleep(suspend)? I’m using it with a usb adapter.

You need to add some udev rules, I was also doing it also manually but searched on GitHub and found a nice custom module. Tried it and it worked. Also there is a usage example on same repo.

1 Like

How do I add this module it to my config?

You can get the file and add:

imports = [ ./module-file.nix ];

into which file you’d like to use this functionality. A similar example also in the file linked above :+1:

You can also do the job manually, by adding something like:

ACTION=="add", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c33a", ATTR{power/wakeup}="disabled"

via services.udev.extraRules (with correct ids of course).

1 Like

The nixos module works (udev rule is created), but it didn’t have any effect on the wakeup behavior.

$ lsusb
Bus 003 Device 002: ID 046d:c539 Logitech, Inc. USB Receiver
  vendor = "046d";
  product = "c539";
$ cat /etc/udev/rules.d/90-usb-wakeup-configure.rules
ACTION=="add", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c539", ATTR{power/wakeup}="disabled"%                                                                                                                                               

Moving the mouse still wakes up the computer.

Hmm not sure then. I also had some weird wake ups which turned out to be caused by something entirely different.
You can check which usb devices can wake the computer up via:

grep . /sys/bus/usb/devices/*/power/wakeup

They also have product and productID etc. on the same folder to identify.

Even if those don’t help, what helped me eventually was echo 1 > /sys/power/pm_debug_messages which showed the module which was the reason for wakeup in dmesg.