因为linux睡眠后只要鼠标一动就唤醒了电脑,系统设置都没有办法禁用鼠标的唤醒,也没有第三方软件有这种功能。这一点上mac系统也这样禁止不了鼠标唤醒,这一点很不好,因为难免发生点振动或误碰,电脑就开启了,很恼人。
也有其它的命令的办法可以禁用usb鼠标唤醒睡眠中的电脑,但是每次开机后都要重新运行那个命令。现在在外网找到了办法,如下,
For a USB mouse or keyboard, you can use a udev rule to make the setting permanent. First, look up the PCI vendor ID of your mouse/keyboard using lsusb【lsusb是一个终端命令,重点】. For my mouse, it's 046d:
py@f1177p:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 046d:c52b Logitech, Inc. Unifying Receiver #关注这一行
Bus 003 Device 003: ID 8087:0026 Intel Corp. AX201 Bluetooth
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Then create a "rules" file like my,
/etc/udev/rules.d/logitech.rules #【这个路径是重点,文件名是什么可能不重要】
only replace "046d" with the vendor ID of your own device:【以下内容重点】
ACTION=="add", SUBSYSTEM=="usb", DRIVERS=="usb", ATTRS{idVendor}=="046d", ATTR{power/wakeup}="disabled"
下面是其它2个网友的评论,【这2个人给的命令我都没有用,只用上面,重启电脑就生效了。】
①It could help to reload the rule: udevadm control --reload-rules.
②I think you should use ATTRS{idProduct}=="c52b" there, too, in case there are more than one product from the same vendor.
附加:创建文件的命令是touch,
sudo touch logitech.rules
然后可以用
sudo nano logitech.rules
把rules上面rules的内容粘贴进去, Ctrl+O写入保存, Ctrl+X退出nano.
博主是kubuntu24.04上面测试的,用的鼠标是罗技m590。插拔一下鼠标即生效. 验证方法看下面这个链接,