You are not logged in.

#1 2021-12-30 21:43:32

luser
Member
Registered: 2016-08-27
Posts: 114

[SOLVED]How Do I Turn on my Bluetooth Controller via the Command Line?

My system is fully up to date. I am using KDE Plasma, pipewire, and pipewire-pulse. The GUI interface to bluetooth indicates that the controller is disabled, but clicking the "enable" button is fruitless.

I've tried using bluetoothctl, but it can't find the controller, and there doesn't seem to be any way to use bluetoothctl to power it up or enable it. Perhaps I missed something here, though I tried many other bluetoothctl commands to no avail.

[bluetooth]# show
No default controller available

The controller is there, as lsusb reveals:

Bus 002 Device 005: ID 8087:0a2a Intel Corp. Bluetooth wireless interface

systemctl status bluetooth shows:

● bluetooth.service - Bluetooth service
     Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: disabled)
     Active: active (running) since Thu 2021-12-30 12:47:45 PST; 31min ago
       Docs: man:bluetoothd(8)
   Main PID: 902 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 19057)
     Memory: 2.0M
        CPU: 25ms
     CGroup: /system.slice/bluetooth.service
             └─902 /usr/lib/bluetooth/bluetoothd

Dec 30 12:47:45 random7 systemd[1]: Starting Bluetooth service...
Dec 30 12:47:45 random7 bluetoothd[902]: Bluetooth daemon 5.62
Dec 30 12:47:45 random7 systemd[1]: Started Bluetooth service.
Dec 30 12:47:45 random7 bluetoothd[902]: Starting SDP server
Dec 30 12:47:45 random7 bluetoothd[902]: Bluetooth management interface 1.21 initialized

Related services are present and appear to be working.
$ systemctl list-units | grep -i blue

  sys-devices-pci0000:00-0000:00:14.0-usb2-2\x2d7-2\x2d7:1.0-bluetooth-hci0.device          loaded active plugged   /sys/devices/pci0000:00/0000:00:14.0/usb2/2-7/2-7:1.0/bluetooth/hci0
  sys-subsystem-bluetooth-devices-hci0.device                                               loaded active plugged   /sys/subsystem/bluetooth/devices/hci0
  bluetooth.service                                                                         loaded active running   Bluetooth service
  bluetooth.target                                                                          loaded active active    Bluetooth Support

If I install blueman and reboot the system, the blueman icon indicates that the controller is disabled. Clicking on the blueman icon provides an opportunity to enable the controller, and this actually works.

I would prefer to remove blueman and to be able to enable the controller via the command line, so it could be automated.

Can anyone tell me how that can be done under the current circumstances?

edited for clarity, punctuation, and grammar, as if anyone remembers what the last one is

Last edited by luser (2021-12-31 01:38:02)


luser: an epithet applied by Windows users to linux users

Offline

#2 2021-12-30 23:18:57

jonno2002
Member
Registered: 2016-11-21
Posts: 688

Re: [SOLVED]How Do I Turn on my Bluetooth Controller via the Command Line?

i have 3 simple scripts, i rarely use bluetooth so i only turn it on when i need it, if bluetooth plays up and doesnt work i just run "btrestart" and usually fixes it.

bton:

#!/bin/bash
sudo rfkill unblock bluetooth
sudo systemctl start bluetooth
sleep 1
bluetoothctl power on
exit 0

btoff:

#!/bin/bash
bluetoothctl power off
sudo systemctl stop bluetooth
sudo rfkill block bluetooth
exit 0

btrestart:

#!/bin/bash
bluetoothctl power off
sudo systemctl stop bluetooth
sudo rfkill block bluetooth
sudo rfkill unblock bluetooth
sudo systemctl start bluetooth
sleep 1
bluetoothctl power on
exit 0

Offline

#3 2021-12-30 23:33:49

luser
Member
Registered: 2016-08-27
Posts: 114

Re: [SOLVED]How Do I Turn on my Bluetooth Controller via the Command Line?

Hi, Thanks for the reply. Unfortunately, the bluetoothctl command can't find a controller to power on.

$ bluetoothctl power on
or
$ sudo bluetoothctl power on

produce the same result:

No default controller available

Also, rfkill doesn't seem to be the problem:

$ rfkill

ID TYPE      DEVICE                   SOFT      HARD
 0 bluetooth tpacpi_bluetooth_sw unblocked unblocked
 1 wlan      phy0                unblocked unblocked
 2 bluetooth hci0                unblocked unblocked

luser: an epithet applied by Windows users to linux users

Offline

#4 2021-12-30 23:47:17

jonno2002
Member
Registered: 2016-11-21
Posts: 688

Re: [SOLVED]How Do I Turn on my Bluetooth Controller via the Command Line?

i understand that but did you try those scripts or try those exact commands in order, for whatever reason it does work disabling and blocking the bt controller and then unblocking and re-enabling bt.

Offline

#5 2021-12-31 01:14:01

luser
Member
Registered: 2016-08-27
Posts: 114

Re: [SOLVED]How Do I Turn on my Bluetooth Controller via the Command Line?

Very interesting! bton.sh doesn't work, but btrestart.sh actually does get it started.

$ ./btrestart.sh

No default controller available
Changing power on succeeded

I will play around with the commands to see if I can simplify it.


luser: an epithet applied by Windows users to linux users

Offline

#6 2021-12-31 01:35:35

luser
Member
Registered: 2016-08-27
Posts: 114

Re: [SOLVED]How Do I Turn on my Bluetooth Controller via the Command Line?

After playing around a bit, I found that this script will turn it on a little more simply. I'm not sure if the sleep command is required, but it's so brief it's hardly worth testing without it.

Why this should be necessary is absolutely opaque as far as I'm concerned. It appears to be unblocked from the start!

#!/bin/bash
sudo rfkill block bluetooth
sudo rfkill unblock bluetooth
sleep 1
bluetoothctl power on
exit 0

luser: an epithet applied by Windows users to linux users

Offline

#7 2021-12-31 04:54:57

jonno2002
Member
Registered: 2016-11-21
Posts: 688

Re: [SOLVED]How Do I Turn on my Bluetooth Controller via the Command Line?

glad it worked, its the old "have you tried turning it off and on again" but it seems to work every time bluetooth plays up for me.

those scripts are for my system and obviously bton will only work if everything is off already. i havent bothered adding checking to the scripts to see if things are off or on cause its never been an issue, maybe one day when im bored.

Offline

Board footer

Powered by FluxBB