我有 /etc/udev/rules.d/99-wakeup.rules 来禁用使用连接到设备的键盘或鼠标时从睡眠状态唤醒:
ACTION=="add", SUBSYSTEM=="usb", DRIVERS=="usb", ATTRS{idVendor}=="0a81", ATTRS{idProduct}=="0205", ATTR{power/wakeup}="disabled"
USB 设备
$ lsusb | grep 0205
Bus 001 Device 006: ID 0a81:0205 Chesen Electronics Corp. PS/2 Keyboard+Mouse Adapter
我添加GRUB_CMDLINE_LINUX="udev.log-priority=debug"
了 /etc/default/grub 并运行sudo update-grub
以提高日志级别。重新启动并运行
$ LC_ALL=C journalctl -b0 -u systemd-udevd | grep -F /etc/udev/rules.d/99-wakeup.rules
Nov 06 03:13:46 jarnos-OptiPlex-9010 systemd-udevd[341]: Reading rules file: /etc/udev/rules.d/99-wakeup.rules
Nov 06 03:13:47 jarnos-OptiPlex-9010 systemd-udevd[349]: 1-1.1.1: /etc/udev/rules.d/99-wakeup.rules:14 ATTR '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1.1/power/wakeup' writing 'disabled'
Nov 06 03:13:47 jarnos-OptiPlex-9010 systemd-udevd[375]: 1-1.1.1:1.1: /etc/udev/rules.d/99-wakeup.rules:14 ATTR '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1.1/1-1.1.1:1.1/power/wakeup' writing 'disabled'
Nov 06 03:13:47 jarnos-OptiPlex-9010 systemd-udevd[375]: 1-1.1.1:1.1: /etc/udev/rules.d/99-wakeup.rules:14 Failed to write ATTR{/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1.1/1-1.1.1:1.1/power/wakeup}, ignoring: No such file or directory
Nov 06 03:13:47 jarnos-OptiPlex-9010 systemd-udevd[349]: 1-1.1.1:1.0: /etc/udev/rules.d/99-wakeup.rules:14 ATTR '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1.1/1-1.1.1:1.0/power/wakeup' writing 'disabled'
Nov 06 03:13:47 jarnos-OptiPlex-9010 systemd-udevd[349]: 1-1.1.1:1.0: /etc/udev/rules.d/99-wakeup.rules:14 Failed to write ATTR{/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1.1/1-1.1.1:1.0/power/wakeup}, ignoring: No such file or directory
但重启后
$ cat /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1.1/power/wakeup
enabled
什么会将其更改为“启用”?即使鼠标移动也会将系统从睡眠状态唤醒。但是,如果我在启动后重新连接适配器,该值将变为“禁用”。我希望该规则在启动时也有效。如果这是一个错误,应该针对哪个软件包报告此错误?
我可以通过在进入系统暂停之前写入(可能自动)来解决此问题(disabled
参见)。/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1.1/power/wakeup
man systemd-sleep