Mouse Movement Awakens Laptop

I have a Lenovo C940 with i7 processor 16 GB memory and 1 TB SSD. It is running F39 Cinnamon and it is up to date. I have a very minor issue with a cordless mouse using the type A usb port. With the sender/receiver (not to sure what to call it) plugged in, it awakens the computer from suspend with the slightest mouse movement. I found this terminal command that corrects the issue:

echo "XHC" > /proc/acpi/wakeup

This command apparently toggles the acpi between enabled and dissabled for that particular usb port. However, it works for only the current session and must be re-run at the next start-up.

The simplest way to automatically run the command at start-up appears to be to add the following to the crontab file:

@reboot "xxxx"

where “xxxx” is the command you wish to run. This seems simple enough. However, running the command on the command line requires “sudo” and a password.

First. Is this the best/simplest way to do this?

Second, How do I deal with the need for “sudo” and a password in the contab?

1 Like

I’d think that the simplest way to do that would be to put the command in root’s crontab, not your own. How to do that I’ll leave as an exercise for the reader.

Please forgive me. I get very frustrated by command line exercises.
I opened the editor with sudo crontab -e and inserted the line
@reboot echo "XHC" > /proc/acpi/wakeup
and tried to save it. Syntax instructions I found say that I need a complete path. What is the path to a command? Do I actually need the command to be in a file with a path? I went to root’s directory with elevated privileges, but I cannot create a new folder there.

cron doesn’t have a path, so you have to tell it just where every command is. To find out where echo is, you run whereis echo and the first location listed, /usr/bin/echo is the location of the command, and what you need to use.

Type in the terminal:

lsusb

Copy the left-hand side of the device ID for the mouse receiver. It should look something like:

Bus 003 Device 002: ID 046d:c52b Logitech, Inc. Unifying Receiver

and just copy ‘046d’ or whatever the vendor ID is for your receiver. Then go to
/etc/udev/rules.d/ and reopen the tab as admin. Right click to create a new text file and call it something like logitech.rules (or whatever brand your mouse is followed by .rules). In the file, paste this:

ACTION==“add”, SUBSYSTEM==“usb”, DRIVERS==“usb”, ATTRS{idVendor}==“046d”, ATTR{power/wakeup}=“disabled”

Paste the device ID for your receiver in ATTRS(idVendor). Then save the .rules file. Open the terminal again and paste the command:

sudo udevadm control --reload-rules

Don’t remember where I got it from, but this solution is somewhat similar to the one found here:

Under the “I used simpler udev rule” comment.

I have apparently done someting wrong as it does not work. After reboot and suspend (close lid), moving the mouse wakes the system up; the flashing light on the power button goes steady on. To confirm, the vendor id # is the same as your example. Here is my logitech.rules file:

I appreciate your help.

Even after writing the command to update the udev rules (i.e. sudo udevadm control --reload-rules)?

Yes, Sorry I failed to mention that I did run that command before rebooting.

Nothing to be sorry about. :slight_smile:

Try adding ATTRS(idProduct) to the udev rule. That’s the right-hand side of the device ID that you get when you type lsusb. So make it look something like this instead:

ACTION==“add”, SUBSYSTEM==“usb”, DRIVERS==“usb”, ATTRS{idVendor}==“046d”,
ATTRS{idProduct}==“c52b”, ATTR{power/wakeup}=“disabled”

More info:

Under the “The solution I’m using is a udev rule” comment.

Here is what the line now looks like:
ACTION==“add”, SUBSYSTEM==“usb”, DRIVERS==“usb”, ATTRS{idVendor}==“046d”, ATTRS{idProduct}==“c52b”, ATTR{power/wakeup}=“disabled”
It does not work.
Regarding your last comment: I did disconnect and re-connect the receiver, if that is what you are referring to.