You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux(NixOS)笔记本挂起时插拔USB键盘后无法唤醒问题

Troubleshooting USB Keyboard Wake Failure After Plugging/Unplugging During Suspend on Lemur 8 (NixOS)

I’ve dealt with similar USB wake quirks on laptops with hotplugged devices, so let’s break down what’s going on and how to fix it:

When you plug/unplug the USB keyboard while the system is suspended, the USB bus re-enumerates the device once the system wakes up—but the kernel doesn’t always reattach the wake-up trigger correctly, even though power/wakeup shows as enabled. Here are actionable fixes you can try:

1. Quick Temporary Fix: Reset Wake-up State

If you just need to get the keyboard working right after waking up, toggle the wake-up state to force the kernel to re-recognize the device’s capability:

echo disabled | sudo tee /sys/bus/usb/devices/1-7.1/power/wakeup
echo enabled | sudo tee /sys/bus/usb/devices/1-7.1/power/wakeup

This quick resync often fixes the issue temporarily, but we’ll want a permanent solution below.

2. Permanent Fix with Udev Rules

Udev can automatically set the wake-up state every time the keyboard is plugged in (including after suspend hotplug). Here’s how to set it up:

  1. First, get your keyboard’s vendor and product IDs using lsusb:
    lsusb
    
    Look for your keyboard entry—you’ll see something like ID 1234:5678 Vendor Name Keyboard Model. The 1234 is the vendor ID, 5678 is the product ID.
  2. Create a udev rule file at /etc/udev/rules.d/99-usb-wakeup.rules with this content (replace the IDs with yours):
    SUBSYSTEM=="usb", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", RUN+="/bin/sh -c 'echo enabled > /sys$devpath/power/wakeup'"
    
  3. Reload udev to apply the rule immediately:
    sudo udevadm control --reload-rules && sudo udevadm trigger
    

Now every time you plug in the keyboard (even after suspend), udev will ensure the wake-up setting is enabled.

3. Adjust Kernel USB Power Management Parameters

Some kernel-level USB autosuspend settings can interfere with wake-up after hotplug. Try disabling USB autosuspend entirely (it’s a small trade-off in power draw for reliability):
In NixOS, edit your configuration.nix and add this line:

boot.kernelParams = [ "usbcore.autosuspend=-1" ];

Then rebuild your system configuration:

sudo nixos-rebuild switch

This prevents the kernel from putting USB devices into low-power states that might break wake-up triggers after hotplug.

4. Verify Device Wake-up Capability

Double-check that your keyboard actually supports wake-up (though you said it works when not hotplugged, so this is just a sanity check):

cat /sys/bus/usb/devices/1-7.1/power/wakeup_capable

If the output is yes, the hardware supports wake-up, and the issue is definitely with system state sync. If it’s no, you might have a hardware limitation—but your scenario suggests this isn’t the case.


内容的提问来源于stack exchange,提问作者illabout

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:22:07