Hey Why Does My Linux Laptop Keep Waking up?

A couple of weeks ago I got myself a nice cheap laptop that was on sale for Black Friday. However today I noticed that every time I closed the lid and put the laptop aside, it was waking up. Slack was making notification noises when the lid was closed.

First thing I did was check out /proc/acpi/wakeup by running:

grep enabled /proc/acpi/wakeup

My aha moment came when I saw XHC was enabled to wake up the system from a suspend.

XHC S3 *enabled pci:0000:00:14.0

The above line in the output says that USB 3.0 (XHCI) devices are able to wake up the laptop. Since I have a USB wireless mouse plugged in, I noticed of course it would roll around after I’d close the lid, thus waking up the laptop.

An easy fix for this is to make a file in /etc/udev/rules.d like the following;


ACTION=="add", KERNEL=="0000:00:14.0", SUBSYSTEM=="pci", RUN+="/bin/sh -c 'echo XHC > /proc/acpi/wakeup'"

For your own system, replace the 0000:00:14.0 with the address given after the pci: output in the above grep.

Now I can close the lid and not have to worry about turning the mouse off first.