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.

Sorry for the late reply. Honestly, I’ve been trying to figure out a solution to a similar issue myself, but with a built-in keyboard.

Since you’ve had some success with the command echo "XHC" > /proc/acpi/wakeup, you could try making a systemd service instead of the udev rule. In the terminal, type:

sudo nano /etc/systemd/system/disable-xhc-wakeup.service

And write the following:

[Unit]
Description=Disable multiple XHC devices from waking the system

[Service]
Type=oneshot
ExecStart=/bin/sh -c 'for dev in XHC0 XHC1 XHC2 XHC3 XHC4; do echo $$de>

[Install]
WantedBy=multi-user.target

You might have to change the sixth line to the amount of XHC devices your computer has. You can find that with:

cat /proc/acpi/wakeup

Then press control O to write the file, press enter, and then exit with control x.

After that, type the command:

sudo systemctl restart disable-xhc-wakeup.service

and then:

sudo systemctl daemon-reload

Check to make sure that XHC devices’ wakeup ability are disabled with:

cat /proc/acpi/wakeup