mashuptwice Asked: 2022-07-24 10:54:31 +0800 CST2022-07-24 10:54:31 +0800 CST 2022-07-24 10:54:31 +0800 CST 连接蓝牙设备时,如何防止我的 Linux 笔记本从睡眠中唤醒? 772 当我将蓝牙耳机连接到电脑并让笔记本电脑进入睡眠状态时,它会在几秒钟后再次唤醒。结合自动睡眠超时,此循环将持续到蓝牙设备不可用或电池电量耗尽。 只要连接了蓝牙设备,如何防止笔记本电脑不断唤醒? linux bluetooth 1 个回答 Voted Best Answer mashuptwice 2022-07-24T10:54:31+08:002022-07-24T10:54:31+08:00 rfkill每次机器进入睡眠状态时,您都可以使用 systemd 服务运行: 在下面创建一个新文件/etc/systemd/system/bluetooth-prevent-wake.service,内容如下: [Unit] Description=disable bluetooth for systemd sleep/suspend targets Before=sleep.target Before=suspend.target Before=hybrid-sleep.target Before=suspend-then-hibernate.target StopWhenUnneeded=yes [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/rfkill block bluetooth ExecStop=/usr/bin/rfkill unblock bluetooth [Install] WantedBy=sleep.target WantedBy=suspend.target WantedBy=hybrid-sleep.target WantedBy=suspend-then-hibernate.target 跑sudo systemctl daemon-reload 运行sudo systemctl enable --now bluetooth-prevent-wake.service以启动并启用新服务
rfkill
每次机器进入睡眠状态时,您都可以使用 systemd 服务运行:/etc/systemd/system/bluetooth-prevent-wake.service
,内容如下:sudo systemctl daemon-reload
sudo systemctl enable --now bluetooth-prevent-wake.service
以启动并启用新服务