Software & AppsOperating SystemLinux

How To fix Bluetooth connection issues after sleep in Ubuntu 18.04 LTS

Ubuntu 17

If you’re an Ubuntu 18.04 LTS user and you’ve been experiencing Bluetooth connection issues after your computer goes to sleep, you’re not alone. This is a common issue, but fortunately, there are several solutions that can help resolve it. In this article, we’ll guide you through these solutions step by step.

Quick Answer

To fix Bluetooth connection issues after sleep in Ubuntu 18.04 LTS, you can try updating the Bluez package, toggling Bluetooth manually using the rfkill command, restarting the Bluetooth service, creating a script for systemd-sleep, installing the PulseAudio Bluetooth module, or changing the Bluetooth adapter USB port.

Update Bluez

Ubuntu 18.04 ships with a version of the Bluez package that has been known to cause some issues. Bluez is the official Linux Bluetooth protocol stack. It’s responsible for managing all the Bluetooth devices on your computer.

To update Bluez, you’ll need to add a new Personal Package Archive (PPA) to your system. A PPA is a software repository that allows you to install and update software packages on your system.

Open the terminal and run the following commands:

sudo add-apt-repository ppa:bluetooth/bluez
sudo apt install bluez

The sudo command allows you to run commands with administrative privileges. The add-apt-repository command adds the specified PPA to your system. The apt install command installs the specified package.

Toggling Bluetooth Manually

If the Bluetooth menu applet doesn’t let you enable Bluetooth after resuming from sleep, you can try toggling Bluetooth manually using the rfkill command.

First, use the rfkill list command to find the ID number for your Bluetooth device. Then, run the following commands to block and unblock your Bluetooth device:

rfkill block <ID>
rfkill unblock <ID>

Replace <ID> with the ID number of your Bluetooth device.

Restarting the Bluetooth Service

Sometimes, simply restarting the Bluetooth service can resolve connection issues. To do this, run the following command in the terminal:

sudo service bluetooth restart

The service command allows you to run a System V init script. In this case, it’s used to restart the Bluetooth service.

Creating a Script for Systemd-sleep

Another solution is to create a script that automatically toggles the Bluetooth device after resuming from sleep.

First, open a new file with the following command:

sudo nano /lib/systemd/system-sleep/bt

Then, paste the following script into the file:

#!/bin/sh

case $1 in
 post)
 modprobe -r btusb
 sleep 1
 service bluetooth restart
 sleep 1
 modprobe btusb
 ;;
esac

Finally, make the script executable with the following command:

sudo chmod +x /lib/systemd/system-sleep/bt

The chmod +x command makes the script executable.

Installing the PulseAudio Bluetooth Module

If you’re using Ubuntu 18.04 and PulseAudio, you might need to install the PulseAudio Bluetooth module. PulseAudio is a sound system that’s used on many Linux-based operating systems.

To install the PulseAudio Bluetooth module, run the following commands in the terminal:

sudo apt-get install pulseaudio-module-bluetooth
pactl load-module module-bluetooth-discover

The apt-get install command installs the specified package. The pactl load-module command loads the specified PulseAudio module.

Changing the Bluetooth Adapter USB Port

If you’re using a USB Bluetooth adapter, try connecting it to a different USB port. Some users have reported that certain USB ports cause disconnections after waking from sleep.

Conclusion

Bluetooth connection issues after sleep can be frustrating, but they’re usually easy to fix. The solutions we’ve discussed in this article should help resolve most issues. However, keep in mind that not all solutions may work for everyone, and it may require some trial and error to find the best solution for your specific setup. If you’re still having trouble, don’t hesitate to seek help from the Ubuntu community or the manufacturer of your Bluetooth device.

How do I check the version of Bluez installed on my system?

To check the version of Bluez installed on your system, open the terminal and run the following command: bluetoothctl --version.

Can I use these solutions for other Ubuntu versions?

These solutions are specifically tailored for Ubuntu 18.04 LTS. However, some of the solutions may work for other versions of Ubuntu or Linux distributions, but there is no guarantee. It’s always recommended to look for solutions specific to your operating system version.

Leave a Comment

Your email address will not be published. Required fields are marked *