sleep 1.8 KB

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