Glam Prestige Journal

Bright entertainment trends with youth appeal.

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.

0

14 Answers

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.

6

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.

4

This solution works with Ubuntu 15.10, 18.04, 20.04

I tried to used lsusb command to find what mouse device is. It's very simple, you type lsusb then unplug the mouse (in my case, it's a Bluetooth receiver) and type lsusb again. The device looks like this:

Bus 007 Device 008: ID 24ae:2000

Now find it in /sys/bus/usb/devices/ folder by using the same way (unplug/plug). In my case, I found that they are somewhere in folders start with 7-2*.

Now try to read the idProduct and idVendor. For example: cat /sys/bus/usb/devices/7-2.3/idProduct => 2000, cat /sys/bus/usb/devices/7-2.3/idVendor => 24ae. That's it.

Finally I create a script in /lib/systemd/system-sleep directory, name it whatever you want.

#!/bin/bash
# From lsusb: Bus 007 Device 008: ID 24ae:2000
idVendor=24ae
idProduct=2000
# Get sys device path by vendorId and productId
function find_device()
{ local vendor=$1 local product=$2 vendor_files=( $(egrep --files-with-matches "$vendor" /sys/bus/usb/devices/*/idVendor) ) for file in "${vendor_files[@]}"; do local dir=$(dirname "$file") if grep -q -P "$product" "$dir/idProduct"; then printf "%s\n" "$dir" return fi done
}
sysdev=$(find_device $idVendor $idProduct)
if [ ! -r "$sysdev/power/wakeup" ]; then echo $idVendor:$idProduct not found 1>&2 exit 1
fi
case "$1" in enabled|disabled) echo $1 > "$sysdev/power/wakeup" ;; *) echo "$0 enabled -- to enable the wakeup for this device" echo "$0 disabled -- to disable the wakeup for this device" ;;
esac
grep --color=auto -H ".*" "$sysdev/power/wakeup"
exit 0

All done.

3

This is my step-by-step "tutorial" to make it work for you:

  1. Use command cat /proc/acpi/wakeup to show the list of wake up devices
  2. Use command sudo sh -c "echo XXXX >/proc/acpi/wakeup" (replace "XXXX" with your device code) to toggle the device state (enabled/disabled). Go one device at a time and try to suspend your machine and wake it up using the device you want to disable until the deserved device will not be able to wake up the machine. Don't forget to always enable back the devices that you do not want to have disabled.
  3. When you find the right device create on your desktop file "acpi_wakeup" containing following code: #!/bin/sh printf "XXXX" > /proc/acpi/wakeup(don't forget to replace "XXXX" with your device code)
  4. Move or copy the file to folder /etc/init.d/. To copy the file use following command:sudo cp /home/USERNAME/Desktop/acpi_wakeup /etc/init.d/acpi_wakeup(replace "USERNAME" with your actual user name)
  5. Make the file executable:sudo chmod 755 /etc/init.d/acpi_wakeup
  6. Then use 'update-rc.d' to make the required symbolic links automatically in other directories:sudo update-rc.d acpi_wakeup defaults(it shows WARNING: ...missing LSB tags and overrides but it is OK. You don't need to worry about it)
  7. Reboot your computer.

Sources and further reading:

In Kubuntu 19.10 the /etc/rc.local setting stopped working for me. I first noticed this on a Manjaro KDE, and found this solution, that worked there. It also works in Kubuntu 19.10, which may mean there are some changes in newer systems (whether related to the kernel or the Plasma version I don't know).

So:

sort /proc/acpi/wakeup

and look for items that are marked "enabled". Note their names (e.g EHC1,EHC2, NXUC). Then, test which of the commands like below stop the mouse from waking up the PC:

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

Create a folder ~/.bin

mkdir ~/.bin

(If you prefer another location, replace that accordingly in the following files.)

Create a systemd service. In terminal:

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

With this content:

[Unit]
Description=Disable wakeup events on startup
[Service]
Type=oneshot
ExecStart=/bin/bash ~/.bin/wakeup-events.sh
[Install]
WantedBy=multi-user.target

Save and enter password.

In terminal:

nano ~/.bin/wakeup-events.sh

with the following content:

#!/bin/bash
# Disable wakeup events
echo EHC1 > /proc/acpi/wakeup
echo EHC2 > /proc/acpi/wakeup
echo NXUC > /proc/acpi/wakeup

(Replace accordingly: e.g EHC1,EHC2, NXUC).

Don't forget:

sudo systemctl enable wakeup-events

And reboot.

Here is an easier solution. I just wrote the first line:

sudo sh -c "echo disabled > /sys/bus/usb/devices/1-1/power/wakeup"

Now, the USB no:1 doesn't wake up the computer.

Note: by rebooting the system this procedure will reset and will need to be re-run.

1

Great explanation. I simply added to rc.local the following command

for d in $(cat /proc/apci/wakeup | grep enabled | grep -v PS2K | cut -b -4); do echo $d > /proc/acpi/wakeup ; done

to disable every device than PS2K (keyboard PS2) from wakeup.

The above solution () works, but it is crude and, also it disables the keyboard wake, which is actually useful.

A more granular alternative can be this: First, we start by enumerating the USB devices connected to the system:

lsusb | sort

from here, it’s pretty obvious which one is the mouse:

 Bus 002 Device 006: ID 046d:c52b Logitech, Inc. Unifying Receiver

then we proceed with finding where the devices are mapped to:

grep . /sys/bus/usb/devices/*/power/wakeup | grep enabled
/sys/bus/usb/devices/2-1.2.6/power/wakeup:enabled
/sys/bus/usb/devices/2-1.2.7/power/wakeup:enabled

Finally, to figure out which is which, we use:

dmesg | grep Logitech | grep -o -P "usb.+?\s"
usb 2-1.2.7:

at which point it’s pretty obvious which one needs to be disabled:

sudo sh -c "echo 'disabled' > /sys/bus/usb/devices/2-1.2.7/power/wakeup"

note: every time you need to echo as superuser, sh -c is necessary, or the system will not allow redirecting to a priviliged file.

Then it’s just a matter of suspending the system and verifying that, while the mouse does not wake it, the keyboard will.

this does not survive a system reboot, so either you need to re-run the last command, or add it to your .bashrc or .zshrc.

This is something that has been annoying me on Ubuntu since when I installed 16.04, and probably there forever, I cannot understand why Canonical wouldn’t add this in the System Settings.

Source:

1

Ridiculous, but plug out, plug back in to determine the device code method is the least tedious. So:

  1. find
grep . /sys/bus/usb/devices/*/power/wakeup | grep enabled

figure out the offender using plug-out-plug-in method

  1. disable
sudo sh -c "echo 'disabled' > /sys/bus/usb/devices/YOUR_DEVICE/power/wakeup"

inspired by this blog post

this script solved my problem. check it out.

 #!/bin/bash
# allow only one instance
r=$(pidof -x -o $$ ssmonoff.sh)
set -- $r
if [ "${#@}" -ge 1 ]; then echo "Script already running. Exit..." exit
fi
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" | ( while read line; do if echo $line | grep "boolean true" &> /dev/null; then xinput --set-prop "Dell Premium USB Optical Mouse" "Device Enabled" "0" xset dpms force off else xinput --set-prop "Dell Premium USB Optical Mouse" "Device Enabled" "1" fi
done )

All you have to do is, first, run sudo xinput list, find the given Name of your USB mouse, and put it on the script. Then, save the file as "ssmonoff.sh", make it executable, and set it to run on startup.

For me all the above solutions only worked temporarily, that is all the changes got reset after plugging out and in the device or reboot.

Disabling the process using the sudo sh -c "echo XXXX > /proc/acpi/wakeup" command works well until reboot (in my case it was sudo sh -c "echo XHC > /proc/acpi/wakeup"), but none of the solutions above made this setting permanent. Eventually, I found a working solution here:

I'm using Ubuntu 20.04.

The solution I'm using is a udev rule that disables wakeup from a particular USB device. It should be agnostic to which port the device is plugged in to.

Create /etc/udev/rules.d/90-usb-wakeup.rules with the following content (modify idVendor and idProduct as appropriate, see output from lsusb):

# Disable waking up from Logitech unified receiver
ACTION=="add", SUBSYSTEM=="usb", DRIVERS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52b", ATTR{power/wakeup}="disabled"

Inspiration comes from

The solution that worked for me, was got from here.

First, we start by enumerating the USB devices connected to the system:

lsusb | sort

from here, it’s pretty obvious which one is the mouse:

Bus 002 Device 006: ID 046d:c52b Logitech, Inc. Unifying Receiver

then we proceed with finding where the devices are mapped to:

grep . /sys/bus/usb/devices/*/power/wakeup | grep enabled
/sys/bus/usb/devices/2-1.2.6/power/wakeup:enabled
/sys/bus/usb/devices/2-1.2.7/power/wakeup:enabled

Finally, to figure out which is which, we use:

dmesg | grep Logitech | grep -o -P "usb.+?\s"
usb 2-1.2.7:

at which point it’s pretty obvious which one needs to be disabled:

sudo sh -c "echo 'disabled' > /sys/bus/usb/devices/2-1.2.7/power/wakeup"

(note: every time you need to echo as superuser, sh -c is necessary, or the system will not allow redirecting to a priviliged file).

Then it’s just a matter of suspending the system and verifying that, while the mouse does not wake it, the keyboard will.

This does not survive a system reboot, so either you need to re-run the last command, or add it to your .bashrc or .zshrc

1

There may be a way specific to your hardware, in which case the option may be available through your system's BIOS settings.

Getting to your BIOS menu to change settings is also system specific. Usually you press a key just after rebooting, and the key to press is often displayed on the screen.

However, user138339's answer seems like a more general way to achieve what you need, and you can do this from the running system.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy