TLDR:
➜ ~ cat /etc/systemd/system/stopbt.service
[Unit]
Description=stop bluetooth before hibernation
Before=hibernate.target
[Service]
ExecStart=bluetoothctl power off
[Install]
WantedBy=hibernate.target
➜ ~ cat /etc/systemd/system/startbt.service
[Unit]
Description=start bluetooth after hibernation
After=hibernate.target
[Service]
ExecStart=bluetoothctl power on
[Install]
WantedBy=hibernate.target
systemctl enable stopbt startbt
I had a problem where my bt mouse and keyboard stops working on resume from hibernation. After a couple of days of searching for a solution I came up with above trick. The main idea is to turn off bluetooth power before the hibernation starts and power on it back after resume. I’ve tried another approach that I posted here but it works every other time. My hyposesis is that bt driver gets a corrupted hardware state after resume and even driver reloading doesn’t help, only full restart. It should also for sleep.target
as well. I also have a question: is there a standard way to share systemd unit files for easy installation? Is it good practice to create rpm package for such scripts?
➜ ~ inxi -Eaz
Bluetooth:
Device-1: Intel AX210 Bluetooth driver: btusb v: 0.8 type: USB rev: 2.0
speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-5:3 chip-ID: 8087:0032
class-ID: e001
Report: btmgmt ID: hci0 rfk-id: 2 state: up address: <filter> bt-v: 5.3
lmp-v: 12 status: discoverable: no pairing: no class-ID: 7c010c
inspiration comes from:
https://discussion.fedoraproject.org/t/bluetooth-stops-working-after-sleep