[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: which commands are executed by the "bluetooth enable" button?



you can try:

#!/bin/bash
if rfkill list bluetooth | grep -q 'yes$' ; then 
    rfkill unblock bluetooth
else
    rfkill block bluetooth
fi

https://askubuntu.com/questions/1144596/set-a-shortcut-to-toggle-bluetooth-on-or-off


Il 28/04/20 23:03, Marco Möller ha scritto:
There are two buttons for triggering Bluetooth availability by a mouse click, and they appear to do some magic. I would need to find out about this, I am searching for the commands which become executed by these buttons.

After a reboot Bluetooth is still deactivated, and for activating it I can go here:

System Settings - Network - Bluetooth

There, I find emphasized by alarming color "Bluetooth is disabled" and next to it is then nicely provided an "Enable" button which perfectly works. After Bluetooth becomes activated in this way, then there appears the related System Tray icon in the panel of KDE Plasma, and from now on I can there deactivate Bluetooth, or activate it there again, forth and back, repeatedly, which works as expected.

In another thread I asked how to set a keyboard shortcut for this activation/deactivation of Bluetooth, and quickly got the very helpful answer how to set the needed "custom shortcut" (Thanks, Helge!). However, the command which has to become executed by the shortcut troubles. It worked for Helge, but not for me, and the Internet is full about the problem and error message as I receive it.

There obviously is something more going on behind this buttons, than simply calling the commands "bluetoothctl power on" or "bluetoothctl power off".
I tested the "bluetoothctl" command interactively on a CLI as the user or with sudo and got with sub-command "devices" (and others) the error message: "No default controller available".
The internet is full of questions about this and by now I could not find any good answer. There are suggestions that the problem would have been solved after a cold start (not simply a reboot), after driver re-installation, booting into Windows and back into Linux, and many more weird solutions.

BUT: if I use the mouse in order to trigger the button, then bluetooth becomes enabled or disabled without any problems, forth and back, repeatedly. And if it first becomes enabled by the mouse click on the button, I then afterwards also succeed on the CLI with the commands given as a normal user "bluetoothctl power off" and "bluetoothctl power on", forth and back, repeatedly (and also the keyboard shortcut works for me, then).
Once I use the mouse for deactivating Bluetooth by the button, then the bluetoothctl commands again fail with said error message.

Obviously, the buttons know the magic trick how to activate/deactivate the communication with the present hardware at a state, when bluetoothctl cannot succeed to get access to the device.
I should add, that "systemctl status bluetooth" confirms this service to all the time being active, and obviously there are no drivers or configurations missing - the buttons can do the job. So, nothing is missing but to find out which commands these buttons trigger.
Well, I am now searching for this full series of commands, for achieving on the CLI the same result as these buttons are doing it.

Could you help?
Marco.


-- 
Saluti, Luca Pedrielli 

Reply to: