Ubuntu禁用鼠标键盘唤醒

避免误触鼠标键盘唤醒睡眠状态的电脑

Posted by WW on April 6, 2021

参考文章Ubuntu Disable mouse wake from suspend, enabling the wake on mouse

获取USB设备名称

lsusb | sort

使用的是2.4G无线键鼠

Bus 003 Device 003: ID 25a7:fa61 Compx 2.4G Receiver

获取启用唤醒功能的设备

grep . /sys/bus/usb/devices/*/power/wakeup | grep **abled
/sys/bus/usb/devices/3-2/power/wakeup:enabled
/sys/bus/usb/devices/5-4/power/wakeup:enabled

确认 2.4G Receiver 对应的设备路径

dmesg | grep 2.4G | grep -o -P "usb.+?\s"
usb 3-2: 
usb 3-2:

禁用指定的设备

sudo sh -c "echo 'disabled' > /sys/bus/usb/devices/3-2/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).

重启后可能失效,将指令加入 .bashrc or .zshrc.

echo PASS | sudo -S -c "echo 'disabled' > /sys/bus/usb/devices/3-2/power/wakeup"