sleep 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. case $1 in
  3. pre) # unload the modules before going to sleep
  4. # Disable bluetooth if no device is connected
  5. if ps cax | grep bluetoothd && ! bluetoothctl info; then
  6. bluetoothctl power off
  7. fi
  8. ## Disable bluetooth regardless if devices are connected (see notes below)
  9. #if ps cax | grep bluetoothd; then
  10. # bluetoothctl power off
  11. #fi
  12. # handle wifi issues
  13. modprobe -r mwifiex_pcie;
  14. modprobe -r mwifiex;
  15. modprobe -r cfg80211;
  16. ## IPTS: see notes below
  17. ## > Remove IPTS from ME side
  18. #modprobe -r ipts_surface
  19. #modprobe -r intel_ipts
  20. #modprobe -r mei_hdcp
  21. #modprobe -r mei_me
  22. #modprobe -r mei
  23. ## > Remove IPTS from i915 side
  24. #for i in $(find /sys/kernel/debug/dri -name i915_intel_ipts_cleanup); do echo 1 > $i; done
  25. ;;
  26. post) # re-load modules after resume
  27. ## IPTS: see notes below
  28. ## > Load IPTS from i915 side
  29. #for i in $(find /sys/kernel/debug/dri -name i915_intel_ipts_init); do echo 1 > $i; done
  30. ## > Load IPTS from ME side
  31. #modprobe mei
  32. #modprobe mei_me
  33. #modprobe mei_hdcp
  34. #modprobe intel_ipts
  35. #modprobe ipts_surface
  36. # Restart bluetooth
  37. if ps cax | grep bluetoothd; then
  38. bluetoothctl power on
  39. fi
  40. # handle wifi issues: complete cycle
  41. modprobe cfg80211;
  42. modprobe mwifiex;
  43. modprobe mwifiex_pcie;
  44. echo 1 > /sys/bus/pci/rescan
  45. if [ -x "$(command -v nmcli)" ] && [ "$(nmcli net)" = "enabled" ]; then
  46. nmcli net off
  47. nmcli net on
  48. fi
  49. ;;
  50. esac
  51. # Notes:
  52. # - For IPTS, see
  53. # > https://github.com/jakeday/linux-surface/issues/544#issuecomment-519126757
  54. # for an explanation/discussion. We do not unload/reload modules for now as
  55. # the IPTS drivers should be able to resume/suspend without this. If you
  56. # experience any issues on suspend/resume, please file an appropriate issue or
  57. # join the discussion linked above so that we can fix it. As a temporary
  58. # workaround, you may want to uncomment the IPTS-related lines above.
  59. # - For bluetooth: If you have spontaneous wakeups, you may want to disable
  60. # bluetooth completely, regardless if any devices are connected or not, by
  61. # removing the `! bluetoothctl info;` part as indicated in the comment (e.g.
  62. # comment-out the original check and comment-in the one below). Note that you
  63. # may be required to re-connect your devices after resume if you choose this
  64. # change.