Browse Source

Disable bluetooth when suspending without anything connected.

On Surface Book 2 it is not possible to archive stable S0ix while bluetooth is
enabled but no device is connected. Either S0ix fails completely, or the
residency is pretty bad. When bluetooth is disabled, or a device such as the pen
is connected, S0ix works fine and residency is great again.

By disabling bluetooth when no device is connected, we get proper S0ix in all
situations. And since no device is connected, the reset won't really matter.

Signed-off-by: Dorian Stoll <dorian.stoll@tmsp.io>
Dorian Stoll 5 years ago
parent
commit
b74befa0ca
1 changed files with 9 additions and 0 deletions
  1. 9 0
      root/lib/systemd/system-sleep/sleep

+ 9 - 0
root/lib/systemd/system-sleep/sleep

@@ -1,6 +1,12 @@
 #!/bin/bash
 #!/bin/bash
 case $1 in
 case $1 in
   pre)    # unload the modules before going to sleep
   pre)    # unload the modules before going to sleep
+
+    # Disable bluetooth if no device is connected
+    if ! bluetoothctl info; then
+      bluetoothctl power off
+    fi
+
     # handle wifi issues
     # handle wifi issues
     modprobe -r mwifiex_pcie;
     modprobe -r mwifiex_pcie;
     modprobe -r mwifiex;
     modprobe -r mwifiex;
@@ -25,6 +31,9 @@ case $1 in
     #modprobe mei_hdcp
     #modprobe mei_hdcp
     #modprobe intel_ipts
     #modprobe intel_ipts
 
 
+    # Restart bluetooth
+    bluetoothctl power on
+
     # handle wifi issues: complete cycle
     # handle wifi issues: complete cycle
     modprobe cfg80211;
     modprobe cfg80211;
     modprobe mwifiex;
     modprobe mwifiex;