I can't enable bluetooth from the command line in Lubuntu v21.04

I have recently changed OS from Ubuntu to Lubuntu. When I was on Ubuntu, I had a script which automatically connected to a bluetooth device on startup.

The script went like so:

rfkill unblock bluetooth
sleep 15
bluetoothctl connect E0:B8:36:20:AA:35

In Lubuntu however, I can’t enable bluetooth from the command line. I’m using Bluetooth Device Wizard in the GUI to see what’s going on.

Initially, the Bluetooth Device Wizard starts with bluetooth disabled.

(I was going to show an image here, but new users can only use one image apparently, so imagine an identical image here to the other one, but instead of ‘Make Pairable’ it says ‘Enable Bluetooth’.

Then, when I run rfkill unblock bluetooth ,

I am able to enable bluetooth, but the window now shows this:

As you can see, there is a new barrier that didn’t happen on Ubuntu, I have to ‘make pairable’.

Does anyone know how I can do that same as clicking this button but from the command line?

I have tried bluetooth on, bluetoothctl power on, and obviously rfkill unblock bluetooth and rfkill unblock all, but none of them allow me to use bluetoothctl commands.

When I try to use bluetoothctl commands like bluetoothctl pair F2:EB:B7:1E:B5:D7, I it says it’s already paired. But if I try bluetoothctl connect F2:EB:B7:1E:B5:D7, I get Failed to connect: org.bluez.Error.NotReady.

I want to clarify, my problem is not with connecting. I can connect the device fine. It is paired, trusted and connects perfectly well if I were to manually click the ‘enable bluetooth’ and ‘make pairable’ buttons in the Bluetooth Device Wizard. But I need to be able to do this from the command line without the GUI.

I thought there might be a simple setting in system preferences to enable bluetooth at startup from the GUI, but I couldn’t find it.

Does anyone know how I can do this please?

1 Like

Have you tried to restart bluetooth from the command line?

systemctl restart bluetooth

2 Likes

Yes! You did it! Thanks so much!

At first I didn’t think it worked. But I found that using it after rfkill unblock bluetooth and without doing anything else beforehand, it worked.

My script has been edited like so:

rfkill unblock bluetooth
sleep 5
sudo systemctl restart bluetooth
sleep 15
bluetoothctl connect 34:81:F4:99:77:ED
sleep 5
bluetoothctl connect 34:81:F4:99:77:ED

I don’t know why I have to connect twice, but I do. :unicorn:

2 Likes

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.