Laptop wakes from sleep if bluetooth is enabled

Thanks to tbg for this great solution. Here’s a round up of everything that we went over for anyone who doesn’t want to read through this giant sprawling thread. tbg, feel free to repost this round up if you want to get proper credit for the solution. :wink:

You’ll need to create three script files:

/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

reboot (probably not necessary, but just in case)

If for some reason your bluetooth does not return after suspend, it can be resolved by either running sudo modprobe btusb or by re-suspending and re-resuming.

1 Like

(edit)

Please do not use the above services. Much time has passed since this was originally posted and these services/scripts will likely cause you issues.

1 Like

@tbg suddenly the suspend service/script is no longer working even after a reboot, and I’m trying to find what the source might be.

Here is the status of the suspend service:

● bluetooth-suspend.service - Bluetooth module suspend helper
   Loaded: loaded (/etc/systemd/system/bluetooth-suspend.service; enabled; vendor preset: disabled)
   Active: inactive (dead)

Aug 15 17:23:08 merlin-xiaomi-1 systemd[1]: /etc/systemd/system/bluetooth-suspend.service:5: Unknown lvalue 'WantedBy' in section 'Unit'
Aug 15 17:23:09 merlin-xiaomi-1 systemd[1]: /etc/systemd/system/bluetooth-suspend.service:4: Unknown lvalue 'WantedBy' in section 'Unit'
Aug 15 17:23:09 merlin-xiaomi-1 systemd[1]: /etc/systemd/system/bluetooth-suspend.service:5: Unknown lvalue 'WantedBy' in section 'Unit'
Aug 15 17:23:11 merlin-xiaomi-1 systemd[1]: /etc/systemd/system/bluetooth-suspend.service:4: Unknown lvalue 'WantedBy' in section 'Unit'
Aug 15 17:23:11 merlin-xiaomi-1 systemd[1]: /etc/systemd/system/bluetooth-suspend.service:5: Unknown lvalue 'WantedBy' in section 'Unit'
Aug 15 17:23:11 merlin-xiaomi-1 systemd[1]: Started Bluetooth module suspend helper.
Aug 15 17:23:51 merlin-xiaomi-1 systemd[1]: /etc/systemd/system/bluetooth-suspend.service:4: Unknown lvalue 'WantedBy' in section 'Unit'
Aug 15 17:23:51 merlin-xiaomi-1 systemd[1]: /etc/systemd/system/bluetooth-suspend.service:5: Unknown lvalue 'WantedBy' in section 'Unit'
Aug 15 17:24:20 merlin-xiaomi-1 systemd[1]: /etc/systemd/system/bluetooth-suspend.service:4: Unknown lvalue 'WantedBy' in section 'Unit'
Aug 15 17:24:20 merlin-xiaomi-1 systemd[1]: /etc/systemd/system/bluetooth-suspend.service:5: Unknown lvalue 'WantedBy' in section 'Unit'

Very strange did this happen after a kernel or other update. You might want to test different kernels to see if there’s one that might be working for you if things have changed.

stranger and stranger… manually turning off bluetooth doesn’t work anymore either. I guess it is a new issue… The laptop wakes from suspend every single time. I did update to the latest version of 4.17 along with the other Manjaro updates…

That is not good news if turning off Bluetooth no longer will prevent the suspend issue. Did you try disabling the Bluetooth service as well. I would suggest testing kernel 4.18 as well as the 4.14 LTS kernel. There are also other methods to fully disable Bluetooth.

You can create a file:

/etc/modprobe.d/bluetooth.conf

Add the following line to the file.

install bluetooth /bin/false

That should totally disable all Bluetooth modules from starting. That along with disabling the Bluetooth service may be required.

The other possibility is that your laptop has developed the more common problem of your wifi modules preventing proper sleep functions. The way to test for that is to unload your wifi modules before sleeping to see if things improve. If the wifi modules are now interfering you will need to add them to the scripts to unload/load.

I would also check to see if there is a bios update for your laptop. Sorry that things have gone south on you. Hopefully you can get it sorted.

1 Like

fwiw, shortly after I made my last post, updates seem to have reversed whatever was going on. I’m not currently having any issues as long as I use the script/instructions up above.

Awesome, I just posted another couple of systemd suspend/resume units if you want to see them. I was thinking of posting them here for you as I was thinking of your issue.

In your case adding the bluetooth.service could help as well.

The solution I use disables bluetooth before sleep and restores on wake using a script in /usr/lib/systemd/system-sleep/

The contents of the script /usr/lib/systemd/system-sleep/suspend-bt.sh is:

#!bin/bash

if [ "${1}" == "pre" ]; then
systemctl stop bluetooth && systemctl disable bluetooth

elif [ "${1}" == "post" ]; then
systemctl enable bluetooth
sleep 1s
systemctl start bluetooth
fi

The script should of course be set to root:root and 700 permissions.

I found it was necessary to wait a second before starting bluetooth otherwise the desktop tray (KDE plasma 5 tray icon) would not appear. Stops the laptop from waking in my bag due to a bluetooth mouse waking up.

2 Likes

This is the only solution (and simplest) that worked for me. I'm running Pop!_OS, thank you!

Using a script in /usr/lib/systemd/system-sleep/ is no longer recommended on Arch based systems. The Archwiki advises against this, as this method has been deprecated. A service is the currently recommended method to accomplish this with Arch/Manjaro.

This method was regularly recommended on Debian based systems in the past, but even they no longer recommend this method.

Perhaps report your solution on the Pop!_OS forum as this method is not appropriate on Arch/Manjaro.

Necrobumping posts that are over a year old is also not recommended. This thread is over a year old and I have written many other services that can accomplish this task that may work better than the old service given on this thread. A more efficient way to disable a bluetooth device with a service would be using the device ID:

I have a thread with many more modern services here:

Disabling bluetooth via the device ID helps to conserve battery power on a laptop, so it is probably the better type of service for a laptop.

I tried adding a .service calling the script but didn't work.
Dropping it in the folder /usr/lib/systemd/system-sleep/ solved my issue! Thanks!

PS
is it really needed to disable the unit? Isn't it enough to stop?

Please post the service you attempted to use, I can likely provide a better service method.

I have tried these scripts, but now modprobe btusb doesn't turn my bluetooth back on, and I can't connect to any devices. Even a reboot doesn't fix it.

lsmod  
Module                  Size  Used by
fuse                  139264  5
xt_MASQUERADE          20480  2
nf_conntrack_netlink    57344  0
nfnetlink              16384  2 nf_conntrack_netlink
xfrm_user              45056  1
xfrm_algo              16384  1 xfrm_user
iptable_nat            16384  1
xt_addrtype            16384  2
iptable_filter         16384  1
xt_conntrack           16384  2
nf_nat                 53248  2 iptable_nat,xt_MASQUERADE
nf_conntrack          167936  4 xt_conntrack,nf_nat,nf_conntrack_netlink,xt_MASQUERADE
nf_defrag_ipv6         24576  1 nf_conntrack
nf_defrag_ipv4         16384  1 nf_conntrack
libcrc32c              16384  2 nf_conntrack,nf_nat
br_netfilter           28672  0
bridge                208896  1 br_netfilter
stp                    16384  1 bridge
llc                    16384  2 bridge,stp
overlay               135168  0
aufs                  319488  0
ccm                    20480  6
squashfs               69632  0
loop                   40960  0
bnep                   28672  2
bbswitch               20480  0
sof_pci_dev            20480  0
snd_sof_intel_hda_common    77824  1 sof_pci_dev
snd_sof_intel_hda      20480  1 snd_sof_intel_hda_common
snd_sof_intel_byt      28672  1 sof_pci_dev
snd_sof_intel_ipc      20480  1 snd_sof_intel_byt
snd_sof               114688  4 snd_sof_intel_hda_common,snd_sof_intel_byt,snd_sof_intel_ipc,sof_pci_dev
snd_sof_xtensa_dsp     16384  1 sof_pci_dev
snd_soc_skl           118784  0
x86_pkg_temp_thermal    20480  0
snd_soc_hdac_hda       24576  2 snd_sof_intel_hda_common,snd_soc_skl
intel_powerclamp       20480  0
snd_hda_codec_realtek   126976  1
snd_hda_ext_core       36864  4 snd_sof_intel_hda_common,snd_soc_hdac_hda,snd_soc_skl,snd_sof_intel_hda
coretemp               20480  0
snd_soc_skl_ipc        73728  1 snd_soc_skl
snd_hda_codec_generic    94208  1 snd_hda_codec_realtek
iwlmvm                466944  0
snd_hda_codec_hdmi     69632  2
kvm_intel             311296  0
snd_soc_sst_ipc        20480  1 snd_soc_skl_ipc
ledtrig_audio          16384  2 snd_hda_codec_generic,snd_hda_codec_realtek
snd_soc_sst_dsp        40960  1 snd_soc_skl_ipc
snd_soc_acpi_intel_match    28672  3 snd_sof_intel_hda_common,sof_pci_dev,snd_soc_skl
mac80211              987136  1 iwlmvm
kvm                   774144  1 kvm_intel
snd_soc_acpi           16384  3 snd_soc_acpi_intel_match,sof_pci_dev,snd_soc_skl
snd_soc_core          286720  4 snd_sof,snd_sof_intel_hda_common,snd_soc_hdac_hda,snd_soc_skl
btusb                  57344  0
uvcvideo              114688  0
btrtl                  24576  1 btusb
snd_compress           28672  1 snd_soc_core
ac97_bus               16384  1 snd_soc_core
videobuf2_vmalloc      20480  1 uvcvideo
snd_pcm_dmaengine      16384  1 snd_soc_core
videobuf2_memops       20480  1 videobuf2_vmalloc
irqbypass              16384  1 kvm
btbcm                  16384  1 btusb
libarc4                16384  1 mac80211
snd_hda_intel          53248  6
videobuf2_v4l2         28672  1 uvcvideo
btintel                28672  1 btusb
videobuf2_common       57344  2 videobuf2_v4l2,uvcvideo
joydev                 28672  0
input_leds             16384  0
mousedev               24576  0
ucsi_ccg               20480  0
crct10dif_pclmul       16384  1
crc32_pclmul           16384  0
bluetooth             671744  12 btrtl,btintel,btbcm,bnep,btusb
ghash_clmulni_intel    16384  0
i915                 2322432  29
iwlwifi               393216  1 iwlmvm
aesni_intel           372736  4
nls_iso8859_1          16384  1
videodev              237568  3 videobuf2_v4l2,uvcvideo,videobuf2_common
snd_hda_codec         159744  5 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec_realtek,snd_soc_hdac_hda
hid_multitouch         32768  0
ecdh_generic           16384  1 bluetooth
typec_ucsi             45056  1 ucsi_ccg
nls_cp437              20480  1
aes_x86_64             20480  1 aesni_intel
i2c_algo_bit           16384  1 i915
usbhid                 65536  0
crypto_simd            16384  1 aesni_intel
cryptd                 24576  2 crypto_simd,ghash_clmulni_intel
iTCO_wdt               16384  0
glue_helper            16384  1 aesni_intel
mc                     61440  4 videodev,videobuf2_v4l2,uvcvideo,videobuf2_common
vfat                   24576  1
ecc                    32768  1 ecdh_generic
intel_cstate           16384  0
drm_kms_helper        217088  1 i915
fat                    86016  1 vfat
mei_hdcp               24576  0
8250_dw                28672  0
hid_generic            16384  0
typec                  49152  1 typec_ucsi
dcdbas                 20480  0
iTCO_vendor_support    16384  1 iTCO_wdt
snd_hda_core          102400  10 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_ext_core,snd_hda_codec,snd_hda_codec_realtek,snd_sof_intel_hda_common,snd_soc_hdac_hda,snd_soc_skl,snd_sof_intel_hda
intel_rapl_msr         20480  0
intel_uncore          147456  0
snd_hwdep              20480  1 snd_hda_codec
drm                   520192  9 drm_kms_helper,i915
snd_pcm               139264  11 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_ext_core,snd_hda_codec,snd_sof,snd_sof_intel_hda_common,snd_soc_core,snd_soc_skl,snd_hda_core,snd_pcm_dmaengine
dell_wmi_descriptor    20480  0
intel_rapl_perf        16384  0
wmi_bmof               16384  0
cfg80211              851968  3 iwlmvm,iwlwifi,mac80211
intel_wmi_thunderbolt    20480  0
mxm_wmi                16384  0
pcspkr                 16384  0
snd_timer              40960  1 snd_pcm
mei_me                 45056  1
processor_thermal_device    20480  0
idma64                 20480  0
intel_gtt              24576  1 i915
thunderbolt           196608  0
mei                   122880  3 mei_hdcp,mei_me
tpm_crb                20480  0
agpgart                53248  2 intel_gtt,drm
tpm_tis                16384  0
snd                   110592  21 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_compress,snd_soc_core,snd_pcm
intel_rapl_common      28672  2 intel_rapl_msr,processor_thermal_device
syscopyarea            16384  1 drm_kms_helper
i2c_hid                32768  0
sysfillrect            16384  1 drm_kms_helper
tpm_tis_core           24576  1 tpm_tis
sysimgblt              16384  1 drm_kms_helper
intel_lpss_pci         20480  0
i2c_i801               36864  0
rfkill                 28672  8 bluetooth,cfg80211
hid                   143360  4 i2c_hid,usbhid,hid_multitouch,hid_generic
intel_soc_dts_iosf     20480  1 processor_thermal_device
i2c_nvidia_gpu         16384  0
intel_pch_thermal      16384  0
int3403_thermal        16384  0
soundcore              16384  1 snd
fb_sys_fops            16384  1 drm_kms_helper
intel_lpss             16384  1 intel_lpss_pci
battery                24576  0
int340x_thermal_zone    16384  2 int3403_thermal,processor_thermal_device
ac                     16384  0
wmi                    36864  4 intel_wmi_thunderbolt,wmi_bmof,dell_wmi_descriptor,mxm_wmi
tpm                    77824  3 tpm_tis,tpm_crb,tpm_tis_core
rng_core               16384  1 tpm
evdev                  28672  20
mac_hid                16384  0
int3400_thermal        20480  0
acpi_thermal_rel       16384  1 int3400_thermal
uinput                 20480  0
vboxpci                28672  0
vboxnetflt             32768  0
vboxnetadp             28672  0
vboxdrv               503808  3 vboxpci,vboxnetadp,vboxnetflt
crypto_user            16384  0
ip_tables              36864  2 iptable_filter,iptable_nat
x_tables               49152  5 xt_conntrack,iptable_filter,xt_addrtype,ip_tables,xt_MASQUERADE
ext4                  770048  2
crc32c_generic         16384  0
crc16                  16384  2 bluetooth,ext4
mbcache                16384  1 ext4
jbd2                  131072  1 ext4
xhci_pci               20480  0
crc32c_intel           24576  5
xhci_hcd              278528  1 xhci_pci
bluetoothctl 
Agent registered
[bluetooth]# scan on
No default controller available
[bluetooth]# 
sudo systemctl status bluetooth.service 
[sudo] password for vbabiy: 
● bluetooth.service - Bluetooth service
   Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-09-23 21:13:08 EDT; 3h 53min left
     Docs: man:bluetoothd(8)
 Main PID: 833 (bluetoothd)
   Status: "Running"
    Tasks: 1 (limit: 4915)
   Memory: 2.4M
   CGroup: /system.slice/bluetooth.service
           └─833 /usr/lib/bluetooth/bluetoothd

Sep 23 21:13:08 vitaly-white systemd[1]: Starting Bluetooth service...
Sep 23 21:13:08 vitaly-white bluetoothd[833]: Bluetooth daemon 5.50
Sep 23 21:13:08 vitaly-white systemd[1]: Started Bluetooth service.
Sep 23 21:13:08 vitaly-white bluetoothd[833]: Starting SDP server
Sep 23 21:13:08 vitaly-white bluetoothd[833]: Bluetooth management interface 1.14 initialized```

Please post everything you did.

I copied everything that is here: Laptop wakes from sleep if bluetooth is enabled

what odd is even when I run:

sudo modprobe -vr btusb         
rmmod btusb
rmmod btintel
rmmod btbcm
rmmod btrtl

and

sudo modprobe -v btusb 
insmod /lib/modules/5.3.0-1-MANJARO/kernel/drivers/bluetooth/btintel.ko.xz 
insmod /lib/modules/5.3.0-1-MANJARO/kernel/drivers/bluetooth/btbcm.ko.xz 
insmod /lib/modules/5.3.0-1-MANJARO/kernel/drivers/bluetooth/btrtl.ko.xz 
insmod /lib/modules/5.3.0-1-MANJARO/kernel/drivers/bluetooth/btusb.ko.xz reset=1 

I still have no bluetooth.

This thread is over a year old the advice here is outdated. I am requesting this thread be closed.

Forum kindly sponsored by