How to disable Bluetooth when notebook sleeps (Ubuntu 18.04 LTS, Dell XPS 13 9370) ? Notebook turns on and connects to my earphones whenever i switch them on (to listen to music from phone) which is undesired (when i travel with my notebook in my backpack for example)
2 Answers
That's because the laptop is not actually sleeping - just turning the display off!
It is possible to make the XPS 13 9370 sleep properly (mine now does) but you are entering a bit of a rabbit hole. Have a look at the accepted answer at Ubuntu 18.04 - Dell XPS13 9370 no longer suspends on lid close. But also look in the comments, including the one by me - you may also need to install the HWE that was released at the same time as 18.04.02 to get a new kernel (installation instructions in the comment).
Mine now deep sleeps when I close the lid, and wakes up very quickly when I open it again, and I get very little battery drain over days of sleeping.

- 2,636
I'm not an expert, but this might be a result of your pc being in a lighter sleep state (s2idle) instead of deep sleep (aka s3).
1. Check what you have:
1.1. dmesg | grep -i "acpi: (supports"
Example output when it supports S3:
[ 0.133190] ACPI: (supports S0 S3 S4 S5)
1.2. and:
cat /sys/power/mem_sleep
Example output when it supports S3/deep:
[s2idle] deep
In the last output you can see which type of sleep is prioritized by which is surrounded with square brackets.
2. Test if sleep is s2idle or s3:
2.1.Try sleeping (either by GUI or by command):
sudo systemctl suspend
2.2. Try if pressing any keyboard key wakes the pc up (an indication of s2idle sleep, I believe).
2.3. (In case of a laptop) try if opening the lid wakes the pc up (might be an indication of s2idle sleep).
2.4. If the previous two didn't wake your pc up then press the power button to wake it up.
2.5 The certain way to know which sleep was used is the kernel messages after sleep:
sudo journalctl | grep "PM: suspend" | tail -2
Example output in case of s3/deep sleep state:
May 09 00:27:49 mypchostname kernel: PM: suspend entry (deep)
May 09 00:30:57 mypchostname kernel: PM: suspend exit
Example output in case of s2idle:
May 08 01:47:15 mypchostname kernel: PM: suspend entry (s2idle)
May 08 08:49:12 mypchostname kernel: PM: suspend exit
3. Get S3 sleep state working.
One possibility for getting S3 sleep might be to update your firmware. If your pc is on the fwupd supported devices list then updates should come with your other, regular updates (via Ubuntu Software or KDE Discover or some such). If your pc isn't on that list then you should find out from your manufacturers website or a websearch or Arch Wiki or Stack Exchange on how to do it for your model.
Another possibility might be some config from BIOS/UEFI. On a Lenovo Thinkpad X1 Carbon gen6 I had to switch from "Windows sleep" option to "Linux sleep" to enable S3. On a Dell Latitude 5289 2-in-1 I had to ensure that "Block Sleep" option was unticked to see S3 supported in the OS.
4. Try out whether deep/S3 sleep works:
4.1. Be root:
sudo su
4.2. Change default sleep (I believe it will revert at restart):
echo deep > /sys/power/mem_sleep
4.3. Exit root (either by pressing Ctrl+D or typing exit
)
4.4. Verify that it is working by going to step 2.
5. Change default sleep state type:
5.1. Run sudoedit /etc/default/grub
.
5.2. Find the line that looks roughly like:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
5.3. Add to that line between the double quotes "
the following:
mem_sleep_default=deep
So the previous example would become:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mem_sleep_default=deep"
5.4. Run sudo update-grub
.
5.5. Reboot.
5.6. If you'd like, verify that it is working by going to step 2.
PS: In my case my pc sometimes failed to return from the s3 sleep state, so I had to return to s2idle.
Some of this answer was possible thanks to this answer.
i'll check that thread then.
– razor May 07 '19 at 12:18