Ubuntu wakes up immediately after suspend when USB mouse is connected
I have the problem that my Ubuntu wakes up immediately after suspend, not every time, but when I connect my USB 3.0 mouse.
When I start Ubuntu, it doesn't detect my mouse, so I must plug/unplug it few times, maybe suspend Ubuntu and wake it up. But when mouse is connected and works, then suspend doesn't work.
I tried editing the wakeup file and disabling some S3 lines, but after that, when I suspended Ubuntu, it turned off the screen, but the PC was still running, so it seems that isn't the right way to handle it.
How can I fix this properly?
Solution 1:
I was having a similar issue to this one. Apparently, there's a known bug where the bluetooth service is causing Ubuntu to wake up immediately upon suspending https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1774994
This was the first link I found when I was googling an answer, which is why I'm posting this solution here.
The solution is basically to have a script ran before and after suspending to start and stop the bluetooth service.
#!/bin/bash
# Makes sure bluetooth service is not running while suspended.
if [ "${1}" == "pre" ]; then
service bluetooth stop
elif [ "${1}" == "post" ]; then
service bluetooth start
fi
Save this script as bluetooth-suspend
under /lib/systemd/system-sleep
and make sure the script can be executed with chmod +x bluetooth-suspend
.
That seemed to fix the issue for me.
Solution 2:
This problem happens on my Ubuntu system as well. When it does, log in again, open a terminal, and run
$ ps aux | grep suspend
If you have the same problem I do, you will see a failed/hanging suspend process. That's what causes the system to start right again, because the suspend isn't finishing itself.
If in the same terminal you try this
$ sudo /sbin/shutdown -h now
you will get a refusal from the system, with a message saying something like that's a destructive transaction, that's the system d's way of saying that as long as that suspend process is hung, you aren't shutting down.
The only fix I know of is to kill the suspend process
$ kill -9 nnnnnn
where nnnnnn
is the number of the hanging suspend process you see in the ps aux
output.
I tried to track discussion of this in forums on the kernel and drivers, but it is pretty tough going. Some people claim it is being solved by kernel updates, say into the latest 4.6
and 4.8
editions, but I don't see any benefit. My problem, I'm pretty sure, links back to commercial Nvidia drivers that don't always get out of the way.
Solution 3:
It happened to my computer when I used Microsoft Mouse. Before I had used Logitech mouse, then it worked just fine. So I switched back to Logitech one, now it works normally again. I put computer on suspend, it stays.