How do I prevent mouse movement from waking up a suspended computer?

It's really annoying as I have to unplug the mouse after a suspend to ensure that an occasional bump doesn't wake up the system. I haven't found anything in system settings which could disable this neither by googling around.


I haven't checked the BIOS yet, but I've found a solution!

Short summary: In /proc/acpi/wakeup, you can see which devices are currently enabled to resume from suspend. That list shows names (abbreviated) of so called "Devices". Example "PWRB" means "power button".

If you write device-names to that file, you toggle them between enabled/disabled.

I wrote a small HowTo for disabling wakeup-by-mouse, based on a blog where I found that info.


Thanks to all posters as the mouse wakeup is a major inconvenience and I got my answers here. I wish to add my twist to the solutions as that may help in more cases. I had to disable 3 different items in /proc/acpi/wakeup. My devices: EHC1, EHC2, XHCI. The first 2 are usb2 and the 3rd a usb3 entry. Please note that although the usb transceiver for my mouse is plugged into a usb2 port and nothing is in any usb3 port, the computer will wake on mouse moves until all 3 items are disabled.

$ cat /proc/acpi/wakeup | sort 
Device  S-state   Status   Sysfs node
EHC1      S3    *disabled  pci:0000:00:1d.0
EHC2      S3    *disabled  pci:0000:00:1a.0
GLAN      S4    *enabled   pci:0000:08:00.0
.. ,, ..
USB7      S3    *disabled
WLAN      S3    *disabled  pci:0000:03:00.0
XHCI      S3    *disabled  pci:0000:07:00.0

To have the wakeup items disabled on every startup, you can add something like this to /etc/rc.local ..

echo EHC1 > /proc/acpi/wakeup
echo EHC2 > /proc/acpi/wakeup
echo XHCI > /proc/acpi/wakeup

Test which items need to be disabled - as indicated here - for each of the items that were posted as enabled under cat /proc/acpi/wakeup | sort by running in terminal each of the commands below and then testing if the mouse wakes the system (without the need for restart):

sudo sh -c "echo EHC1 > /proc/acpi/wakeup"
sudo sh -c "echo EHC2 > /proc/acpi/wakeup"
sudo sh -c "echo XHCI > /proc/acpi/wakeup"

(in my case the first one was enough even after testing with other USB ports)


If the /etc/rc.local file doesn't exist

According to this post, run:

printf '%s\n' '#!/bin/bash' 'exit 0' | sudo tee -a /etc/rc.local
sudo chmod +x /etc/rc.local

The file should look something like:

#!/bin/bash
echo EHC1 > /proc/acpi/wakeup
echo EHC2 > /proc/acpi/wakeup
echo XHCI > /proc/acpi/wakeup

exit 0

Reboot.


If that still doesn't work, it might be that the file /etc/systemd/system/rc-local.service is missing or not properly configured.

Test with

sudo /etc/init.d/rc.local start

and

sudo systemctl status rc-local

Following How to Enable /etc/rc.local with Systemd:

Create the file:

sudo nano /etc/systemd/system/rc-local.service

Then add the following content to it.

[Unit]
 Description=/etc/rc.local Compatibility
 ConditionPathExists=/etc/rc.local

[Service]
 Type=forking
 ExecStart=/etc/rc.local start
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes
 SysVStartPriority=99

[Install]
 WantedBy=multi-user.target

Save and close the file. To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit the file, Press Ctrl+X.

Check all is well with no errors with:

sudo systemctl start rc-local.service
sudo systemctl status rc-local.service

Reboot to see changes.