自 19.10 更新以来,鼠标移动可唤醒处于睡眠状态的计算机

自 19.10 更新以来,鼠标移动可唤醒处于睡眠状态的计算机

自从从 19.04 更新到 19.10 以来,我发现移动鼠标会将计算机从睡眠状态唤醒。我将 Logitech 鼠标及其 Unifying 接收器插入 USB 3.0 端口(USB 2.0 端口的行为相同)。此行为与 19.04 不同。

我在 2017 年的一篇旧帖子中发现了类似内容鼠标移动可唤醒挂起的计算机,但无法禁用它,并且的输出grep --color -E '|enabled' /sys/bus/usb/devices/*/power/wakeup显示:

/sys/bus/usb/devices/1-1.3.1/power/wakeup:disabled
/sys/bus/usb/devices/1-1.3/power/wakeup:disabled
/sys/bus/usb/devices/1-1/power/wakeup:disabled
/sys/bus/usb/devices/2-1.4/power/wakeup:disabled
/sys/bus/usb/devices/2-1/power/wakeup:disabled
/sys/bus/usb/devices/2-2/power/wakeup:enabled
/sys/bus/usb/devices/3-1.4/power/wakeup:disabled
/sys/bus/usb/devices/3-1/power/wakeup:disabled
/sys/bus/usb/devices/usb1/power/wakeup:disabled
/sys/bus/usb/devices/usb2/power/wakeup:disabled
/sys/bus/usb/devices/usb3/power/wakeup:disabled

可以看到,USB 设备 2-2 已启用。

lsusb -t显示:

/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 4: Dev 3, If 0, Class=Hub, Driver=hub/4p, 5000M
            |__ Port 4: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/9p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 4: Dev 4, If 0, Class=Hub, Driver=hub/4p, 480M
    |__ Port 2: Dev 3, If 2, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 2: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 2: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
        |__ Port 3: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 1: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
            |__ Port 4: Dev 6, If 2, Class=Human Interface Device, Driver=usbhid, 12M
            |__ Port 4: Dev 6, If 0, Class=Audio, Driver=snd-usb-audio, 12M
            |__ Port 4: Dev 6, If 1, Class=Audio, Driver=snd-usb-audio, 12M
        |__ Port 8: Dev 4, If 0, Class=Video, Driver=uvcvideo, 480M
        |__ Port 8: Dev 4, If 1, Class=Video, Driver=uvcvideo, 480M

我应该disable用这样的东西吗/etc/rc.local

# Disable
for f in /sys/bus/usb/devices/*/power/wakeup
do
   echo "disabled" > $f
done

为什么会有这种不同的行为,以及在 19.10 中禁用此“新”功能的最佳方法是什么?

更新#1:

另请参阅...

如何防止鼠标移动唤醒暂停的计算机?

http://www.das-werkstatt.com/forum/werkstatt/viewtopic.php?f=7&t=1985

grep -i 启用 /proc/acpi/wakeup

EHC1      S3    *enabled   pci:0000:00:1d.0
XHC       S3    *enabled   pci:0000:00:14.0
PWRB      S4    *enabled   platform:PNP0C0C:00
LID0      S4    *enabled   platform:PNP0C0D:00

显示 EHC1 和 XHC USB 集线器(以及盖子和电源按钮)已启用。

建议...

将以下行添加到/etc/rc.local...

echo "EHC1" > /proc/acpi/wakeup
echo "XHC" > /proc/acpi/wakeup

答案1

我在 2017 年的一篇旧帖子中发现了类似内容鼠标移动可唤醒挂起的计算机,但无法禁用它,以及输出

grep --color -E '|enabled' /sys/bus/usb/devices/*/power/wakeup

显示:

/sys/bus/usb/devices/1-1.3.1/power/wakeup:disabled
/sys/bus/usb/devices/1-1.3/power/wakeup:disabled
/sys/bus/usb/devices/1-1/power/wakeup:disabled
/sys/bus/usb/devices/2-1.4/power/wakeup:disabled
/sys/bus/usb/devices/2-1/power/wakeup:disabled
/sys/bus/usb/devices/2-2/power/wakeup:enabled
/sys/bus/usb/devices/3-1.4/power/wakeup:disabled
/sys/bus/usb/devices/3-1/power/wakeup:disabled
/sys/bus/usb/devices/usb1/power/wakeup:disabled
/sys/bus/usb/devices/usb2/power/wakeup:disabled
/sys/bus/usb/devices/usb3/power/wakeup:disabled

可以看到,USB 设备 2-2已启用。如果我拔下 Logitech Unifying 接收器,然后重新插入,并重复该grep命令,它现在显示为已禁用。 这意味着已启用状态仅在启动时确定。

我当前的修复是编辑/etc/rc.local并添加...

# Disable wake computer from mouse movement
for f in /sys/bus/usb/devices/*/power/wakeup
do
   echo "disabled" > $f
done

exit 0在文件末尾找到之前。这会强制所有 USB 设备显示为已禁用

睡眠功能仍然有效。并且鼠标移动不再会从睡眠状态唤醒。

答案2

暂停时关闭 USB 设备

我的挂起/恢复功能大约在一年前就坏了。对我来说,解决方案是在进入睡眠状态之前关闭 USB 设备,然后使用恢复功能将其打开。

在目录中/lib/systemd/system-sleep创建此脚本:

#!/bin/bash

# Original script was using /bin/sh but shellcheck reporting warnings.

# NAME: custom-xhci_hcd
# PATH: /lib/systemd/system-sleep
# CALL: Called from SystemD automatically
# DESC: Suspend broken for USB3.0 as of Oct 25/2018 various kernels all at once

# DATE: Oct 28 2018.

# NOTE: From comment #61 at: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/522998

TMPLIST=/tmp/xhci-dev-list

# Original script was: case "${1}" in hibernate|suspend)

case $1/$2 in
  pre/*)
    echo "$0: Going to $2..."
    echo -n '' > $TMPLIST
          for i in `ls /sys/bus/pci/drivers/xhci_hcd/ | egrep '[0-9a-z]+\:[0-9a-z]+\:.*$'`; do
              # Unbind xhci_hcd for first device XXXX:XX:XX.X:
               echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/unbind
           echo "$i" >> $TMPLIST
          done
        ;;
  post/*)
    echo "$0: Waking up from $2..."
    for i in `cat $TMPLIST`; do
              # Bind xhci_hcd for first device XXXX:XX:XX.X:
              echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/bind
    done
    rm $TMPLIST
        ;;
esac

使用以下方式标记脚本为可执行文件chmod a+x /lib/systemd/system-sleep/custom-xhci_hcd

重启。

确认脚本正常运行journalctl -b-0 | grep custom-xhci_hcd

Nov 12 14:06:27 alien systemd-sleep[20174]: /lib/systemd/system-sleep/custom-xhci_hcd: Going to suspend...
Nov 12 17:22:19 alien systemd-sleep[20174]: /lib/systemd/system-sleep/custom-xhci_hcd: Waking up from suspend...
  (... SNIP ...)
Nov 22 22:28:06 alien systemd-sleep[24432]: /lib/systemd/system-sleep/custom-xhci_hcd: Going to suspend...
Nov 23 08:16:15 alien systemd-sleep[24432]: /lib/systemd/system-sleep/custom-xhci_hcd: Waking up from suspend...

答案3

我可以报告上述将其放入的解决方案/etc/rc.local

# Disable wake computer from mouse movement
for f in /sys/bus/usb/devices/*/power/wakeup
do
   echo "disabled" > $f
done

...还适用于 KDE Neon(基于 Ubuntu 20.04),用于禁用 Logitech Unifying Receiver 的唤醒功能。非常感谢!

注意:禁用设备/proc/acpi/wakeup对我来说不起作用。

相关内容