How To Disable USB Wake from Suspend?

I had been happily putting my PC running Ubuntu 20.04.1 LTS into Suspend, and then putting away the USB keyboard and mouse. Sometime recently, perhaps from a Software Update, it stopped working. Now, unless very careful putting them away and avoiding any chance they're jostled later, the PC can wake without me knowing.

My fix had been simply turning off wake by USB in the BIOS. It's still set that way, and I tried re/unsetting it with no change. So I've been reading lots of old posts online (most/all in other distros), about using echo or printf to send specific device names to /proc/acpi/wakeup and of course, it doesn't work. I don't have su set up and with sudo I get:
bash: /proc/acpi/wakeup: Permission denied

Among the least complex suggestions I've found, is to simply add echo lines to /etc/rc.local and of course the system happily reports:
/etc/rc.local: No such file or directory

The devices listed as enabled in /proc/acpi/wakeup are RP05, 8, & 21 with PCI addresses, so maybe USB ports on a card? The power button I'd been using to wake the PC is apparently XHC, the only other thing enabled, also PCI.

I've spelunked around searching various strings like wake, suspend, etc. in Dconf Editor without success. With the good fortune to have a small SSD I've taken to Shutdown since boot is only a few seconds, but I have to close or lose any work in progress.

While it would be wonderful if Mate had a simple setting for this somewhere like Control Panel / Power Management, maybe it's rare that users want it. I'm guessing it could also be insanely complex to auto-detect what various systems are calling the USB ports, if they all follow the convention of using /proc/acpi/wakeup to toggle them.

Help me, O Wizards! :pray: Any ideas?

1 Like

A moment of hope this morning when Software Updater reported something about acpi libraries, but alas update, reboot, suspend, move mouse ... hopes dashed. :neutral_face:

But maybe there's something new in Mate that just needs to be activated in a new way to disable USB wake?

You're on the right track about using /proc/acpi/wakeup. This is something I've needed to do on a couple of machines that just didn't follow my UEFI/BIOS settings for wakeup. Unfortunately I'm not actually aware of a GUI tool for this.

1 Like

Thanks Schykle. :slightly_smiling_face:
Pondering it a bit, I wondered just now if after today's Software Update maybe the widely suggested solution could now be working. But:
$ sudo echo "RP05" > /proc/acpi/wakeup
bash: /proc/acpi/wakeup: Permission denied

$ sudo printf "RP05" > /proc/acpi/wakeup
bash: /proc/acpi/wakeup: Permission denied

In the ACPI wiki intro I see another indication that this issue did arise in relation to a recent Mate update: " ACPI brings the power management under the control of the operating system, as opposed to the previous BIOS-centric system..."

This gives me hope that someone with detailed Mate knowledge may offer a simple fix. :crossed_fingers:

Cautiously curious,in case it could provide more info just now I tried Boot Repair in the Control Center without changing anything.


I don't see anything in the Main tab, but wonder if Reinstall GRUB might bring an update to address the Mate update that I suspect is now over-riding my BIOS setting disabling USB wakeup?

In the GRUB Options tab I clicked Add a kernel option and saw a few acpi options like the one selected here (can't do a screencap of the full list):

So in short, I'm stumped for the moment but hopeful that something here might be helpful in figuring this out.

1 Like

Hi folks,
The following solution is working for me.

  1. Check what is on USB ports:
    lsusb –t

  2. Find the bus where is Human Interface Device.
    In my case Bus 03, Port 1. The device will be 3-1

  3. Create a file
    sudo nano /lib/systemd/system-sleep/mouse_disable_wakeup.sh

  4. Insert the script

    #!/bin/sh
    case "$1" in
    pre)
    echo disabled > /sys/bus/usb/devices/3-1/power/wakeup
    ;;
    esac

  5. Save and Exit

  6. Make the file executable:
    sudo chmod +x /lib/systemd/system-sleep/mouse_disable_wakeup.sh

Also, it is possible to open properties of the file as superuser in Caja and change Permission - Execute - Allow executing as program.
Actually, I am keeping the copy of the file. In case of re-installation, I am just inserting the file to proper place and making it is executable via Caja.

  1. Restart

I found this solution here.

1 Like

Excellent! This looks quite different from anything I'd found elsewhere, which gives me great hope. :blush:

Keep in mind, I need to basically disable all the USB ports since I don't want anythng other than the power button to wake the PC. Here's what I'm seeing:
$ lsusb -t
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 10000M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
|__ Port 5: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 5: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 6: Dev 3, If 2, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 6: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 6: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 8: Dev 4, If 0, Class=Vendor Specific Class, Driver=rtsx_usb, 480M
|__ Port 14: Dev 6, If 0, Class=Wireless, Driver=btusb, 12M
|__ Port 14: Dev 6, If 1, Class=Wireless, Driver=btusb, 12M

Not that it matters, but I guess maybe the end suffix on the usbhid lines indicates USB port speed? Maybe all of the PC's four rear-mounted USB 2.x ports are in the Bus 1 list? No idea why there are two or three lines per Dev(ice?) but it's all starting to sort of make sense. Since I'm using a bluetooth mouse in one of those four USB 2 ports, maybe that's 1-14? The USB keyboard is plugged into another of the four rear USB 2 ports, so that could be 1-8. The PC has two front-mount USB 3.x ports but one's dead, so maybe the good one is 2-1?

To hopefully test this schema out without generating copious smoke and light show, I'm going to try this:
echo disabled > /sys/bus/usb/devices/1-14/power/wakeup
If no mayhem at that point, and the mouse still works, I'll Suspend and wiggle the mouse a bit. Barring calamity I'll be back in a minute all smiles, ready to try again on 1-8 for the keyboard. :crossed_fingers:

OK, so as everyone but me probably already knew, no dice on the "safety test" idea:
$ sudo echo disabled > /sys/bus/usb/devices/1-14/power/wakeup
bash: /sys/bus/usb/devices/1-14/power/wakeup: Permission denied

So now I've written the file with that echo line & set execute. Being mostly lost in the dark here, yet still curious I tried this before testing it:
$ cat /sys/bus/usb/devices/1-14/power/wakeup
disabled
Now to my mind this doesn't bode well for the file actually working, since the "disabled" variable is already there and apparently being ignored. :thinking:

Next I did this:
$ ls --width=1 /sys/bus/usb/devices/
1-0:1.0
1-14
1-14:1.0
1-14:1.1
1-5
1-5:1.0
1-5:1.1
1-6
1-6:1.0
1-6:1.1
1-6:1.2
1-8
1-8:1.0
2-0:1.0
usb1
usb2

In case my guess about the mouse port is wrong, I tried these checks:
$ cat /sys/bus/usb/devices/1-8/power/wakeup
disabled
sigh... :pensive:

Well, since I've already done the file I'll reboot, test, and report. :crossed_fingers:

So, no surprise: no change. :neutral_face:

I guess Mate is ignoring this file, but since the /proc/acpi/wakeup lists some "enabled" devices, maybe I should try figuring out a way to access it and set one to "disabled" for testing? Maybe one of those "echo" strings directed to the read only file that are posted elsewhere somehow magically works when run during boot?

Ideas or suggestions anyone? :slightly_smiling_face:

Eureka! Tonight a small success, building on a different echo command I found posted here by @cipricus and by trying a brute force test that ended up matching the experience described in that post (disable everything). First off, the echo command that works for me is:
sudo sh -c "echo DEVn > /proc/acpi/wakeup"
Everyone here probably knows why the other echo commands I've found sprinkled around the web just give the Permission denied response, and maybe someone will chime in with the Why of that. Bottom line, it worked! When I used RP05 for the DEVn and then did the cat command, that one was disabled.

Alas my dismay when Suspend woke instantly upon either mouse or keyboard input. So in an agitated state, I turned off RP08 and 21. Same lack of success of course. Going brute I then turned off the ONLY other item not already disabled on the entire list: XHC. Now I feared that this would disable the Power Button, but to my great delight it disabled both the keyboard and mouse that had been stubbornly resisting every other attempt. As a bonus, a touch of the Power Button brought me right back to the saved state. Happy me. :smile:

Tomorrow I'll try the methods outlined in that post to make it survive a reboot, and report back. Thanks for your ideas that have helped me to blunder to this first step of a solution. For now, I'm going to Suspend, harass the keyboard and mouse to enjoy again this small success, and then get some rest. :sleeping:

1 Like

"One more thing..." as the saying goes. I saw a post somewhere else saying that once the echo commands worked, they'd survive a Restart. So of course, half asleep and lacking good sense I tried it. Nope - all back to enabled. Then from some corner of semi-dream the idea to try ONLY disabling XHC. Well, you guessed it - that turned off BOTH the USB keyboard and the USB bluetooth mouse. So now I can Suspend again, and attack the Restart survival issue tomorrow. :blush:

OK, so first a confession: I'm blundering mostly in darkness here and after delving beyond my depth into something like this it's easy to forget most of the details after a week or two. So I've tried to document what I'm doing in the two files just created. First, after imagining some comprehension of the Feb 10 at 9:03 post by cipricus here, I created this file:

sudo nano .toggleWakeFromSuspendInBoot.sh

 # This file contains the device name(s) of anything you want Disabled or Enabled,
 # for waking the PC from Suspend. For example, if your PC wakes from Suspend any
 # time you touch the mouse you can put that device name in the line below. To get
 # get a list of device names, copy and paste this line into in the Terminal app:
 #   cat /sys/bus/usb/devices/1-8/power/wakeup
 # Any line with the word "enabled" contains the name of a device that will wake
 # your PC from Suspend. For example, this line on a Dell PC running Ubuntu Mate
 # 20.04.1 indicates the current wake from Suspend status of both the USB keyboard
 # and a bluetooth mouse plugged into a different USB port:
 #   XHC  S0  *enabled  pci:0000:00:14.0
 # Note that this status is unaffected by the BIOS setting chosen by the user, for
 # selecting whether USB devices will wake the PC from Suspend. This status may be
 # toggled between enabled and disabled with this line in the Terminal app (for
 # the XHC device in this example):
 #   sudo sh -c "echo XHC > /proc/acpi/wakeup"
 # After testing to ensure this is the device that prevents waking from Suspend as
 # desired when toggled to "disabled" status, the following line was added without
 # the hashtag start on every line in this description. This way the line is sent 
 # to the PC at every Startup or Restart, thus disabling the USB keyboard and 
 # mouse from waking the PC. More such lines may be added, to enable or disable
 # any other devices in the "cat /sys/bus/usb/devices/1-8/power/wakeup" list.
 # Note that this file is sent to the PC at Startup by the file named:
 #   /etc/systemd/system/wakeup-events.service

echo XHC > /proc/acpi/wakeup

My hope is that since I sometimes turn on dot files in Nemo when rummaging around my Home directory, this might help a forgetful future self by occasionally seeing the file or finding it via a Nemo (aka Files) search for "wake" as I've done during initial struggle with this issue. Since my PC is single user, you may want a different location. Anyway, I then created the file to call that one based on minimal understanding of cipricus' excellent post:

sudo nano /etc/systemd/system/wakeup-events.service

  [Unit]
  Description=Run script toggling wake from Suspend devices during system start

  [Service]
  Type=oneshot
  ExecStart=/bin/bash ~/.toggleWakeFromSuspendInBoot.sh

  [Install]
  WantedBy=multi-user.target

Now I'm going to test all this and report back... :crossed_fingers:

ARRGHH!! :crazy_face:

NO, it doesn't work. The XHC status is enabled. :no_mouth:
Yes, after posting the prior tome about making the two files I did remember to set them both for Executable status:
$ sudo chmod 755 /etc/systemd/system/wakeup-events.service
$ sudo chmod 755 .toggleWakeFromSuspendInBoot.sh
$ ls -al .toggleWakeFromSuspendInBoot.sh
-rwxr-xr-x 1 j j 1685 Dec 5 10:13 .toggleWakeFromSuspendInBoot.sh
$ ls -al /etc/systemd/system/wakeup-events.service
-rwxr-xr-x 1 root root 201 Dec 5 09:30 /etc/systemd/system/wakeup-events.service

So maybe the echo command needs to have the device name in quotes? Testing...

Everyone here probably already knows what I'm doing wrong, and that of course adding the quotes made no difference at all. I'm going to sit in a corner with my little magic line:
sudo sh -c "echo XHC > /proc/acpi/wakeup"
I'll do it manually until some kindly wizard helps me get the startup scripts working.
I'm appreciating all the help here, and the hopeful tidbits gleaned from the askubuntu topic.

Fools in corners have ideas. Mine: "Maybe because it's during boot, the echo string in the .toggleWakeFromSuspendInBoot.sh file needs a specified path?"
So with nano I edited the line to read:
ExecStart=/bin/bash /home/ME/.toggleWakeFromSuspendInBoot.sh
(with my username in place of the ME above of course).
No change.
Back to the corner, this time trying to turn off ideas, use the happily functional echo line, and wait patiently for someone to help... :person_in_lotus_position:

SOLVED! :clinking_glasses:
All I had to do was give up. Rather than keep beating my head on the above strategy, I found a 3-step solution that's scary but it works. Scary because I only dimly understand it, and all three steps require sudo authorization. I found it right here in the Mate community, written by karnemelk.
Steps:

  1. Create a /etc/systemd/system/acpi-wake.service file with this in it:
[Unit]
Description=ACPI Wake Service

[Service]
Type=oneshot
ExecStart=/bin/sh -c "for i in $(cat /proc/acpi/wakeup|grep enabled|awk '{print $1}'|xargs); do [ $i != PBTN ] && echo $i|tee /proc/acpi/wakeup;done"

[Install]
WantedBy=multi-user.target
  1. Start the file with this command:

systemctl start acpi-wake.service

  1. Enable the file with this command:

systemctl enable acpi-wake.service

I used sudo nano /etc/systemd/system/acpi-wake.service to create the file (password required), and password was also required for both the start and enable commands.

It works! I don't know why, nor do I have a clue about the start and enable commands. If someone does, please feel free to explain. If I've just given Russia root access to my lovely new Costco Dell PC, that would be nice to know too. Having now invested much thought, effort and experimentation in this after waiting to see if anyone can shed more light or add warnings, I'm going to write up a more basic step by step and post it in Tips, Tricks and Tutorials with links back here and to the source post by my new hero karnemelk.

Thanks, community for the help and inspiration. :slightly_smiling_face:

1 Like

Last night I wrote up a detailed basic process for this solution and posted it the Stop USB Wake from Suspend Topic in the Mate Community. I hope that simplified basic 3-step process may be helpful for anyone seeking a non-technical procedure that most anyone can try to see if it prevents USB from waking their computer from Suspend. Thanks again to all who helped me find this solution. :blush: