sleep 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. # handle wifi issues
  9. modprobe -r mwifiex_pcie;
  10. modprobe -r mwifiex;
  11. modprobe -r cfg80211;
  12. ## IPTS: see notes below
  13. ## > Remove IPTS from ME side
  14. #modprobe -r ipts_surface
  15. #modprobe -r intel_ipts
  16. #modprobe -r mei_hdcp
  17. #modprobe -r mei_me
  18. #modprobe -r mei
  19. ## > Remove IPTS from i915 side
  20. #for i in $(find /sys/kernel/debug/dri -name i915_intel_ipts_cleanup); do echo 1 > $i; done
  21. ;;
  22. post) # re-load modules after resume
  23. ## IPTS: see notes below
  24. ## > Load IPTS from i915 side
  25. #for i in $(find /sys/kernel/debug/dri -name i915_intel_ipts_init); do echo 1 > $i; done
  26. ## > Load IPTS from ME side
  27. #modprobe mei
  28. #modprobe mei_me
  29. #modprobe mei_hdcp
  30. #modprobe intel_ipts
  31. #modprobe ipts_surface
  32. # Restart bluetooth
  33. if ps cax | grep bluetoothd; then
  34. bluetoothctl power on
  35. fi
  36. # handle wifi issues: complete cycle
  37. modprobe cfg80211;
  38. modprobe mwifiex;
  39. modprobe mwifiex_pcie;
  40. echo 1 > /sys/bus/pci/rescan
  41. if [ -x "$(command -v nmcli)" ] && [ "$(nmcli net)" = "enabled" ]; then
  42. nmcli net off
  43. nmcli net on
  44. fi
  45. ;;
  46. esac
  47. # Notes:
  48. # - For IPTS, see
  49. # > https://github.com/jakeday/linux-surface/issues/544#issuecomment-519126757
  50. # for an explanation/discussion. We do not unload/reload modules for now as
  51. # the IPTS drivers should be able to resume/suspend without this. If you
  52. # experience any issues on suspend/resume, please file an appropriate issue or
  53. # join the discussion linked above so that we can fix it. As a temporary
  54. # workaround, you may want to uncomment the IPTS-related lines above.