September 30, 2019

Fixing Bluetooth Suspend Issue on Xiaomi Mi Air 13

My notebook had problems suspending to ram. When closing the lid or manually suspending the device, it would wake up immediately after about 5 seconds. This was extremly annoying – so I investigated and it turns out that the bluetooth subsystem made was involved in the issue. I realized that after disabling the bluetooth subsystem, the notebook would sleep and wake just fine. A quick google search revealed the following solution, which also helped in my case. Thanks to the Manjaro community!

https://forum.manjaro.org/t/laptop-wakes-from-sleep-if-bluetooth-is-enabled/50647

/etc/systemd/system/bluetooth-reload.service

[Unit]
Description=Reload bluetooth driver after system resume
After=hibernate.target suspend.target hybrid-sleep.target

[Service]
Type=oneshot
TimeoutSec=15
ExecStart=/usr/sbin/modprobe btusb

[Install]
WantedBy=hibernate.target suspend.target hybrid-sleep.target

/etc/systemd/system/bluetooth-suspend.service

[Unit]
Description=Bluetooth module suspend helper
Before=sleep.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target

[Service]
Type=simple
ExecStart=-/usr/bin/bluetooth-suspend.sh

[Install]
WantedBy=sleep.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target

/usr/bin/bluetooth-suspend.sh

#!/bin/bash
modprobe -r btusb

Next, you’ll need to run the following list of commands.

sudo chmod +x /etc/systemd/system/bluetooth-reload.service
sudo chown root:root /etc/systemd/system/bluetooth-reload.service
sudo chmod +x /etc/systemd/system/bluetooth-suspend.service
sudo chown root:root /etc/systemd/system/bluetooth-suspend.service
sudo chmod +x /usr/bin/bluetooth-suspend.sh
sudo chown root:root /usr/bin/bluetooth-suspend.sh
sudo systemctl enable bluetooth-suspend.service
sudo systemctl start bluetooth-suspend.service
sudo systemctl enable bluetooth-reload.service
sudo systemctl start bluetooth-reload.service